2008-12-17 Magnus Granberg Peter S. Mazinger * gcc/gcc.c: Add spec suff. We add Gentoo Hardened minispec support. --- gcc/gcc.c.zorry +++ gcc/gcc.c @@ -705,10 +705,12 @@ #define LINK_PIE_SPEC "%{pie:-pie} " #define LD_PIE_CRTFILE_GEN_SPEC "%(crtfile_pie_gen)" #define ASM_PIE_SPEC "%{pie:-K PIC}" +#define CC1_PIE_SPEC "%{pie:-fPIE}" #else #define LINK_PIE_SPEC "%{pie:} " #define LD_PIE_CRTFILE_GEN_SPEC "%(crtfile_gen)" #define ASM_PIE_SPEC "" +#define CC1_PIE_SPEC "" #endif #ifndef CRTFILE_GEN_SPEC @@ -731,6 +733,28 @@ #define ENDFILE_PIE_GEN_SPEC "%{shared|pie:crtendS.o%s;:crtend.o%s}" #endif +#ifndef CC1_GENTOO_HARDENED_SPEC +#define CC1_GENTOO_HARDENED_SPEC "%{!D__KERNEL__: %(cc1_pie) %(cc1_ssp) } %(cc1_strict)" +#endif +#ifndef CC1_SSP_SPEC +#define CC1_SSP_SPEC "" +#endif +#ifndef CC1_SSP_ALL_SPEC +#define CC1_SSP_ALL_SPEC "" +#endif +#ifndef CC1_STRICT_SPEC +#define CC1_STRICT_SPEC "" +#endif +#ifndef LINK_NOW_SPEC +#define LINK_NOW_SPEC "" +#endif + + + + + + + /* -u* was put back because both BSD and SysV seem to support it. */ /* %{static:} simply prevents an error message if the target machine doesn't handle -static. */ @@ -740,7 +764,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) %(link_now) %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\ %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ @@ -772,7 +796,7 @@ 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 CC1_GENTOO_HARDENED_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; @@ -801,6 +825,14 @@ static const char *startfile_pie_t_gen_spec = STARTFILE_PIE_T_GEN_SPEC; static const char *startfile_pie_gen_spec = STARTFILE_PIE_GEN_SPEC; static const char *endfile_pie_gen_spec = ENDFILE_PIE_GEN_SPEC; +static const char *cc1_ssp_spec = CC1_SSP_SPEC; +static const char *cc1_ssp_all_spec = CC1_SSP_ALL_SPEC; +static const char *cc1_pie_spec = CC1_PIE_SPEC; +static const char *cc1_strict_spec = CC1_STRICT_SPEC; +static const char *link_now_spec = LINK_NOW_SPEC; +static const char *link_pie_spec = LINK_PIE_SPEC; + + /* Standard options to cpp, cc1, and as, to reduce duplication in specs. There should be no need to override these in target dependent files, @@ -1643,6 +1675,14 @@ INIT_STATIC_SPEC ("startfile_pie_t_gen", &startfile_pie_t_gen_spec), INIT_STATIC_SPEC ("startfile_pie_gen", &startfile_pie_gen_spec), INIT_STATIC_SPEC ("endfile_pie_gen", &endfile_pie_gen_spec), + INIT_STATIC_SPEC ("cc1_ssp", &cc1_ssp_spec), + INIT_STATIC_SPEC ("cc1_ssp_all", &cc1_ssp_all_spec), + INIT_STATIC_SPEC ("cc1_pie", &cc1_pie_spec), + /* INIT_STATIC_SPEC ("cc1_fortify", &cc1_fortify_spec), */ + INIT_STATIC_SPEC ("cc1_strict", &cc1_strict_spec), + /* INIT_STATIC_SPEC ("link_relro", &link_relro_spec), */ + INIT_STATIC_SPEC ("link_now", &link_now_spec), + INIT_STATIC_SPEC ("link_pie", &link_pie_spec), }; #ifdef EXTRA_SPECS /* additional specs needed */