enable relro with PIE if available, this gives extra protection to the ELF segment
authoridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Thu, 17 May 2007 18:20:16 +0000 (18:20 +0000)
committeridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Thu, 17 May 2007 18:20:16 +0000 (18:20 +0000)
git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_0@22974 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/configure.in

index 2f763b0..592fc6a 100644 (file)
@@ -1763,6 +1763,29 @@ EOF
        fi
 fi
 
+#Check if we can enable relro as well
+if test x"${samba_cv_fpie}" = x"yes"
+then
+       AC_CACHE_CHECK(for relro, samba_cv_fpie_relro,
+       [
+               cat > conftest.c <<EOF
+int foo;
+main () { return 0;}
+EOF
+                if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -Wl,z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+               then
+                       samba_cv_fpie_relro=yes
+               else
+                       samba_cv_fpie_relro=no
+               fi
+               rm -f conftest*
+       ])
+       if test x"${samba_cv_fpie_relro}" = x"yes"
+       then
+               PIE_LDFLAGS="-pie -Wl,z,relro"
+       fi
+fi
+
 # Assume non-shared by default and override below
 BLDSHARED="false"