0014-nopie.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From db28b1e0f3b06325026ec5b5e7cdca4e9992e05c Mon Sep 17 00:00:00 2001
  2. From: Szabolcs Nagy <nsz@port70.net>
  3. Date: Sat, 7 Nov 2015 02:08:05 +0000
  4. Subject: [PATCH] nopie
  5. ---
  6. gcc/configure | 27 +++++++++++++++++++++++++++
  7. gcc/configure.ac | 13 +++++++++++++
  8. 2 files changed, 40 insertions(+)
  9. diff --git a/gcc/configure b/gcc/configure
  10. index e9060112384..2f6b3265a6c 100755
  11. --- a/gcc/configure
  12. +++ b/gcc/configure
  13. @@ -32497,6 +32497,33 @@ fi
  14. $as_echo "$gcc_cv_no_pie" >&6; }
  15. if test "$gcc_cv_no_pie" = "yes"; then
  16. NO_PIE_FLAG="-no-pie"
  17. +else
  18. + # Check if -nopie works.
  19. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5
  20. +$as_echo_n "checking for -nopie option... " >&6; }
  21. +if test "${gcc_cv_nopie+set}" = set; then :
  22. + $as_echo_n "(cached) " >&6
  23. +else
  24. + saved_LDFLAGS="$LDFLAGS"
  25. + LDFLAGS="$LDFLAGS -nopie"
  26. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  27. +/* end confdefs.h. */
  28. +int main(void) {return 0;}
  29. +_ACEOF
  30. +if ac_fn_cxx_try_link "$LINENO"; then :
  31. + gcc_cv_nopie=yes
  32. +else
  33. + gcc_cv_nopie=no
  34. +fi
  35. +rm -f core conftest.err conftest.$ac_objext \
  36. + conftest$ac_exeext conftest.$ac_ext
  37. + LDFLAGS="$saved_LDFLAGS"
  38. +fi
  39. +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5
  40. +$as_echo "$gcc_cv_nopie" >&6; }
  41. + if test "$gcc_cv_nopie" = "yes"; then
  42. + NO_PIE_FLAG="-nopie"
  43. + fi
  44. fi
  45. diff --git a/gcc/configure.ac b/gcc/configure.ac
  46. index 75a7048045c..e683d3a7a5f 100644
  47. --- a/gcc/configure.ac
  48. +++ b/gcc/configure.ac
  49. @@ -7681,6 +7681,19 @@ AC_CACHE_CHECK([for -no-pie option],
  50. LDFLAGS="$saved_LDFLAGS"])
  51. if test "$gcc_cv_no_pie" = "yes"; then
  52. NO_PIE_FLAG="-no-pie"
  53. +else
  54. + # Check if -nopie works.
  55. + AC_CACHE_CHECK([for -nopie option],
  56. + [gcc_cv_nopie],
  57. + [saved_LDFLAGS="$LDFLAGS"
  58. + LDFLAGS="$LDFLAGS -nopie"
  59. + AC_LINK_IFELSE([int main(void) {return 0;}],
  60. + [gcc_cv_nopie=yes],
  61. + [gcc_cv_nopie=no])
  62. + LDFLAGS="$saved_LDFLAGS"])
  63. + if test "$gcc_cv_nopie" = "yes"; then
  64. + NO_PIE_FLAG="-nopie"
  65. + fi
  66. fi
  67. AC_SUBST([NO_PIE_FLAG])