0008-Fix-build-on-rhES5.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. From db3aaeda1d6b156100d969edb8c0e674bca6b201 Mon Sep 17 00:00:00 2001
  2. From: Tom Tromey <tromey@adacore.com>
  3. Date: Wed, 12 May 2021 12:39:22 -0600
  4. Subject: [PATCH] Fix build on rhES5
  5. The rhES5 build failed due to an upstream import a while back. The
  6. bug here is that, while the 'personality' function exists,
  7. ADDR_NO_RANDOMIZE is only defined in <linux/personality.h>, not
  8. <sys/personality.h>.
  9. However, <linux/personality.h> does not declare the 'personality'
  10. function, and <sys/personality.h> and <linux/personality.h> cannot
  11. both be included.
  12. This patch restores one of the removed configure checks and updates
  13. the code to check it.
  14. We had this as a local patch at AdaCore, because it seemed like there
  15. was no interest upstream. However, now it turns out that this fixes
  16. PR build/28555, so I'm sending it now.
  17. [Upstream: https://sourceware.org/git?p=binutils-gdb.git;h=0b03c6f03d51f441d999e0cee92f81af543d9373]
  18. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
  19. ---
  20. gdb/config.in | 4 ++++
  21. gdb/configure | 16 ++++++++++++++++
  22. gdb/nat/linux-personality.c | 4 ++++
  23. gdbserver/config.in | 4 ++++
  24. gdbserver/configure | 16 ++++++++++++++++
  25. gdbsupport/common.m4 | 5 +++++
  26. gdbsupport/config.in | 4 ++++
  27. gdbsupport/configure | 16 ++++++++++++++++
  28. 8 files changed, 69 insertions(+)
  29. diff --git a/gdb/config.in b/gdb/config.in
  30. index 2c30504..776bee9 100644
  31. --- a/gdb/config.in
  32. +++ b/gdb/config.in
  33. @@ -96,6 +96,10 @@
  34. /* define if the compiler supports basic C++11 syntax */
  35. #undef HAVE_CXX11
  36. +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
  37. + you don't. */
  38. +#undef HAVE_DECL_ADDR_NO_RANDOMIZE
  39. +
  40. /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
  41. don't. */
  42. #undef HAVE_DECL_ASPRINTF
  43. diff --git a/gdb/configure b/gdb/configure
  44. index 5d89635..27e3194 100755
  45. --- a/gdb/configure
  46. +++ b/gdb/configure
  47. @@ -13838,6 +13838,22 @@ fi
  48. done
  49. + # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
  50. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
  51. + # only in linux/personality.h.
  52. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
  53. +"
  54. +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
  55. + ac_have_decl=1
  56. +else
  57. + ac_have_decl=0
  58. +fi
  59. +
  60. +cat >>confdefs.h <<_ACEOF
  61. +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
  62. +_ACEOF
  63. +
  64. +
  65. ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
  66. if test "x$ac_cv_have_decl_strstr" = xyes; then :
  67. ac_have_decl=1
  68. diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
  69. index 9ce345b..27999fd 100644
  70. --- a/gdb/nat/linux-personality.c
  71. +++ b/gdb/nat/linux-personality.c
  72. @@ -22,6 +22,10 @@
  73. #include <sys/personality.h>
  74. +# if !HAVE_DECL_ADDR_NO_RANDOMIZE
  75. +# define ADDR_NO_RANDOMIZE 0x0040000
  76. +# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
  77. +
  78. /* See comment on nat/linux-personality.h. */
  79. maybe_disable_address_space_randomization::
  80. diff --git a/gdbserver/config.in b/gdbserver/config.in
  81. index cf06c56..c9258b3 100644
  82. --- a/gdbserver/config.in
  83. +++ b/gdbserver/config.in
  84. @@ -31,6 +31,10 @@
  85. /* define if the compiler supports basic C++11 syntax */
  86. #undef HAVE_CXX11
  87. +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
  88. + you don't. */
  89. +#undef HAVE_DECL_ADDR_NO_RANDOMIZE
  90. +
  91. /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
  92. don't. */
  93. #undef HAVE_DECL_ASPRINTF
  94. diff --git a/gdbserver/configure b/gdbserver/configure
  95. index b227167..d399d71 100755
  96. --- a/gdbserver/configure
  97. +++ b/gdbserver/configure
  98. @@ -7131,6 +7131,22 @@ fi
  99. done
  100. + # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
  101. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
  102. + # only in linux/personality.h.
  103. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
  104. +"
  105. +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
  106. + ac_have_decl=1
  107. +else
  108. + ac_have_decl=0
  109. +fi
  110. +
  111. +cat >>confdefs.h <<_ACEOF
  112. +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
  113. +_ACEOF
  114. +
  115. +
  116. ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
  117. if test "x$ac_cv_have_decl_strstr" = xyes; then :
  118. ac_have_decl=1
  119. diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
  120. index 901c454..56a355e 100644
  121. --- a/gdbsupport/common.m4
  122. +++ b/gdbsupport/common.m4
  123. @@ -55,6 +55,11 @@ AC_DEFUN([GDB_AC_COMMON], [
  124. ptrace64 sbrk setns sigaltstack sigprocmask \
  125. setpgid setpgrp getrusage getauxval sigtimedwait])
  126. + # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
  127. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
  128. + # only in linux/personality.h.
  129. + AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
  130. +
  131. AC_CHECK_DECLS([strstr])
  132. # ----------------------- #
  133. diff --git a/gdbsupport/config.in b/gdbsupport/config.in
  134. index f46e261..6945a62 100644
  135. --- a/gdbsupport/config.in
  136. +++ b/gdbsupport/config.in
  137. @@ -28,6 +28,10 @@
  138. /* define if the compiler supports basic C++11 syntax */
  139. #undef HAVE_CXX11
  140. +/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
  141. + you don't. */
  142. +#undef HAVE_DECL_ADDR_NO_RANDOMIZE
  143. +
  144. /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
  145. don't. */
  146. #undef HAVE_DECL_ASPRINTF
  147. diff --git a/gdbsupport/configure b/gdbsupport/configure
  148. index a9dd02c..243a03f 100755
  149. --- a/gdbsupport/configure
  150. +++ b/gdbsupport/configure
  151. @@ -8144,6 +8144,22 @@ fi
  152. done
  153. + # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
  154. + # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
  155. + # only in linux/personality.h.
  156. + ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
  157. +"
  158. +if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
  159. + ac_have_decl=1
  160. +else
  161. + ac_have_decl=0
  162. +fi
  163. +
  164. +cat >>confdefs.h <<_ACEOF
  165. +#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
  166. +_ACEOF
  167. +
  168. +
  169. ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
  170. if test "x$ac_cv_have_decl_strstr" = xyes; then :
  171. ac_have_decl=1
  172. --
  173. 2.33.1