From db8bd91488ffe5a29fb4422c5d32318f8c87182d Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 20 Oct 2012 20:07:30 -0400 Subject: [PATCH] Fix for some platforms that didn't want to insert the harden LIB in some cases. --- configure.ac | 1 + m4/ax_harden_compiler_flags.m4 | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 28f8cace3..ca5fe7fb6 100644 --- a/configure.ac +++ b/configure.ac @@ -707,6 +707,7 @@ echo " * C Flags: $CFLAGS" echo " * C++ Compiler: $CXX_VERSION" echo " * C++ Flags: $CXXFLAGS" echo " * CPP Flags: $CPPFLAGS" +echo " * LIB Flags: $LIB" echo " * Assertions enabled: $ac_cv_assert" echo " * Debug enabled: $with_debug" echo " * Warnings as failure: $ac_cv_warnings_as_errors" diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index 99916d876..394812d2d 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -68,16 +68,28 @@ AC_REQUIRE([AX_DEBUG]) AC_REQUIRE([AX_CXX_COMPILER_VERSION]) + dnl If we are inside of VCS we append -Werror, otherwise we just use it to test other flags + AX_HARDEN_LIB= ax_append_compile_link_flags_extra= - AS_IF([test "$ac_cv_vcs_checkout" = "yes"], [ - AX_CHECK_LINK_FLAG([-Werror]) + AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],[ + AX_CHECK_LINK_FLAG([-Werror],[ + AX_HARDEN_LIB="-Werror $AX_HARDEN_LIB" + ]) ],[ AX_CHECK_LINK_FLAG([-Werror],[ - ax_append_compile_link_flags_extra=$ax_cv_check_ldflags___Werror + ax_append_compile_link_flags_extra='-Werror' ]) ]) - AX_CHECK_LINK_FLAG([-z relro -z now],,[$ax_append_compile_link_flags_extra]) - AX_CHECK_LINK_FLAG([-pie],,[$ax_append_compile_link_flags_extra]) + + AX_CHECK_LINK_FLAG([-z relro -z now],[ + AX_HARDEN_LIB="-z relro -z now $AX_HARDEN_LIB" + ],,[$ax_append_compile_link_flags_extra]) + + AX_CHECK_LINK_FLAG([-pie],[ + AX_HARDEN_LIB="-pie $AX_HARDEN_LIB" + ],,[$ax_append_compile_link_flags_extra]) + + LIB="$LIB $AX_HARDEN_LIB" ]) AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [