diff options
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/configure.in b/configure.in index 3dcd8bc6..4ed2e1c0 100644 --- a/configure.in +++ b/configure.in @@ -211,7 +211,17 @@ if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-fPIC[\ \ ]*) ;; *) if cc_supports_flag -fPIC; then - CFLAGS="$CFLAGS -fPIC" + PIC_CFLAGS="-fPIC" + PIC_LDFLAGS="-Wl,-z,relro" + fi + ;; + esac + + case " $CFLAGS " in + *[\ \ ]-fPIE[\ \ ]*) ;; + *) if cc_supports_flag -fPIE; then + PIE_CFLAGS="-fPIE" + PIE_LDFLAGS="-pie -Wl,-z,relro" fi ;; esac @@ -257,6 +267,11 @@ else fi fi +AC_SUBST(PIC_CFLAGS) +AC_SUBST(PIC_LDFLAGS) +AC_SUBST(PIE_CFLAGS) +AC_SUBST(PIE_LDFLAGS) + # Check for -Wl,--gc-sections AC_MSG_CHECKING([for ld that supports "-Wl,--gc-sections"]) AC_TRY_LINK([ @@ -268,8 +283,11 @@ if test "$ac_gcsections" = "yes"; then rm -f conftest.c touch conftest.c if $CC -c conftest.c; then - if $LD --gc-sections -o conftest conftest.o 2>&1 | \ - grep "Warning: gc-sections option ignored" > /dev/null; then + ld_out=`$LD --gc-sections -o conftest conftest.o 2>&1` + ld_ret=$? + if test $ld_ret -ne 0 ; then + ac_gcsections=no + elif echo "$ld_out" | egrep 'option ignored|^usage:|illegal option' >/dev/null ; then ac_gcsections=no fi fi @@ -571,7 +589,7 @@ fi AC_CHECK_LIB(socket,socket) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist fpathconf setrlimit) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit) AC_MSG_CHECKING(for dirfd) AC_TRY_LINK([ |