On Hardened we add or remove some options like -fstack-check, -fstack-protector-all, -fstrict_overflow and -z now --- a/libgcc/Makefile.in 2011-11-22 04:01:02.000000000 +0100 +++ b/libgcc/Makefile.in 2011-12-25 15:18:22.449610631 +0100 @@ -225,7 +225,7 @@ endif LIBGCC2_DEBUG_CFLAGS = -g LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \ $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \ - -fbuilding-libgcc -fno-stack-protector \ + -fbuilding-libgcc -fno-stack-protector -fstack-check=no \ $(INHIBIT_LIBC_CFLAGS) # Additional options to use when compiling libgcc2.a. @@ -279,7 +290,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CF -finhibit-size-directive -fno-inline -fno-exceptions \ -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \ -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \ - $(INHIBIT_LIBC_CFLAGS) + -fstack-check=no $(INHIBIT_LIBC_CFLAGS) # Extra flags to use when compiling crt{begin,end}.o. CRTSTUFF_T_CFLAGS = --- a/gcc/defaults.h 2016-01-04 15:30:50.000000000 +0100 +++ b/gcc/defaults.h 2016-05-02 22:23:43.815707806 +0200 @@ -1398,8 +1398,12 @@ see the files COPYING3 and COPYING.RUNTI /* Default value for flag_stack_protect when flag_stack_protect is initialized to -1: --enable-default-ssp: Default flag_stack_protect to -fstack-protector-strong. --disable-default-ssp: Default flag_stack_protect to 0. + Hardened: Default flag_stack_protect to -fstack-protector-all. */ #ifdef ENABLE_DEFAULT_SSP +# ifdef EXTRA_OPTIONS +# define DEFAULT_FLAG_SSP 2 +# endif # ifndef DEFAULT_FLAG_SSP # define DEFAULT_FLAG_SSP 3 # endif --- a/gcc/gcc.c 2016-02-19 23:18:38.000000000 +0100 +++ b/gcc/gcc.c 2016-05-02 22:56:10.185721270 +0200 @@ -868,6 +868,13 @@ proper position among the other output f #endif #endif +#define STACK_CHECK_SPEC "%{fstack-check|fstack-check=*:;: -fstack-check} " +#ifdef EXTRA_OPTIONS +#define LINK_NOW_SPEC "%{!nonow:-z now} " +#else +#define LINK_NOW_SPEC "" +#endif + #ifdef ENABLE_DEFAULT_PIE #define NO_PIE_SPEC "no-pie|static" #define PIE_SPEC NO_PIE_SPEC "|r|shared:;" @@ -1013,7 +1020,7 @@ proper position among the other output f %(linker) " \ LINK_PLUGIN_SPEC \ "%{flto|flto=*:%