Skip to contentSkip to conversation

package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related)

PATCH Superseded Peter Seiderer 1 participant 3 messages Nov 6, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related)

- fix getrandom compile for uclibc < v1.0.35, add missing stddef.h include (fixed in uclibc since v1.0.35, see [1])

Fixes:

.../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:35: error: unknown type name ‘size_t’
27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
| ^~~~~~

---
 ...getrandom-compile-for-uclibc-v1.0.35.patch | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 package/gdb/11.1/0007-Fix-getrandom-compile-for-uclibc-v1.0.35.patch
package/gdb/11.1/0007-Fix-getrandom-compile-for-uclibc-v1.0.35.patch new file +39 -0
new file mode 100644
index 0000000000..b02d63fc0c
@@ -0,0 +1,39 @@
+From 879008ef9a48aa1363671f5c1736b49f30c5a379 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Sat, 6 Nov 2021 10:06:25 +0100
+Subject: [PATCH] Fix getrandom compile for uclibc < v1.0.35
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+- fix getrandom compile for uclibc < v1.0.35, add missing stddef.h
+  include (fixed in uclibc since v1.0.35, see [1])
+
+Fixes:
+
+  .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:35: error: unknown type name ‘size_t’
+     27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
+        |                                   ^~~~~~
+
+[1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=00972c02c2b6e0a95d5def4a71bdfb188e091782t
+
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ gnulib/import/getrandom.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gnulib/import/getrandom.c b/gnulib/import/getrandom.c
+index 41212fb..0ad3f96 100644
+--- a/gnulib/import/getrandom.c
++++ b/gnulib/import/getrandom.c
+@@ -19,6 +19,7 @@
+ 
+ #include <config.h>
+ 
++#include <stddef.h>
+ #include <sys/random.h>
+ 
+ #include <errno.h>
+-- 
+2.33.1
+
Signature · 6 lines
2.33.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

RFC 2/2 package/gdb: gdb-11.1 compile for uclibc (ADDR_NO_RANDOMIZE related)

- add patch reverting upstream patch ([1]) which removed the configure time check

Fixes:

../../gdbserver/../gdb/nat/linux-personality.c: In constructor ‘maybe_disable_address_space_randomization::maybe_disable_address_space_randomization(int)’:
../../gdbserver/../gdb/nat/linux-personality.c:36:48: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope

     36 |       if (errno == 0 && !(m_personality_orig & ADDR_NO_RANDOMIZE))
        |                                                ^~~~~~~~~~~~~~~~~
  ../../gdbserver/../gdb/nat/linux-personality.c:42:37: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
     42 |     && !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
        |                                     ^~~~~~~~~~~~~~~~~

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4655f8509fd44e6efabefa373650d9982ff37fd6

---
Note:

- a quick fix, the proper fix would be (as mentioned in the upstream commit changelog:

[...]
If for some odd reason, some remotely modern system still needs a configure check, then we can revert this commit but drop the AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE cross-compile fallback.
[...]

---
 ...-personality-syscall-at-configure-ti.patch | 371 ++++++++++++++++++
 1 file changed, 371 insertions(+)
 create mode 100644 package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch
package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch new file +371 -0
new file mode 100644
index 0000000000..d674287b57
@@ -0,0 +1,371 @@
+From c26b279aa4c7dc8a0cd9e30d2e43e6b95cefb5a0 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Sat, 6 Nov 2021 12:54:42 +0100
+Subject: [PATCH] Revert "Don't run personality syscall at configure time;
+ don't check it at all"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit 4655f8509fd44e6efabefa373650d9982ff37fd6 ([1]).
+
+Fixes (with uclibc toolchain):
+
+  ../../gdbserver/../gdb/nat/linux-personality.c: In constructor ‘maybe_disable_address_space_randomization::maybe_disable_address_space_randomization(int)’:
+  ../../gdbserver/../gdb/nat/linux-personality.c:36:48: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
+     36 |       if (errno == 0 && !(m_personality_orig & ADDR_NO_RANDOMIZE))
+        |                                                ^~~~~~~~~~~~~~~~~
+  ../../gdbserver/../gdb/nat/linux-personality.c:42:37: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
+     42 |     && !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
+        |                                     ^~~~~~~~~~~~~~~~~
+
+[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4655f8509fd44e6efabefa373650d9982ff37fd6
+
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ gdb/config.in               |  7 ++++
+ gdb/configure               | 74 +++++++++++++++++++++++++++++++++++++
+ gdb/linux-nat.c             |  4 ++
+ gdb/nat/linux-personality.c | 12 +++++-
+ gdbserver/config.in         |  7 ++++
+ gdbserver/configure         | 74 +++++++++++++++++++++++++++++++++++++
+ gdbserver/linux-low.cc      |  4 ++
+ gdbsupport/common.m4        | 23 ++++++++++++
+ 8 files changed, 204 insertions(+), 1 deletion(-)
+
+diff --git a/gdb/config.in b/gdb/config.in
+index 2c30504..eee0eaf 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
+@@ -297,6 +301,9 @@
+ /* Define to 1 if you have the <nlist.h> header file. */
+ #undef HAVE_NLIST_H
+ 
++/* Define if you support the personality syscall. */
++#undef HAVE_PERSONALITY
++
+ /* Define to 1 if you have the `pipe' function. */
+ #undef HAVE_PIPE
+ 
+diff --git a/gdb/configure b/gdb/configure
+index 5d89635..599521a 100755
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -13838,6 +13838,80 @@ 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
++
++
++  if test "$cross_compiling" = yes; then :
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext conftest.$ac_ext
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++  if $have_personality
++  then
++
++$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
++
++  fi
++
+   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/linux-nat.c b/gdb/linux-nat.c
+index f206b87..1a6bcb5 100644
+--- a/gdb/linux-nat.c
++++ b/gdb/linux-nat.c
+@@ -4195,7 +4195,11 @@ linux_nat_target::supports_multi_process ()
+ bool
+ linux_nat_target::supports_disable_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
+   return true;
++#else
++  return false;
++#endif
+ }
+ 
+ /* SIGCHLD handler that serves two purposes: In non-stop/async mode,
+diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
+index 9ce345b..87d1921 100644
+--- a/gdb/nat/linux-personality.c
++++ b/gdb/nat/linux-personality.c
+@@ -20,7 +20,12 @@
+ #include "gdbsupport/common-defs.h"
+ #include "nat/linux-personality.h"
+ 
+-#include <sys/personality.h>
++#ifdef HAVE_PERSONALITY
++# include <sys/personality.h>
++# if !HAVE_DECL_ADDR_NO_RANDOMIZE
++#  define ADDR_NO_RANDOMIZE 0x0040000
++# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
++#endif /* HAVE_PERSONALITY */
+ 
+ /* See comment on nat/linux-personality.h.  */
+ 
+@@ -29,6 +34,7 @@ maybe_disable_address_space_randomization (int disable_randomization)
+   : m_personality_set (false),
+     m_personality_orig (0)
+ {
++#ifdef HAVE_PERSONALITY
+   if (disable_randomization)
+     {
+       errno = 0;
+@@ -43,11 +49,14 @@ maybe_disable_address_space_randomization (int disable_randomization)
+ 	warning (_("Error disabling address space randomization: %s"),
+ 		 safe_strerror (errno));
+     }
++#endif /* HAVE_PERSONALITY */
+ }
+ 
+ maybe_disable_address_space_randomization::
+ ~maybe_disable_address_space_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
++
+   if (m_personality_set)
+     {
+       errno = 0;
+@@ -56,4 +65,5 @@ maybe_disable_address_space_randomization::
+ 	warning (_("Error restoring address space randomization: %s"),
+ 		 safe_strerror (errno));
+     }
++#endif /* HAVE_PERSONALITY */
+ }
+diff --git a/gdbserver/config.in b/gdbserver/config.in
+index cf06c56..b55ddc1 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
+@@ -178,6 +182,9 @@
+ /* Define to 1 if you have the <netinet/tcp.h> header file. */
+ #undef HAVE_NETINET_TCP_H
+ 
++/* Define if you support the personality syscall. */
++#undef HAVE_PERSONALITY
++
+ /* Define to 1 if you have the `pipe' function. */
+ #undef HAVE_PIPE
+ 
+diff --git a/gdbserver/configure b/gdbserver/configure
+index b227167..c566ab7 100755
+--- a/gdbserver/configure
++++ b/gdbserver/configure
+@@ -7131,6 +7131,80 @@ 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
++
++
++  if test "$cross_compiling" = yes; then :
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext conftest.$ac_ext
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++  if $have_personality
++  then
++
++$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
++
++  fi
++
+   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/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
+index 5c6191d..ca0c513 100644
+--- a/gdbserver/linux-low.cc
++++ b/gdbserver/linux-low.cc
+@@ -6224,7 +6224,11 @@ linux_process_target::core_of_thread (ptid_t ptid)
+ bool
+ linux_process_target::supports_disable_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
+   return true;
++#else
++  return false;
++#endif
+ }
+ 
+ bool
+diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
+index 901c454..be925b4 100644
+--- a/gdbsupport/common.m4
++++ b/gdbsupport/common.m4
+@@ -55,6 +55,29 @@ AC_DEFUN([GDB_AC_COMMON], [
+ 		  ptrace64 sbrk setns sigaltstack sigprocmask \
+ 		  setpgid setpgrp getrusage getauxval sigtimedwait])
+ 
++  dnl Check if we can disable the virtual address space randomization.
++  dnl The functionality of setarch -R.
++  AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
++  define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1])])
++  AC_RUN_IFELSE([PERSONALITY_TEST],
++		[have_personality=true],
++		[have_personality=false],
++		[AC_LINK_IFELSE([PERSONALITY_TEST],
++				[have_personality=true],
++				[have_personality=false])])
++  if $have_personality
++  then
++      AC_DEFINE([HAVE_PERSONALITY], 1,
++		[Define if you support the personality syscall.])
++  fi
++
+   AC_CHECK_DECLS([strstr])
+ 
+   # ----------------------- #
+-- 
+2.33.1
+
Signature · 6 lines
2.33.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [RFC v1 2/2] package/gdb: gdb-11.1 compile for uclibc (ADDR_NO_RANDOMIZE related)

Quoted 22 lines · Peter Seiderer

- add patch reverting upstream patch ([1]) which removed the configure time check

Fixes:

../../gdbserver/../gdb/nat/linux-personality.c: In constructor ‘maybe_disable_address_space_randomization::maybe_disable_address_space_randomization(int)’:
../../gdbserver/../gdb/nat/linux-personality.c:36:48: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope

     36 |       if (errno == 0 && !(m_personality_orig & ADDR_NO_RANDOMIZE))
        |                                                ^~~~~~~~~~~~~~~~~
  ../../gdbserver/../gdb/nat/linux-personality.c:42:37: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
     42 |     && !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
        |                                     ^~~~~~~~~~~~~~~~~

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4655f8509fd44e6efabefa373650d9982ff37fd6

---
Note:

- a quick fix, the proper fix would be (as mentioned in the upstream commit changelog:

Quoted 6 lines

[...]
If for some odd reason, some remotely modern system still needs a configure check, then we can revert this commit but drop the AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE cross-compile fallback.
[...]

And reported upstream:

	https://sourceware.org/bugzilla/show_bug.cgi?id=28555

Regards,
Peter

Quoted 372 lines
---
 ...-personality-syscall-at-configure-ti.patch | 371 ++++++++++++++++++
 1 file changed, 371 insertions(+)
 create mode 100644 package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch
package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch new file +361 -0
new file mode 100644
index 0000000000..d674287b57
@@ -0,0 +1,371 @@
+From c26b279aa4c7dc8a0cd9e30d2e43e6b95cefb5a0 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Sat, 6 Nov 2021 12:54:42 +0100
+Subject: [PATCH] Revert "Don't run personality syscall at configure time;
+ don't check it at all"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit 4655f8509fd44e6efabefa373650d9982ff37fd6 ([1]).
+
+Fixes (with uclibc toolchain):
+
+  ../../gdbserver/../gdb/nat/linux-personality.c: In constructor ‘maybe_disable_address_space_randomization::maybe_disable_address_space_randomization(int)’:
+  ../../gdbserver/../gdb/nat/linux-personality.c:36:48: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
+     36 |       if (errno == 0 && !(m_personality_orig & ADDR_NO_RANDOMIZE))
+        |                                                ^~~~~~~~~~~~~~~~~
+  ../../gdbserver/../gdb/nat/linux-personality.c:42:37: error: ‘ADDR_NO_RANDOMIZE’ was not declared in this scope
+     42 |     && !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
+        |                                     ^~~~~~~~~~~~~~~~~
+
+[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4655f8509fd44e6efabefa373650d9982ff37fd6
+
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ gdb/config.in               |  7 ++++
+ gdb/configure               | 74 +++++++++++++++++++++++++++++++++++++
+ gdb/linux-nat.c             |  4 ++
+ gdb/nat/linux-personality.c | 12 +++++-
+ gdbserver/config.in         |  7 ++++
+ gdbserver/configure         | 74 +++++++++++++++++++++++++++++++++++++
+ gdbserver/linux-low.cc      |  4 ++
+ gdbsupport/common.m4        | 23 ++++++++++++
+ 8 files changed, 204 insertions(+), 1 deletion(-)
+
+diff --git a/gdb/config.in b/gdb/config.in
+index 2c30504..eee0eaf 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
+@@ -297,6 +301,9 @@
+ /* Define to 1 if you have the <nlist.h> header file. */
+ #undef HAVE_NLIST_H
+ 
++/* Define if you support the personality syscall. */
++#undef HAVE_PERSONALITY
++
+ /* Define to 1 if you have the `pipe' function. */
+ #undef HAVE_PIPE
+ 
+diff --git a/gdb/configure b/gdb/configure
+index 5d89635..599521a 100755
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -13838,6 +13838,80 @@ 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
++
++
++  if test "$cross_compiling" = yes; then :
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext conftest.$ac_ext
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++  if $have_personality
++  then
++
++$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
++
++  fi
++
+   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/linux-nat.c b/gdb/linux-nat.c
+index f206b87..1a6bcb5 100644
+--- a/gdb/linux-nat.c
++++ b/gdb/linux-nat.c
+@@ -4195,7 +4195,11 @@ linux_nat_target::supports_multi_process ()
+ bool
+ linux_nat_target::supports_disable_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
+   return true;
++#else
++  return false;
++#endif
+ }
+ 
+ /* SIGCHLD handler that serves two purposes: In non-stop/async mode,
+diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
+index 9ce345b..87d1921 100644
+--- a/gdb/nat/linux-personality.c
++++ b/gdb/nat/linux-personality.c
+@@ -20,7 +20,12 @@
+ #include "gdbsupport/common-defs.h"
+ #include "nat/linux-personality.h"
+ 
+-#include <sys/personality.h>
++#ifdef HAVE_PERSONALITY
++# include <sys/personality.h>
++# if !HAVE_DECL_ADDR_NO_RANDOMIZE
++#  define ADDR_NO_RANDOMIZE 0x0040000
++# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
++#endif /* HAVE_PERSONALITY */
+ 
+ /* See comment on nat/linux-personality.h.  */
+ 
+@@ -29,6 +34,7 @@ maybe_disable_address_space_randomization (int disable_randomization)
+   : m_personality_set (false),
+     m_personality_orig (0)
+ {
++#ifdef HAVE_PERSONALITY
+   if (disable_randomization)
+     {
+       errno = 0;
+@@ -43,11 +49,14 @@ maybe_disable_address_space_randomization (int disable_randomization)
+ 	warning (_("Error disabling address space randomization: %s"),
+ 		 safe_strerror (errno));
+     }
++#endif /* HAVE_PERSONALITY */
+ }
+ 
+ maybe_disable_address_space_randomization::
+ ~maybe_disable_address_space_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
++
+   if (m_personality_set)
+     {
+       errno = 0;
+@@ -56,4 +65,5 @@ maybe_disable_address_space_randomization::
+ 	warning (_("Error restoring address space randomization: %s"),
+ 		 safe_strerror (errno));
+     }
++#endif /* HAVE_PERSONALITY */
+ }
+diff --git a/gdbserver/config.in b/gdbserver/config.in
+index cf06c56..b55ddc1 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
+@@ -178,6 +182,9 @@
+ /* Define to 1 if you have the <netinet/tcp.h> header file. */
+ #undef HAVE_NETINET_TCP_H
+ 
++/* Define if you support the personality syscall. */
++#undef HAVE_PERSONALITY
++
+ /* Define to 1 if you have the `pipe' function. */
+ #undef HAVE_PIPE
+ 
+diff --git a/gdbserver/configure b/gdbserver/configure
+index b227167..c566ab7 100755
+--- a/gdbserver/configure
++++ b/gdbserver/configure
+@@ -7131,6 +7131,80 @@ 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
++
++
++  if test "$cross_compiling" = yes; then :
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core conftest.err conftest.$ac_objext \
++    conftest$ac_exeext conftest.$ac_ext
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++#include <sys/personality.h>
++int
++main ()
++{
++
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++  have_personality=true
++else
++  have_personality=false
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++  if $have_personality
++  then
++
++$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
++
++  fi
++
+   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/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
+index 5c6191d..ca0c513 100644
+--- a/gdbserver/linux-low.cc
++++ b/gdbserver/linux-low.cc
+@@ -6224,7 +6224,11 @@ linux_process_target::core_of_thread (ptid_t ptid)
+ bool
+ linux_process_target::supports_disable_randomization ()
+ {
++#ifdef HAVE_PERSONALITY
+   return true;
++#else
++  return false;
++#endif
+ }
+ 
+ bool
+diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
+index 901c454..be925b4 100644
+--- a/gdbsupport/common.m4
++++ b/gdbsupport/common.m4
+@@ -55,6 +55,29 @@ AC_DEFUN([GDB_AC_COMMON], [
+ 		  ptrace64 sbrk setns sigaltstack sigprocmask \
+ 		  setpgid setpgrp getrusage getauxval sigtimedwait])
+ 
++  dnl Check if we can disable the virtual address space randomization.
++  dnl The functionality of setarch -R.
++  AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
++  define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
++  #      if !HAVE_DECL_ADDR_NO_RANDOMIZE
++  #       define ADDR_NO_RANDOMIZE 0x0040000
++  #      endif
++	 /* Test the flag could be set and stays set.  */
++	 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
++	 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
++	     return 1])])
++  AC_RUN_IFELSE([PERSONALITY_TEST],
++		[have_personality=true],
++		[have_personality=false],
++		[AC_LINK_IFELSE([PERSONALITY_TEST],
++				[have_personality=true],
++				[have_personality=false])])
++  if $have_personality
++  then

package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch line 371

Quoted 10 lines
package/gdb/11.1/0008-Revert-Don-t-run-personality-syscall-at-configure-ti.patch new file +10 -0
++      AC_DEFINE([HAVE_PERSONALITY], 1,
++		[Define if you support the personality syscall.])
++  fi
++
+   AC_CHECK_DECLS([strstr])
+ 
+   # ----------------------- #
+-- 
+2.33.1
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot