public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix build on rhES5
@ 2021-11-08 21:28 Tom Tromey
  2021-11-08 21:57 ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2021-11-08 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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 <linux/personality.h>, not
<sys/personality.h>.

However, <linux/personality.h> does not declare the 'personality'
function, and <sys/personality.h> and <linux/personality.h> 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               | 13 +++++++++++++
 gdb/nat/linux-personality.c |  4 ++++
 gdbserver/config.in         |  4 ++++
 gdbserver/configure         | 13 +++++++++++++
 gdbsupport/common.m4        |  2 ++
 gdbsupport/config.in        |  4 ++++
 gdbsupport/configure        | 13 +++++++++++++
 8 files changed, 57 insertions(+)

diff --git a/gdb/config.in b/gdb/config.in
index c61f7a91352..773a0ba91ef 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 d5c1883c25b..ec15f84eae4 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -13863,6 +13863,19 @@ fi
 done
 
 
+  ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
+"
+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 9ce345bc6de..27999fd19df 100644
--- a/gdb/nat/linux-personality.c
+++ b/gdb/nat/linux-personality.c
@@ -22,6 +22,10 @@
 
 #include <sys/personality.h>
 
+# 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 5fb5b7a35f7..39ddc7c0edb 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 0e32d198ad9..044037b28cd 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -7139,6 +7139,19 @@ fi
 done
 
 
+  ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
+"
+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 07c7b2a9bec..2cd9677403f 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -55,6 +55,8 @@ AC_DEFUN([GDB_AC_COMMON], [
 		  ptrace64 sbrk setns sigaltstack sigprocmask \
 		  setpgid setpgrp getrusage getauxval sigtimedwait])
 
+  AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
+
   AC_CHECK_DECLS([strstr])
 
   # ----------------------- #
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index f6b0159bd62..a7ae23b4984 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 d22f225ef7e..16489ea772f 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -8152,6 +8152,19 @@ fi
 done
 
 
+  ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
+"
+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.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix build on rhES5
  2021-11-08 21:28 [PATCH] Fix build on rhES5 Tom Tromey
@ 2021-11-08 21:57 ` Simon Marchi
  2021-11-09 15:20   ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2021-11-08 21:57 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2021-11-08 4:28 p.m., Tom Tromey via Gdb-patches wrote:
> 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 <linux/personality.h>, not
> <sys/personality.h>.
>
> However, <linux/personality.h> does not declare the 'personality'
> function, and <sys/personality.h> and <linux/personality.h> 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.

LGTM.

Can you just add somewhere (in linux-personality.c or common.m4) a
mention that to our knowledge, this it for RHEL5 and uclibc-ng < 1.0.39?
This way when someone sees this in 10 years or so, they'll probably be
know it's ok to remove it.

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix build on rhES5
  2021-11-08 21:57 ` Simon Marchi
@ 2021-11-09 15:20   ` Tom Tromey
  2021-11-09 21:20     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2021-11-09 15:20 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

Simon> Can you just add somewhere (in linux-personality.c or common.m4) a
Simon> mention that to our knowledge, this it for RHEL5 and uclibc-ng < 1.0.39?
Simon> This way when someone sees this in 10 years or so, they'll probably be
Simon> know it's ok to remove it.

Sure, I added this to common.m4:

  # 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.

I'm going to check this in now.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix build on rhES5
  2021-11-09 15:20   ` Tom Tromey
@ 2021-11-09 21:20     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2021-11-09 21:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Simon Marchi, gdb-patches

Tom> I'm going to check this in now.

This was reported to actually fix the PR, so I'm going to backport it to
the gdb-11 branch and then close the PR.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-09 21:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 21:28 [PATCH] Fix build on rhES5 Tom Tromey
2021-11-08 21:57 ` Simon Marchi
2021-11-09 15:20   ` Tom Tromey
2021-11-09 21:20     ` Tom Tromey

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).