[gdb/build] Fix x86_64 x32 build
A build error on x86_64 with x32 abi was reported here (
https://sourceware.org/pipermail/gdb/2021-November/049787.html ):
...
gdb/nat/amd64-linux-siginfo.c:280:42: error: \
'struct compat_x32_siginfo_t::<unnamed union>::<unnamed>' has no member \
named 'si_addr_bnd'
280 | #define cpt_si_lower _sifields._sigfault.si_addr_bnd._lower
| ^~~~~~~~~~~
gdb/nat/amd64-linux-siginfo.c:337:38: note: in expansion of macro 'cpt_si_lower'
337 | to->cpt_si_lower = from_ptrace.cpt_si_lower;
| ^~~~~~~~~~~~
...
The problem is that code added in commit d3d7d1ba3bb "[gdb/tdep] Handle
si_addr_bnd in compat_siginfo_from_siginfo" doesn't compile on an x86_64 x32
setup, because compat_x32_siginfo_t doesn't have the si_addr_bnd fields.
Fix this conservatively by disabling the code for x32.
Tested on x86_64-linux.
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 342840e..fc52b5b 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -330,6 +330,9 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, const siginfo_t *from)
to->cpt_si_pid = from_ptrace.cpt_si_pid;
to->cpt_si_uid = from_ptrace.cpt_si_uid;
}
+#ifndef __ILP32__
+ /* The struct compat_x32_siginfo_t doesn't contain
+ cpt_si_lower/cpt_si_upper. */
else if (to->si_code == SEGV_BNDERR
&& to->si_signo == SIGSEGV)
{
@@ -337,6 +340,7 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, const siginfo_t *from)
to->cpt_si_lower = from_ptrace.cpt_si_lower;
to->cpt_si_upper = from_ptrace.cpt_si_upper;
}
+#endif
else if (to->si_code < 0)
{
to->cpt_si_pid = from_ptrace.cpt_si_pid;