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
7 gcc/configure | 27 +++++++++++++++++++++++++++
8 gcc/configure.ac | 13 +++++++++++++
9 2 files changed, 40 insertions(+)
11 diff --git a/gcc/configure b/gcc/configure
12 index e9060112384..2f6b3265a6c 100755
15 @@ -32497,6 +32497,33 @@ fi
16 $as_echo "$gcc_cv_no_pie" >&6; }
17 if test "$gcc_cv_no_pie" = "yes"; then
20 + # Check if -nopie works.
21 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5
22 +$as_echo_n "checking for -nopie option... " >&6; }
23 +if test "${gcc_cv_nopie+set}" = set; then :
24 + $as_echo_n "(cached) " >&6
26 + saved_LDFLAGS="$LDFLAGS"
27 + LDFLAGS="$LDFLAGS -nopie"
28 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
29 +/* end confdefs.h. */
30 +int main(void) {return 0;}
32 +if ac_fn_cxx_try_link "$LINENO"; then :
37 +rm -f core conftest.err conftest.$ac_objext \
38 + conftest$ac_exeext conftest.$ac_ext
39 + LDFLAGS="$saved_LDFLAGS"
41 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5
42 +$as_echo "$gcc_cv_nopie" >&6; }
43 + if test "$gcc_cv_nopie" = "yes"; then
44 + NO_PIE_FLAG="-nopie"
49 diff --git a/gcc/configure.ac b/gcc/configure.ac
50 index 75a7048045c..e683d3a7a5f 100644
51 --- a/gcc/configure.ac
52 +++ b/gcc/configure.ac
53 @@ -7681,6 +7681,19 @@ AC_CACHE_CHECK([for -no-pie option],
54 LDFLAGS="$saved_LDFLAGS"])
55 if test "$gcc_cv_no_pie" = "yes"; then
58 + # Check if -nopie works.
59 + AC_CACHE_CHECK([for -nopie option],
61 + [saved_LDFLAGS="$LDFLAGS"
62 + LDFLAGS="$LDFLAGS -nopie"
63 + AC_LINK_IFELSE([int main(void) {return 0;}],
66 + LDFLAGS="$saved_LDFLAGS"])
67 + if test "$gcc_cv_nopie" = "yes"; then
68 + NO_PIE_FLAG="-nopie"
71 AC_SUBST([NO_PIE_FLAG])