aboutsummaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorJacob Appelbaum <jacob@appelbaum.net>2009-11-06 15:45:27 -0800
committerJacob Appelbaum <jacob@appelbaum.net>2010-05-07 16:15:26 +0200
commit04fa935e02270bc90aca0f1c652d31c7a872175b (patch)
tree657e97f51ecb9e8faa20f2744308daeeba36f4a2 /configure.in
parentc7114568c253b881f139ccd8f75b49618789ef35 (diff)
downloadtor-04fa935e02270bc90aca0f1c652d31c7a872175b.tar
tor-04fa935e02270bc90aca0f1c652d31c7a872175b.tar.gz
Add support for gcc compiler/linker hardening flags.
This patch adds support for two new configure options: '--enable-gcc-hardening' This sets CFLAGS to include: "-D_FORTIFY_SOURCE=2 -fstack-protector-all" "-fwrapv -fPIE -Wstack-protector -Wformat -Wformat-security" "-Wpointer-sign" It sets LDFLAGS to include: "-pie" '--enable-linker-hardening' This sets LDFLAGS to include: " -z relro -z now"
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in21
1 files changed, 21 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 10e509d3c..07b3ff423 100644
--- a/configure.in
+++ b/configure.in
@@ -90,6 +90,27 @@ AC_ARG_ENABLE(gcc-warnings,
AC_ARG_ENABLE(gcc-warnings-advisory,
AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
+dnl Adam shostack suggests the following for Windows:
+dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
+dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
+dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
+AC_ARG_ENABLE(gcc-hardening,
+ AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
+[if test x$enableval = xyes; then
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
+ CFLAGS+=" -fwrapv -fPIE -Wstack-protector -Wformat -Wformat-security"
+ CFLAGS+=" -Wpointer-sign"
+ LDFLAGS+=" -pie"
+fi])
+
+dnl Linker hardening options
+dnl Currently these options are ELF specific - you can't use this with MacOSX
+AC_ARG_ENABLE(linker-hardening,
+ AS_HELP_STRING(--enable-linker-hardening, enable linker security fixups),
+[if test x$enableval = xyes; then
+ LDFLAGS+=" -z relro -z now"
+fi])
+
AC_ARG_ENABLE(local-appdata,
AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
if test "$enable_local_appdata" = "yes"; then