* [Buildroot] [PATCH v2 2/2] package/gdb: gdb-11.1 compile for uclibc (ADDR_NO_RANDOMIZE related)
2021-11-09 17:56 [Buildroot] [PATCH v2 1/2] package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related) Peter Seiderer
@ 2021-11-09 17:56 ` Peter Seiderer
2021-11-16 20:01 ` [Buildroot] [PATCH v2 1/2] package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related) Arnout Vandecappelle
1 sibling, 0 replies; 3+ messages in thread
From: Peter Seiderer @ 2021-11-09 17:56 UTC (permalink / raw)
To: buildroot
- add upstream patch ([1]) to fix the ADDR_NO_RANDOMIZE compile failure
introduced with commit [2] (see [3] for details)
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;h=0b03c6f03d51f441d999e0cee92f81af543d9373
[2] https://sourceware.org/git/?p=binutils-gdb.git;h=4655f8509fd44e6efabefa373650d9982ff37fd6
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=28555
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
---
Changes v1 -> v2:
- update patch from revert to new upstream solution
---
.../gdb/11.1/0008-Fix-build-on-rhES5.patch | 194 ++++++++++++++++++
1 file changed, 194 insertions(+)
create mode 100644 package/gdb/11.1/0008-Fix-build-on-rhES5.patch
diff --git a/package/gdb/11.1/0008-Fix-build-on-rhES5.patch b/package/gdb/11.1/0008-Fix-build-on-rhES5.patch
new file mode 100644
index 0000000000..2d4e30ffe1
--- /dev/null
+++ b/package/gdb/11.1/0008-Fix-build-on-rhES5.patch
@@ -0,0 +1,194 @@
+From db3aaeda1d6b156100d969edb8c0e674bca6b201 Mon Sep 17 00:00:00 2001
+From: Tom Tromey <tromey@adacore.com>
+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 <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.
+
+[Upstream: https://sourceware.org/git?p=binutils-gdb.git;h=0b03c6f03d51f441d999e0cee92f81af543d9373]
+Signed-off-by: Peter Seiderer <ps.report@gmx.net>
+---
+ 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 2c30504..776bee9 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 5d89635..27e3194 100755
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -13838,6 +13838,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 <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 9ce345b..27999fd 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 cf06c56..c9258b3 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 b227167..d399d71 100755
+--- a/gdbserver/configure
++++ b/gdbserver/configure
+@@ -7131,6 +7131,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 <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 901c454..56a355e 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 <sys/personality.h>])
++
+ AC_CHECK_DECLS([strstr])
+
+ # ----------------------- #
+diff --git a/gdbsupport/config.in b/gdbsupport/config.in
+index f46e261..6945a62 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 a9dd02c..243a03f 100755
+--- a/gdbsupport/configure
++++ b/gdbsupport/configure
+@@ -8144,6 +8144,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 <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.33.1
+
--
2.33.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH v2 1/2] package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related)
2021-11-09 17:56 [Buildroot] [PATCH v2 1/2] package/gdb: fix gdb-11.1 compile for uclibc < v1.0.35 (getrandom related) Peter Seiderer
2021-11-09 17:56 ` [Buildroot] [PATCH v2 2/2] package/gdb: gdb-11.1 compile for uclibc (ADDR_NO_RANDOMIZE related) Peter Seiderer
@ 2021-11-16 20:01 ` Arnout Vandecappelle
1 sibling, 0 replies; 3+ messages in thread
From: Arnout Vandecappelle @ 2021-11-16 20:01 UTC (permalink / raw)
To: Peter Seiderer, buildroot
On 09/11/2021 18:56, Peter Seiderer wrote:
> - 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)
> | ^~~~~~
>
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Both applied to master, thanks.
Regards,
Arnout
> ---
> ...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
>
> diff --git a/package/gdb/11.1/0007-Fix-getrandom-compile-for-uclibc-v1.0.35.patch b/package/gdb/11.1/0007-Fix-getrandom-compile-for-uclibc-v1.0.35.patch
> new file mode 100644
> index 0000000000..b02d63fc0c
> --- /dev/null
> +++ b/package/gdb/11.1/0007-Fix-getrandom-compile-for-uclibc-v1.0.35.patch
> @@ -0,0 +1,39 @@
> +From 879008ef9a48aa1363671f5c1736b49f30c5a379 Mon Sep 17 00:00:00 2001
> +From: Peter Seiderer <ps.report@gmx.net>
> +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 <ps.report@gmx.net>
> +---
> + 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
> +
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread