From df9ebc472a162306dee8ba6e02b99963c2babb7c Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 12 May 2021 12:39:22 -0600 Subject: [PATCH] Fix build on rhES5 The rhES5 build failed due to an upstream import a while back. The bug here is that, while the 'personality' function exists, ADDR_NO_RANDOMIZE is only defined in , not . However, does not declare the 'personality' function, and and cannot both be included. This patch restores one of the removed configure checks and updates the code to check it. We had this as a local patch at AdaCore, because it seemed like there was no interest upstream. However, now it turns out that this fixes PR build/28555, so I'm sending it now. --- gdb/config.in | 4 ++++ gdb/configure | 16 ++++++++++++++++ gdb/nat/linux-personality.c | 4 ++++ gdbserver/config.in | 4 ++++ gdbserver/configure | 16 ++++++++++++++++ gdbsupport/common.m4 | 5 +++++ gdbsupport/config.in | 4 ++++ gdbsupport/configure | 16 ++++++++++++++++ 8 files changed, 69 insertions(+) diff --git a/gdb/config.in b/gdb/config.in index 2c30504905..776bee91a0 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -96,6 +96,10 @@ /* define if the compiler supports basic C++11 syntax */ #undef HAVE_CXX11 +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if + you don't. */ +#undef HAVE_DECL_ADDR_NO_RANDOMIZE + /* Define to 1 if you have the declaration of `asprintf', and to 0 if you don't. */ #undef HAVE_DECL_ASPRINTF diff --git a/gdb/configure b/gdb/configure index 6d4c2b17ed..c248dca5fa 100755 --- a/gdb/configure +++ b/gdb/configure @@ -13846,6 +13846,22 @@ fi done + # This is needed for RHEL 5 and uclibc-ng < 1.0.39. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, + # only in linux/personality.h. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include +" +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl +_ACEOF + + ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default" if test "x$ac_cv_have_decl_strstr" = xyes; then : ac_have_decl=1 diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c index 9ce345bc6d..27999fd19d 100644 --- a/gdb/nat/linux-personality.c +++ b/gdb/nat/linux-personality.c @@ -22,6 +22,10 @@ #include +# if !HAVE_DECL_ADDR_NO_RANDOMIZE +# define ADDR_NO_RANDOMIZE 0x0040000 +# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */ + /* See comment on nat/linux-personality.h. */ maybe_disable_address_space_randomization:: diff --git a/gdbserver/config.in b/gdbserver/config.in index cf06c56421..c9258b326b 100644 --- a/gdbserver/config.in +++ b/gdbserver/config.in @@ -31,6 +31,10 @@ /* define if the compiler supports basic C++11 syntax */ #undef HAVE_CXX11 +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if + you don't. */ +#undef HAVE_DECL_ADDR_NO_RANDOMIZE + /* Define to 1 if you have the declaration of `asprintf', and to 0 if you don't. */ #undef HAVE_DECL_ASPRINTF diff --git a/gdbserver/configure b/gdbserver/configure index f05c1a9b97..fbde90394e 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -7139,6 +7139,22 @@ fi done + # This is needed for RHEL 5 and uclibc-ng < 1.0.39. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, + # only in linux/personality.h. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include +" +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl +_ACEOF + + ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default" if test "x$ac_cv_have_decl_strstr" = xyes; then : ac_have_decl=1 diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 index 901c454ea8..56a355e85b 100644 --- a/gdbsupport/common.m4 +++ b/gdbsupport/common.m4 @@ -55,6 +55,11 @@ AC_DEFUN([GDB_AC_COMMON], [ ptrace64 sbrk setns sigaltstack sigprocmask \ setpgid setpgrp getrusage getauxval sigtimedwait]) + # This is needed for RHEL 5 and uclibc-ng < 1.0.39. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, + # only in linux/personality.h. + AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include ]) + AC_CHECK_DECLS([strstr]) # ----------------------- # diff --git a/gdbsupport/config.in b/gdbsupport/config.in index f46e2612c7..6945a627ff 100644 --- a/gdbsupport/config.in +++ b/gdbsupport/config.in @@ -28,6 +28,10 @@ /* define if the compiler supports basic C++11 syntax */ #undef HAVE_CXX11 +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if + you don't. */ +#undef HAVE_DECL_ADDR_NO_RANDOMIZE + /* Define to 1 if you have the declaration of `asprintf', and to 0 if you don't. */ #undef HAVE_DECL_ASPRINTF diff --git a/gdbsupport/configure b/gdbsupport/configure index ae6047865a..aad746946e 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -8152,6 +8152,22 @@ fi done + # This is needed for RHEL 5 and uclibc-ng < 1.0.39. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, + # only in linux/personality.h. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include +" +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl +_ACEOF + + ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default" if test "x$ac_cv_have_decl_strstr" = xyes; then : ac_have_decl=1 -- 2.34.1