[binutils-gdb] nat/amd64-linux-siginfo.c: Move align attribute from typedef to struct
Pedro Alves
palves@sourceware.org
Mon Jun 7 22:24:08 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d8ca8e9facb184d67ce1aca9196ed8446e7e2a09
commit d8ca8e9facb184d67ce1aca9196ed8446e7e2a09
Author: Pedro Alves <pedro@palves.net>
Date: Fri Jun 4 21:44:36 2021 +0100
nat/amd64-linux-siginfo.c: Move align attribute from typedef to struct
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/nat/amd64-linux-siginfo.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aa8bcb9615a..4859531e1a5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-07 Pedro Alves <pedro@palves.net>
+
+ * nat/amd64-linux-siginfo.c (compat_x32_siginfo_t): Move
+ __attribute__ __aligned__ from the typedef to the struct.
+
2021-06-07 Andrew Burgess <andrew.burgess@embecosm.com>
PR gdb/27847
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. */
More information about the Gdb-cvs
mailing list