diff -Nru gcc-4.1.1.GENTOO_2006-10-08/gcc/config/gentoo-hardened/hardened.h gcc-4.1.1/gcc/config/gentoo-hardened/hardened.h --- gcc-4.1.1.GENTOO_2006-10-08/gcc/config/gentoo-hardened/hardened.h 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.1.1/gcc/config/gentoo-hardened/hardened.h 2006-10-09 02:09:23.000000000 +0200 @@ -0,0 +1,23 @@ +/* Copyright 1999-2006 Gentoo Foundation */ +/* Distributed under the terms of the GNU General Public License v2 */ +/* $Header: $ */ + +#ifndef LINUX_HARDENED_H +#define LINUX_HARDENED_H + +/* callout support for minispecs */ + +#undef GENTOO_HARDENED_ASM_SPEC +#define GENTOO_HARDENED_ASM_SPEC " %(asm_hardened_pie) " + +#undef GENTOO_HARDENED_CC1_SPEC +#define GENTOO_HARDENED_CC1_SPEC " %(cc1_hardened_pie) %(cc1_hardened_ssp) " + +#undef GENTOO_HARDENED_LINK_PIE_SPEC +#define GENTOO_HARDENED_LINK_PIE_SPEC " %(link_pie_hardened_pie) " + +#undef GENTOO_HARDENED_STARTFILE_SPEC +#undef GENTOO_HARDENED_ENDFILE_SPEC + +#endif /* LINUX_HARDENED_H */ + diff -Nru gcc-4.1.1.GENTOO_2006-10-08/gcc/config.gcc gcc-4.1.1/gcc/config.gcc --- gcc-4.1.1.GENTOO_2006-10-08/gcc/config.gcc 2006-10-08 15:35:06.000000000 +0200 +++ gcc-4.1.1/gcc/config.gcc 2006-10-09 00:24:16.000000000 +0200 @@ -325,7 +325,10 @@ ;; esac -tm_file=${cpu_type}/${cpu_type}.h +hardened_dir="gentoo-hardened" +hardened_all="hardened.h" + +tm_file="${hardened_dir}/${hardened_all} ${cpu_type}/${cpu_type}.h" if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-protos.h then tm_p_file=${cpu_type}/${cpu_type}-protos.h diff -Nru gcc-4.1.1.GENTOO_2006-10-08/gcc/gcc.c gcc-4.1.1/gcc/gcc.c --- gcc-4.1.1.GENTOO_2006-10-08/gcc/gcc.c 2006-10-08 15:35:16.000000000 +0200 +++ gcc-4.1.1/gcc/gcc.c 2006-10-09 00:45:10.000000000 +0200 @@ -87,6 +87,8 @@ #include "gcc.h" #include "flags.h" +#include "hardened-stubs.h" + /* By default there is no special suffix for target executables. */ /* FIXME: when autoconf is fixed, remove the host check - dj */ #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX) @@ -628,6 +630,12 @@ "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}" #endif +/* Gentoo Hardened definitions may overwrite the default specs */ +#ifdef GENTOO_HARDENED_STARTFILE_SPEC +#undef STARTFILE_SPEC +#define STARTFILE_SPEC GENTOO_HARDENED_STARTFILE_SPEC +#endif + /* config.h can define SWITCHES_NEED_SPACES to control which options require spaces between the option and the argument. */ #ifndef SWITCHES_NEED_SPACES @@ -639,6 +647,12 @@ #define ENDFILE_SPEC "" #endif +/* Gentoo Hardened definitions may overwrite the default specs */ +#ifdef GENTOO_HARDENED_ENDFILE_SPEC +#undef ENDFILE_SPEC +#define ENDFILE_SPEC GENTOO_HARDENED_ENDFILE_SPEC +#endif + #ifndef LINKER_NAME #define LINKER_NAME "collect2" #endif @@ -699,7 +713,7 @@ #ifndef LINK_COMMAND_SPEC #define LINK_COMMAND_SPEC "\ %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ - %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ + %(linker) %l " LINK_PIE_SPEC GENTOO_HARDENED_LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ %{static:} %{L*} %(mfwrap) %(link_libgcc) %o %(mflib)\ %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\ @@ -730,11 +744,11 @@ static const char *asm_debug; static const char *cpp_spec = CPP_SPEC; -static const char *cc1_spec = CC1_SPEC; +static const char *cc1_spec = CC1_SPEC GENTOO_HARDENED_CC1_SPEC; static const char *cc1plus_spec = CC1PLUS_SPEC; static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; static const char *link_ssp_spec = LINK_SSP_SPEC; -static const char *asm_spec = ASM_SPEC; +static const char *asm_spec = ASM_SPEC GENTOO_HARDENED_ASM_SPEC; static const char *asm_final_spec = ASM_FINAL_SPEC; static const char *link_spec = LINK_SPEC; static const char *lib_spec = LIB_SPEC; diff -Nru gcc-4.1.1.GENTOO_2006-10-08/gcc/hardened-stubs.h gcc-4.1.1/gcc/hardened-stubs.h --- gcc-4.1.1.GENTOO_2006-10-08/gcc/hardened-stubs.h 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.1.1/gcc/hardened-stubs.h 2006-10-09 00:46:30.000000000 +0200 @@ -0,0 +1,28 @@ +/* Copyright 1999-2006 Gentoo Foundation */ +/* Distributed under the terms of the GNU General Public License v2 */ +/* $Header: $ */ + +/* list of empty hardened specs stubs needed for gcc.c */ + +#ifndef LINUX_HARDENED_STUBS_H +# define LINUX_HARDENED_STUBS_H +# ifndef GENTOO_HARDENED_ASM_SPEC +# define GENTOO_HARDENED_ASM_SPEC "" +# endif +# ifndef GENTOO_HARDENED_CC1_SPEC +# define GENTOO_HARDENED_CC1_SPEC "" +# endif +# ifndef HAVE_LD_PIE +# ifdef GENTOO_HARDENED_LINK_PIE_SPEC +# undef GENTOO_HARDENED_LINK_PIE_SPEC +# endif +# define GENTOO_HARDENED_LINK_PIE_SPEC "" +# else +# ifndef GENTOO_HARDENED_LINK_PIE_SPEC +# define GENTOO_HARDENED_LINK_PIE_SPEC "" +# endif +# endif +#endif + +/* no stubs for startfile/endfile replacement specs in gcc.c */ +