From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] nat/amd64-linux-siginfo.c: Move align attribute from typedef to struct
Date: Sat, 5 Jun 2021 01:14:26 +0100 [thread overview]
Message-ID: <20210605001427.3597687-2-pedro@palves.net> (raw)
In-Reply-To: <20210605001427.3597687-1-pedro@palves.net>
Compiling GDB with current git Clang (future 13) fails with (among
other problems), this issue:
$ make nat/amd64-linux-siginfo.o
CXX nat/amd64-linux-siginfo.o
src/gdb/nat/amd64-linux-siginfo.c:590:35: warning: passing 4-byte aligned argument to 8-byte aligned parameter 1 of 'compat_x32_siginfo_from_siginfo' may result in an unaligned pointer access [-Walign-mismatch]
compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,
^
1 warning generated.
The problem is that:
- The flagged code is casting to "struct compat_x32_siginfo" pointer
directly instead of to a pointer to the compat_x32_siginfo_t
typedef. The called function is declared with a
compat_x32_siginfo_t typedef pointer parameter.
- Only the typedef has the __aligned__ attribute.
Fix this by moving the attribute to the struct, so both struct and
typedef have the same alignment.
The next patch removes the typedefs.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* nat/amd64-linux-siginfo.c (compat_x32_siginfo_t): Move
__attribute__ __aligned__ from the typedef to the struct.
---
gdb/nat/amd64-linux-siginfo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index e2d2db6e112..9ff9361487a 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -206,7 +206,7 @@ typedef struct compat_siginfo
/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
-typedef struct compat_x32_siginfo
+typedef struct __attribute__ ((__aligned__ (8))) compat_x32_siginfo
{
int si_signo;
int si_errno;
@@ -263,7 +263,7 @@ typedef struct compat_x32_siginfo
int _fd;
} _sigpoll;
} _sifields;
-} compat_x32_siginfo_t __attribute__ ((__aligned__ (8)));
+} compat_x32_siginfo_t;
/* To simplify usage of siginfo fields. */
--
2.26.2
next prev parent reply other threads:[~2021-06-05 0:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-05 0:14 [PATCH 0/2] Fix alignment issue flagged by Clang in nat/amd64-linux-siginfo.c Pedro Alves
2021-06-05 0:14 ` Pedro Alves [this message]
2021-06-05 21:20 ` [PATCH 1/2] nat/amd64-linux-siginfo.c: Move align attribute from typedef to struct John Baldwin
2021-06-07 22:20 ` Pedro Alves
2021-06-07 22:42 ` John Baldwin
2021-06-05 0:14 ` [PATCH 2/2] nat/amd64-linux-siginfo.c: Remove typedefs Pedro Alves
2021-06-06 14:41 ` [PATCH 0/2] Fix alignment issue flagged by Clang in nat/amd64-linux-siginfo.c Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210605001427.3597687-2-pedro@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).