]> git.proxmox.com Git - libtpms.git/commitdiff
Add relro and now to hardening cflags, if available
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 3 Feb 2015 19:06:46 +0000 (14:06 -0500)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 3 Feb 2015 19:06:46 +0000 (14:06 -0500)
Check ld for availability of relro and now flags and add them to the
hardening cflags if available.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
configure.ac

index 6fb4995e35da68d11c77ca6a65bca51df2eccfc2..f3b8a675a518d3c82f4f7c20eed5b5dea7dd19f2 100644 (file)
@@ -135,7 +135,14 @@ AC_C_INLINE
 AC_TYPE_SIZE_T
 
 HARDENING_CFLAGS="-fstack-protector-strong -Wstack-protector "
-HARDENING_CFLAGS+="-D_FORTIFY_SOURCE=2"
+HARDENING_CFLAGS+="-D_FORTIFY_SOURCE=2 "
+dnl Check ld for 'relro' and 'now'
+if $LD --help 2>&1 | $GREP '\-z relro ' > /dev/null; then
+  HARDENING_CFLAGS+="-Wl,-z,relro "
+fi
+if $LD --help 2>&1 | $GREP '\-z now ' > /dev/null; then
+  HARDENING_CFLAGS+="-Wl,-z,now "
+fi
 AC_SUBST([HARDENING_CFLAGS])
 
 CFLAGS="$CFLAGS -Wall -Werror -Wreturn-type -Wsign-compare"