diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-05-24 04:18:52 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-05-24 04:18:52 +0000 |
commit | 566889b2039773ca66ba42b858f553d5e919f5c9 (patch) | |
tree | 494b9b1d9dc929bdd0c14990d94dafdc57eb9053 /3.3.6 | |
parent | slightly tweaked version of upstream gcc-3.4.3 boundschecking (diff) | |
download | gcc-patches-566889b2039773ca66ba42b858f553d5e919f5c9.tar.gz gcc-patches-566889b2039773ca66ba42b858f553d5e919f5c9.tar.bz2 gcc-patches-566889b2039773ca66ba42b858f553d5e919f5c9.zip |
import pie patchset 8.7.8 by psm (tweaked a little to work with boundschecking)
Diffstat (limited to '3.3.6')
25 files changed, 2307 insertions, 0 deletions
diff --git a/3.3.6/pie/def/01_all_gcc-3.3.5-v8.7.8-pie-generic-default.patch b/3.3.6/pie/def/01_all_gcc-3.3.5-v8.7.8-pie-generic-default.patch new file mode 100644 index 0000000..31ffd69 --- /dev/null +++ b/3.3.6/pie/def/01_all_gcc-3.3.5-v8.7.8-pie-generic-default.patch @@ -0,0 +1,392 @@ +--- gcc-3.3.3/gcc/config/linux.h.def Mon May 10 09:04:47 2004 ++++ gcc-3.3.3/gcc/config/linux.h Mon May 10 09:04:47 2004 +@@ -45,6 +45,7 @@ + provides part of the support for getting C++ file-scope static + object constructed before entering `main'. */ + ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + #ifdef USE_GNULIBC_1 + #define STARTFILE_SPEC \ +@@ -55,6 +56,13 @@ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +@@ -78,8 +86,12 @@ + object constructed before entering `main', followed by a normal + GNU/Linux "finalizer" file, `crtn.o'. */ + ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s" + #define ENDFILE_SPEC "\ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ + %{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" +--- gcc-3.3.3/gcc/gcc.c.def Mon May 10 09:04:47 2004 ++++ gcc-3.3.3/gcc/gcc.c Mon May 10 09:04:47 2004 +@@ -82,6 +82,14 @@ + #include "gcc.h" + #include "flags.h" + ++#include "pie-ssp-setup.h" ++#include "pie-ssp-modus.h" ++#include "pie-ssp-chain.h" ++#if !(defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP)) ++#undef HARDENED_STARTFILE_SPEC ++#undef HARDENED_ENDFILE_SPEC ++#endif ++ + #ifdef HAVE_SYS_RESOURCE_H + #include <sys/resource.h> + #endif +@@ -683,16 +691,28 @@ + static const char *asm_debug; + static const char *cpp_spec = CPP_SPEC; + static const char *cpp_predefines = CPP_PREDEFINES; ++#ifdef HARDENED_CC1_SPEC_SUFFIX ++static const char *cc1_spec = CC1_SPEC " " HARDENED_CC1_SPEC_SUFFIX; ++#else + static const char *cc1_spec = CC1_SPEC; ++#endif + static const char *cc1plus_spec = CC1PLUS_SPEC; + static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; + static const char *asm_spec = 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; + static const char *libgcc_spec = LIBGCC_SPEC; ++#ifdef HARDENED_ENDFILE_SPEC ++static const char *endfile_spec = HARDENED_ENDFILE_SPEC; ++#else + static const char *endfile_spec = ENDFILE_SPEC; ++#endif ++#ifdef HARDENED_STARTFILE_SPEC ++static const char *startfile_spec = HARDENED_STARTFILE_SPEC; ++#else + static const char *startfile_spec = STARTFILE_SPEC; ++#endif + static const char *switches_need_spaces = SWITCHES_NEED_SPACES; + static const char *linker_name_spec = LINKER_NAME; + static const char *link_command_spec = LINK_COMMAND_SPEC; +--- gcc/gcc/pie-ssp-chain.h.piedef~ 2005-03-01 17:19:59 +0100 ++++ gcc/gcc/pie-ssp-chain.h 2005-03-01 17:19:59 +0100 +@@ -0,0 +1,77 @@ ++#ifndef LINUX_PIE_SSP_CHAIN_H ++#define LINUX_PIE_SSP_CHAIN_H ++ ++/* ++ * cc1: ++ **************************************************************************** ++ * C compiler generating code - for nonintel arches fpic/fPIC is not the same ++ * Thu Feb 5 22:32:02 CET 2004 -fpie is causing TEXT relocations in binaries ++ * ++ * -fPIE/-fpie may not be used, it produces unusable objects for shared libs ++ * if it becomes usable, then -fPIE should be used instead of -fpie (arch dep) ++ * ++ * we take care now not using -fPIE on shared libs, by checking for -fPIC/fpic ++ **************************************************************************** ++ */ ++ ++#define CC1_PIE "%{!fPIC:%{!fpic:-fPIE}}" ++ ++#define CC1_SSP "-fstack-protector" ++#define CC1_SSP_ALL "%{!fno-stack-protector-all:-fstack-protector-all}" ++#define CC1_SSP_DUMMY "%{fstack-protector:} %{fno-stack-protector:} %{fstack-protector-all:} %{fno-stack-protector-all:}" ++ ++#if ! ( defined ( __hppa__ ) || defined ( USE_HTB ) ) ++#define HARDENED_SSP_SPEC_SUFFIX SSP_CHAIN_EXCLUDE( STD_SSP_TRIGGER( CC1_SSP " " SSP_LIBC_EXCLUDE(CC1_SSP_ALL) ) ) ++#else ++#define HARDENED_SSP_SPEC_SUFFIX CC1_SSP_DUMMY ++#endif ++ ++#define HARDENED_CC1_SPEC_SUFFIX STD_CHAIN_EXCLUDE( CC1_CHAIN_EXCLUDE( STD_PIE_TRIGGER(CC1_PIE) ) " " HARDENED_SSP_SPEC_SUFFIX ) ++ ++/* ++ * startfile: ++ * we have 4 types of archs: ++ * default: x86[_64]/mips/parisc ++ * not using profile: alpha/rs6000/sparc[64] ++ * not using crtbeginT.o for static: arm/ia64 ++ * having some addon: rs6000(mnewlib) ++ */ ++ ++/* ++ * endfile: ++ * we have 3 types of archs: ++ * default: x86[_64]/mips/parisc ++ * fastmath addon: alpha/ia64/sparc[64] ++ * having some other addon: rs6000(mnewlib) ++ */ ++ ++/* special cases: rs6000 uses STARTFILE_LINUX_SPEC/ENDFILE_LINUX_SPEC */ ++ ++/* the above variety explains why the startfile/endfile sections are moved directly to gcc */ ++ ++/* ++ * link: ++ ***************************************************************************** ++ * building of position independent executables is enabled by binutils:ld -pie ++ * use the x86 Redhat branch update provided support for LINK_PIE_SPEC section ++ ***************************************************************************** ++ */ ++ ++#define LINKSEC_PIE_LNK "-pie" ++ ++#define LINKSEC_RELRO_LNK "-z relro" ++ ++#define LINKSEC_NOW_LNK "-z now" ++ ++/* disable default */ ++#ifdef LINK_PIE_SPEC ++#undef LINK_PIE_SPEC ++#endif ++ ++#ifdef HAVE_LD_PIE ++#define LINK_PIE_SPEC STD_PIE_TRIGGER( LNK_CHAIN_EXCLUDE( PIE_CHAIN_EXCLUDE(LINKSEC_PIE_LNK) ) ) " " OPP_PIE_TRIGGER() " " STD_RELRO_TRIGGER(LINKSEC_RELRO_LNK) " " OPP_RELRO_TRIGGER() " " STD_NOW_TRIGGER(LINKSEC_NOW_LNK) " " OPP_NOW_TRIGGER() ++#else ++#error we need ld w/ -pie support ++#endif ++ ++#endif /* LINUX_PIE_SSP_CHAIN_H */ +--- gcc/gcc/pie-ssp-modus.h.piedef~ 2005-03-01 17:19:59 +0100 ++++ gcc/gcc/pie-ssp-modus.h 2005-03-01 17:19:59 +0100 +@@ -0,0 +1,139 @@ ++#ifndef LINUX_PIE_SSP_MODUS_H ++#define LINUX_PIE_SSP_MODUS_H ++ ++/* ++ * The enabler and inverse is used for the proper inclusion of the ++ * startfile and endfile chaining of the crt1, crtbegin and crtend ++ * to use caution not issuing zero or double occurrences of object ++ * in the respective sections of the currently utilized definition ++ */ ++ ++/* ++ **************************************************************** ++ * set up the trigger logic for stack smashing protector with CC1 ++ **************************************************************** ++ */ ++ ++#if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP ) ++ ++#define STD_SSP_TRIGGER(flag) \ ++ NSPEC("fno-stack-protector", \ ++ flag \ ++ ) ++ ++#else /* defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP ) */ ++ ++#define STD_SSP_TRIGGER(flag) \ ++ PSPEC("fstack-protector", \ ++ flag \ ++ ) ++ ++#endif /* defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP ) */ ++ ++/* ++ **************************************************************** ++ * define the trigger logic for setting up position independence ++ **************************************************************** ++ */ ++ ++#if defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP ) ++ ++#define STD_PIE_TRIGGER(flag) \ ++ NSPEC("nopie", \ ++ flag \ ++ ) ++ ++#define INV_PIE_TRIGGER(flag) \ ++ PSPEC("nopie", \ ++ flag \ ++ ) ++ ++#define OPP_PIE_TRIGGER(flag) \ ++ PSPEC("pie", \ ++ flag \ ++ ) ++ ++#else /* defined ( DEFAULT_PIE ) || defined ( EFAULT_PIE_SSP ) */ ++ ++#define STD_PIE_TRIGGER(flag) \ ++ PSPEC("pie", \ ++ flag \ ++ ) ++ ++#define INV_PIE_TRIGGER(flag) \ ++ NSPEC("pie", \ ++ flag \ ++ ) ++ ++#define OPP_PIE_TRIGGER(flag) \ ++ PSPEC("nopie", \ ++ flag \ ++ ) ++ ++#endif /* defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP ) */ ++ ++/* ++ **************************************************************** ++ * define the trigger logic for setting up -z relro usage ++ **************************************************************** ++ */ ++ ++#if defined ( EFAULT_RELRO ) ++ ++#define STD_RELRO_TRIGGER(flag) \ ++ NSPEC("norelro", \ ++ flag \ ++ ) ++ ++#define OPP_RELRO_TRIGGER(flag) \ ++ PSPEC("relro", \ ++ flag \ ++ ) ++ ++#else /* defined ( EFAULT_RELRO ) */ ++ ++#define STD_RELRO_TRIGGER(flag) \ ++ PSPEC("relro", \ ++ flag \ ++ ) ++ ++#define OPP_RELRO_TRIGGER(flag) \ ++ PSPEC("norelro", \ ++ flag \ ++ ) ++ ++#endif /* defined ( EFAULT_RELRO ) */ ++ ++/* ++ **************************************************************** ++ * define the trigger logic for setting up -z now usage ++ **************************************************************** ++ */ ++ ++#if defined ( EFAULT_BIND_NOW ) ++ ++#define STD_NOW_TRIGGER(flag) \ ++ NSPEC("nonow", \ ++ flag \ ++ ) ++ ++#define OPP_NOW_TRIGGER(flag) \ ++ PSPEC("now", \ ++ flag \ ++ ) ++ ++#else /* defined ( EFAULT_BIND_NOW ) */ ++ ++#define STD_NOW_TRIGGER(flag) \ ++ PSPEC("now", \ ++ flag \ ++ ) ++ ++#define OPP_NOW_TRIGGER(flag) \ ++ PSPEC("nonow", \ ++ flag \ ++ ) ++ ++#endif /* defined ( EFAULT_BIND_NOW ) */ ++ ++#endif /* LINUX_PIE_SSP_MODUS_H */ +--- gcc/gcc/pie-ssp-setup.h.piedef~ 2005-03-01 17:19:59 +0100 ++++ gcc/gcc/pie-ssp-setup.h 2005-03-01 17:19:59 +0100 +@@ -0,0 +1,84 @@ ++#ifndef LINUX_PIE_SSP_SETUP_H ++#define LINUX_PIE_SSP_SETUP_H ++ ++/* ********************************************************************************** */ ++/* definition of macros and functions needed for constructing the specs file sections */ ++/* ********************************************************************************** */ ++ ++#define PSPEC(a,b) "%{"a": "b"} " ++ ++#define NSPEC(a,b) "%{!"a": "b"} " ++ ++/* ++ * standard exclusion ++ * disables -fPIE ++ * disables SSP ++ * applies to cc1 ++ */ ++#define STD_CHAIN_EXCLUDE(flag) \ ++ NSPEC("D__KERNEL__", \ ++ flag \ ++ ) ++ ++/* ++ * link section exclusion ++ * disables -fPIE ++ * ibcs not added (yet) ++ * applies to cc1 and link_command ++ */ ++#define PIE_LNK_CHAIN_EXCLUDE(flag) \ ++ NSPEC("static", \ ++ flag \ ++ ) ++ ++/* pic exclusion, applies to cc1 */ ++#define PIC_CHAIN_EXCLUDE(flag) \ ++ NSPEC("fno-PIC", \ ++ NSPEC("fno-pic", \ ++ flag \ ++ )) ++ ++/* ++ * pie exclusion ++ * disables -fPIE and -pie ++ * applies to cc1 and link_command ++ */ ++#define PIE_CHAIN_EXCLUDE(flag) \ ++ NSPEC("shared", \ ++ NSPEC("nostdlib", \ ++ NSPEC("nostartfiles", \ ++ NSPEC("fno-PIE", \ ++ NSPEC("fno-pie", \ ++ flag \ ++ ))))) ++ ++/* ++ * pie exclusion ++ * disables -pie ++ * applies to link_command ++ */ ++#define LNK_GEN_CHAIN_EXCLUDE(flag) \ ++ NSPEC("A", \ ++ flag \ ++ ) ++ ++#define CC1_CHAIN_EXCLUDE(flag) PIE_LNK_CHAIN_EXCLUDE( PIC_CHAIN_EXCLUDE( PIE_CHAIN_EXCLUDE(flag) ) ) ++#define LNK_CHAIN_EXCLUDE(flag) PIE_LNK_CHAIN_EXCLUDE( LNK_GEN_CHAIN_EXCLUDE(flag) ) ++ ++/* ++ * ssp exclusion ++ * disables SSP ++ * applies to cc1 ++ */ ++#define SSP_CHAIN_EXCLUDE(flag) \ ++ NSPEC("nostdlib", \ ++ flag \ ++ ) ++ ++#define SSP_LIBC_EXCLUDE(flag) \ ++ NSPEC("D_LIBC", \ ++ NSPEC("D_LIBC_REENTRANT", \ ++ flag \ ++ )) ++ ++#endif /* LINUX_PIE_SSP_SETUP_H */ diff --git a/3.3.6/pie/def/02_all_gcc-3.3.3-v8.7.1-pie-alpha-default.patch b/3.3.6/pie/def/02_all_gcc-3.3.3-v8.7.1-pie-alpha-default.patch new file mode 100644 index 0000000..36658c1 --- /dev/null +++ b/3.3.6/pie/def/02_all_gcc-3.3.3-v8.7.1-pie-alpha-default.patch @@ -0,0 +1,32 @@ +--- gcc-3.3.3/gcc/config/alpha/elf.h.defpie Tue May 4 20:34:17 2004 ++++ gcc-3.3.3/gcc/config/alpha/elf.h Tue May 4 20:46:07 2004 +@@ -409,8 +409,15 @@ + support for getting C++ file-scope static object constructed + before entering `main'. */ + ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ +@@ -430,8 +437,13 @@ + getting C++ file-scope static object constructed before entering + `main', followed by a normal ELF "finalizer" file, `crtn.o'. */ + ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s" + #define ENDFILE_SPEC "\ + %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ diff --git a/3.3.6/pie/def/03_all_gcc-3.3.3-v8.7.1-pie-arm-default.patch b/3.3.6/pie/def/03_all_gcc-3.3.3-v8.7.1-pie-arm-default.patch new file mode 100644 index 0000000..6282e94 --- /dev/null +++ b/3.3.6/pie/def/03_all_gcc-3.3.3-v8.7.1-pie-arm-default.patch @@ -0,0 +1,32 @@ +--- gcc-3.3.3/gcc/config/arm/linux-elf.h.defpie Tue May 4 20:38:17 2004 ++++ gcc-3.3.3/gcc/config/arm/linux-elf.h Tue May 4 20:45:37 2004 +@@ -61,8 +61,16 @@ + provides part of the support for getting C++ file-scope static + object constructed before entering `main'. */ + ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbegin.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +@@ -84,8 +92,12 @@ + object constructed before entering `main', followed by a normal + GNU/Linux "finalizer" file, `crtn.o'. */ + ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s" + #define ENDFILE_SPEC "\ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ + %{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" diff --git a/3.3.6/pie/def/04_all_gcc-3.3.3-v8.7.1-pie-ia64-default.patch b/3.3.6/pie/def/04_all_gcc-3.3.3-v8.7.1-pie-ia64-default.patch new file mode 100644 index 0000000..b29e4f8 --- /dev/null +++ b/3.3.6/pie/def/04_all_gcc-3.3.3-v8.7.1-pie-ia64-default.patch @@ -0,0 +1,33 @@ +--- gcc-3.3.3/gcc/config/ia64/linux.h.defpie Tue May 4 20:41:20 2004 ++++ gcc-3.3.3/gcc/config/ia64/linux.h Tue May 4 20:45:04 2004 +@@ -20,8 +20,16 @@ + } while (0) + + /* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */ ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +@@ -38,8 +46,13 @@ + #endif + + /* Similar to standard Linux, but adding -ffast-math support. */ ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s" + #define ENDFILE_SPEC "\ + %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ diff --git a/3.3.6/pie/def/11_all_gcc-3.3.5-v8.7.7-pie-rs6000-default.patch b/3.3.6/pie/def/11_all_gcc-3.3.5-v8.7.7-pie-rs6000-default.patch new file mode 100644 index 0000000..23b356a --- /dev/null +++ b/3.3.6/pie/def/11_all_gcc-3.3.5-v8.7.7-pie-rs6000-default.patch @@ -0,0 +1,116 @@ +--- gcc-3.3.5/gcc/config/rs6000/sysv4.h.def~ Tue Nov 30 16:02:43 2004 ++++ gcc-3.3.5/gcc/config/rs6000/sysv4.h Tue Nov 30 16:31:21 2004 +@@ -859,6 +859,27 @@ + %{mcall-netbsd: -mbig} \ + }}}}" + ++#ifdef HAVE_LD_PIE ++#if defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP) ++#define HARDENED_ASM_SPEC "%(asm_cpu) \ ++%{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \ ++%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ ++%{mrelocatable} %{mrelocatable-lib} \ ++%{!D__KERNEL__: %{!fno-PIC:%{!fno-pic:%{!fno-PIE:%{!fno-pie: %{!nopie:-K PIC} }}}} } \ ++%{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \ ++%{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \ ++%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ ++ %{mcall-freebsd: -mbig} \ ++ %{mcall-i960-old: -mlittle} \ ++ %{mcall-linux: -mbig} \ ++ %{mcall-gnu: -mbig} \ ++ %{mcall-netbsd: -mbig} \ ++}}}}" ++#undef ASM_SPEC ++#define ASM_SPEC HARDENED_ASM_SPEC ++#endif ++#endif ++ + #define CC1_ENDIAN_BIG_SPEC "" + + #define CC1_ENDIAN_LITTLE_SPEC "\ +@@ -1164,6 +1185,13 @@ + %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else + #ifdef HAVE_LD_PIE ++#undef HARDENED_STARTFILE_SPEC ++#define HARDENED_STARTFILE_LINUX_SPEC "\ ++%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{nopie:crt1.o%s}%{!nopie:Scrt1.o%s}} }}} \ ++%{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ ++%{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{nopie:crtbegin.o%s}%{!nopie:crtbeginS.o%s}} }" + #define STARTFILE_LINUX_SPEC "\ + %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ + %{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ +@@ -1180,6 +1208,11 @@ + #endif + + #ifdef HAVE_LD_PIE ++#undef HARDENED_ENDFILE_SPEC ++#define HARDENED_ENDFILE_LINUX_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{nopie:crtend.o%s}%{!nopie:crtendS.o%s}} } \ ++%{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}" + #define ENDFILE_LINUX_SPEC "\ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ + %{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } \ +@@ -1190,6 +1223,15 @@ + %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}" + #endif + ++#ifdef HAVE_LD_PIE ++#if defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP) ++#undef STARTFILE_LINUX_SPEC ++#define STARTFILE_LINUX_SPEC HARDENED_STARTFILE_LINUX_SPEC ++#undef ENDFILE_LINUX_SPEC ++#define ENDFILE_LINUX_SPEC HARDENED_ENDFILE_LINUX_SPEC ++#endif ++#endif ++ + #define LINK_START_LINUX_SPEC "" + + #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ +--- gcc-3.3.5/gcc/config/rs6000/linux64.h.def~ Tue Nov 30 16:02:43 2004 ++++ gcc-3.3.5/gcc/config/rs6000/linux64.h Tue Nov 30 16:36:54 2004 +@@ -166,6 +166,13 @@ + + #undef STARTFILE_LINUX_SPEC + #ifdef HAVE_LD_PIE ++#undef HARDENED_STARTFILE_SPEC ++#undef HARDENED_STARTFILE_LINUX_SPEC ++#define HARDENED_STARTFILE_LINUX_SPEC "\ ++%{!shared: %{pg|p:gcrt1.o%s} %{!pg:%{!p:%{static:crt1.o%s} \ ++%{!static:%{nopie:crt1.o%s}%{!nopie:Scrt1.o%s}}}}} crti.o%s \ ++%{shared:crtbeginS.o%s} %{!shared: %{static:crtbeginT.o%s} \ ++%{!static:%{nopie:crtbegin.o%s} %{!nopie:crtbeginS.o%s}}}" + #define STARTFILE_LINUX_SPEC "\ + %{!shared: %{pg|p:gcrt1.o%s} %{!pg:%{!p:%{static:crt1.o%s} \ + %{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} crti.o%s \ +@@ -180,6 +187,11 @@ + + #undef ENDFILE_LINUX_SPEC + #ifdef HAVE_LD_PIE ++#undef HARDENED_ENDFILE_SPEC ++#undef HARDENED_ENDFILE_LINUX_SPEC ++#define HARDENED_ENDFILE_LINUX_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{nopie:crtend.o%s}%{!nopie:crtendS.o%s}}} crtn.o%s" + #define ENDFILE_LINUX_SPEC "\ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ + %{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}}} crtn.o%s" +@@ -188,6 +200,15 @@ + %{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" + #endif + ++#ifdef HAVE_LD_PIE ++#if defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP) ++#undef STARTFILE_LINUX_SPEC ++#define STARTFILE_LINUX_SPEC HARDENED_STARTFILE_LINUX_SPEC ++#undef ENDFILE_LINUX_SPEC ++#define ENDFILE_LINUX_SPEC HARDENED_ENDFILE_LINUX_SPEC ++#endif ++#endif ++ + #undef TOC_SECTION_ASM_OP + #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\"" + diff --git a/3.3.6/pie/def/12_all_gcc-3.3.5-v8.7.7-pie-sparc-default.patch b/3.3.6/pie/def/12_all_gcc-3.3.5-v8.7.7-pie-sparc-default.patch new file mode 100644 index 0000000..33b6d9b --- /dev/null +++ b/3.3.6/pie/def/12_all_gcc-3.3.5-v8.7.7-pie-sparc-default.patch @@ -0,0 +1,113 @@ +--- gcc-3.3.5/gcc/config/sparc/linux.h.def~ Tue Nov 30 16:02:43 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux.h Tue Nov 30 16:23:19 2004 +@@ -40,6 +40,7 @@ + provides part of the support for getting C++ file-scope static + object constructed before entering `main'. */ + ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + #ifdef USE_GNULIBC_1 + #define STARTFILE_SPEC \ +@@ -48,6 +49,12 @@ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ +@@ -69,8 +76,13 @@ + object constructed before entering `main', followed by a normal + GNU/Linux "finalizer" file, `crtn.o'. */ + ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s" + #define ENDFILE_SPEC "\ + %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ +@@ -217,6 +229,17 @@ + "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ + %{fpic|fPIC|fpie|fPIE|pie:-K PIC} %(asm_cpu) %(asm_relax)" + ++#ifdef HAVE_LD_PIE ++#if defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP) ++#define HARDENED_ASM_SPEC \ ++ "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ ++ %{!D__KERNEL__: %{!fno-PIC:%{!fno-pic:%{!fno-PIE:%{!fno-pie: %{!nopie:-K PIC} }}}} } \ ++ %(asm_cpu) %(asm_relax)" ++#undef ASM_SPEC ++#define ASM_SPEC HARDENED_ASM_SPEC ++#endif ++#endif ++ + /* Same as sparc.h */ + #undef DBX_REGISTER_NUMBER + #define DBX_REGISTER_NUMBER(REGNO) (REGNO) +--- gcc-3.3.5/gcc/config/sparc/linux64.h.def~ Tue Nov 30 16:02:43 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux64.h Tue Nov 30 16:27:28 2004 +@@ -53,9 +53,15 @@ + provides part of the support for getting C++ file-scope static + object constructed before entering `main'. */ + ++#undef HARDENED_STARTFILE_SPEC + #undef STARTFILE_SPEC + + #ifdef HAVE_LD_PIE ++#define HARDENED_STARTFILE_SPEC "\ ++%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{!nopie:Scrt1.o%s}%{nopie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{!nopie:crtbeginS.o%s}%{nopie:crtbegin.o%s}} }" + #define STARTFILE_SPEC "\ + %{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ + %{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ +@@ -74,9 +80,14 @@ + object constructed before entering `main', followed by a normal + GNU/Linux "finalizer" file, `crtn.o'. */ + ++#undef HARDENED_ENDFILE_SPEC + #undef ENDFILE_SPEC + + #ifdef HAVE_LD_PIE ++#define HARDENED_ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{!nopie:crtendS.o%s}%{nopie:crtend.o%s}} } crtn.o%s \ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" + #define ENDFILE_SPEC "\ + %{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ + %{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s \ +@@ -278,6 +289,24 @@ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) %(asm_relax)" + ++#ifdef HAVE_LD_PIE ++#if defined(EFAULT_PIE) || defined(EFAULT_PIE_SSP) ++#define HARDENED_ASM_SPEC "\ ++%{V} \ ++%{v:%{!V:-V}} \ ++%{!Qn:-Qy} \ ++%{n} \ ++%{T} \ ++%{Ym,*} \ ++%{Wa,*:%*} \ ++-s %{!D__KERNEL__: %{!fno-PIC:%{!fno-pic:%{!fno-PIE:%{!fno-pie: %{!nopie:-K PIC} }}}} } \ ++%{mlittle-endian:-EL} \ ++%(asm_cpu) %(asm_arch) %(asm_relax)" ++#undef ASM_SPEC ++#define ASM_SPEC HARDENED_ASM_SPEC ++#endif ++#endif ++ + /* Same as sparc.h */ + #undef DBX_REGISTER_NUMBER + #define DBX_REGISTER_NUMBER(REGNO) (REGNO) diff --git a/3.3.6/pie/nondef/02_all_gcc-3.3.5-v8.7.1-pie-rs6000-nondefault.patch b/3.3.6/pie/nondef/02_all_gcc-3.3.5-v8.7.1-pie-rs6000-nondefault.patch new file mode 100644 index 0000000..be20397 --- /dev/null +++ b/3.3.6/pie/nondef/02_all_gcc-3.3.5-v8.7.1-pie-rs6000-nondefault.patch @@ -0,0 +1,11 @@ +--- gcc-3.3.5/gcc/config/rs6000/sysv4.h.nondef~ Thu Nov 18 22:18:50 2004 ++++ gcc-3.3.5/gcc/config/rs6000/sysv4.h Thu Nov 18 22:18:50 2004 +@@ -831,7 +831,7 @@ + #define ASM_SPEC "%(asm_cpu) \ + %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \ + %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ +-%{mrelocatable} %{mrelocatable-lib} %{fpic|fPIC|fpie|fPIE:-K PIC} \ ++%{mrelocatable} %{mrelocatable-lib} %{fpic|fPIC|fpie|fPIE|pie:-K PIC} \ + %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \ + %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \ + %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ diff --git a/3.3.6/pie/nondef/03_all_gcc-3.3.5-v8.7.6.7-pie-sparc-nondefault.patch b/3.3.6/pie/nondef/03_all_gcc-3.3.5-v8.7.6.7-pie-sparc-nondefault.patch new file mode 100644 index 0000000..5903c32 --- /dev/null +++ b/3.3.6/pie/nondef/03_all_gcc-3.3.5-v8.7.6.7-pie-sparc-nondefault.patch @@ -0,0 +1,22 @@ +--- gcc-3.3.5/gcc/config/sparc/linux.h.nondef~ Fri Nov 19 08:53:00 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux.h Fri Nov 19 08:54:51 2004 +@@ -227,7 +227,7 @@ + #undef ASM_SPEC + #define ASM_SPEC \ + "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ +- %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)" ++ %{fpic|fPIC|fpie|fPIE|pie:-K PIC} %(asm_cpu) %(asm_relax)" + + /* Same as sparc.h */ + #undef DBX_REGISTER_NUMBER +--- gcc-3.3.5/gcc/config/sparc/linux64.h.nondef~ Fri Nov 19 08:53:10 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux64.h Fri Nov 19 08:55:03 2004 +@@ -285,7 +285,7 @@ + %{T} \ + %{Ym,*} \ + %{Wa,*:%*} \ +--s %{fpic|fPIC|fpie|fPIE:-K PIC} \ ++-s %{fpic|fPIC|fpie|fPIE|pie:-K PIC} \ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) %(asm_relax)" + diff --git a/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-no.patch b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-no.patch new file mode 100644 index 0000000..0cd86a6 --- /dev/null +++ b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-no.patch @@ -0,0 +1,13 @@ +--- gcc-3.3.2/gcc/gcc.c.pie 2003-08-11 01:11:26.000000000 +0200 ++++ gcc-3.3.2/gcc/gcc.c 2003-12-15 16:03:40.000000000 +0100 +@@ -631,8 +639,8 @@ proper position among the other output f + #ifndef LINK_COMMAND_SPEC + #define LINK_COMMAND_SPEC "\ + %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ +- %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t}\ +- %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ ++ %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ ++ %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ + %{static:} %{L*} %(link_libgcc) %o %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\ + %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}" + #endif diff --git a/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-yes.patch b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-yes.patch new file mode 100644 index 0000000..b0b2acb --- /dev/null +++ b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3-boundschecking-yes.patch @@ -0,0 +1,13 @@ +--- gcc-3.3.2/gcc/gcc.c.pie 2003-08-11 01:11:26.000000000 +0200 ++++ gcc-3.3.2/gcc/gcc.c 2003-12-15 16:03:40.000000000 +0100 +@@ -631,8 +639,8 @@ proper position among the other output f + #ifndef LINK_COMMAND_SPEC + #define LINK_COMMAND_SPEC "\ + %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ +- %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t}\ +- %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ ++ %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ ++ %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ + %{static:} %{L*} %(link_libgcc) %o\ + %{!symbolic:%{!shared:%{fbounds-checking:libboundscheck.a%s}}}\ + %{!symbolic:%{!shared:%{fbc-strings-only:libboundscheck.a%s}}}\ diff --git a/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3.patch b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3.patch new file mode 100644 index 0000000..9b4b2cb --- /dev/null +++ b/3.3.6/pie/upstream/00_all_gcc-3.3-pie-3.patch @@ -0,0 +1,890 @@ +Submitted By: Robert Connolly <cendres at videotron dot ca> (ashes) +Date: 2004-02-02 +Initial Package Version: 3.3 +Origin: gcc-3.3.1-4mdk.src.rpm - gcc33-pie.patch.bz2 +http://cvs.mandrakesoft.com/cgi-bin/cvsweb.cgi/SPECS/gcc/gcc33-pie.patch +http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00140.html +Description: This is a gcc-3.4 backport for pie/fpie/fPIE support. +This is usefull mainly for Pax. http://pax.grsecurity.net/ +https://twocents.mooo.com/hints/downloads/files/winter.txt + +There is a workgroup using this patch. Comments and questions can be sent to +hlfs-dev@linuxfromscratch.org + +2003-06-03 Jakub Jelinek <jakub@redhat.com> + + * configure.in (HAVE_LD_PIE): Check for ld -pie. + * config.in: Rebuilt. + * configure: Rebuilt. + * toplev.c (flag_pie, flag_shlib): New variables. + (f_options): Add -fpie and -fPIE. + (parse_options_and_default_flags): Set flag_pic if -fpie/-fPIE. + Set flag_shlib if flag_pic and not -fpie/-fPIE. + * flags.h (flag_pic, flag_shlib): Add. + * varasm.c (default_binds_local_p): Use flag_shlib instead of + flag_pic. + * gcc.c (LINK_PIE_SPEC): Define. + (LINK_COMMAND_SPEC): Use LINK_PIE_SPEC. + (option_map): Add --pie -> -pie mapping. + * config/sol2.h (ASM_SPEC): Handle -fpie the same way as -fpic + and -fPIE the same way as -fPIC. + * config/openbsd.h (ASM_SPEC): Likewise. + * config/frv/frv.h (ASM_SPEC): Likewise. + * config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Likewise. + * config/arm/semi.h (ASM_SPEC): Likewise. + * config/arm/netbsd-elf.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise. + * config/freebsd-spec.h (FBSD_CPP_SPEC): Likewise. + * config/i386/beos-elf.h (CC1_SPEC): Likewise. + * config/i386/freebsd-aout.h (ASM_SPEC): Likewise. + * config/i386/sco5.h (CPP_SPEC, LINK_SPEC): Likewise. + * config/m68k/linux.h (CPP_SPEC): Likewise. + * config/m68k/linux-aout.h (ASM_SPEC): Likewise. + * config/m68k/netbsd.h (ASM_SPEC): Likewise. + * config/m68k/openbsd.h (ASM_SPEC): Likewise. + * config/m68k/netbsd-elf.h (ASM_SPEC): Likewise. + * config/m68k/sun2.h (ASM_SPEC): Likewise. + * config/m68k/sun3.h (ASM_SPEC): Likewise. + * config/mips/linux.h (SUBTARGET_CPP_SPEC): Likewise. + * config/mips/openbsd.h (SUBTARGET_ASM_SPEC): Likewise. + * config/pa/pa-linux.h (CPP_SPEC): Likewise. + * config/netbsd-aout.h (ASM_SPEC): Likewise. + * config/rs6000/sysv4.h (ASM_SPEC): Likewise. + * config/rs6000/linux64.h (ASM_SPEC32): Likewise. + * config/sparc/linux.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise. + * config/sparc/linux64.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise. + * config/sparc/sparc.h (ASM_SPEC): Likewise. + * config/sparc/sp64-elf.h (ASM_SPEC): Likewise. + * config/sparc/sysv4.h (ASM_SPEC): Likewise. + * config/sparc/netbsd-elf.h (ASM_SPEC): Likewise. + * config/sparc/openbsd64.h (ASM_SPEC): Likewise. + * config/sparc/hal.h (ASM_SPEC): Likewise. + * config/sparc/linux-aout.h (ASM_SPEC, CPP_SUBTARGET_SPEC): Likewise. + * config/sparc/vxsim.h (ASM_SPEC): Likewise. + * config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise. + * config/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Handle -pie. + * config/alpha/elf.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise. + * config/ia64/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise. + * config/rs6000/sysv4.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise. + * config/sparc/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise. + * config/sparc/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise. + * config/i386/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Remove. + * doc/invoke.texi: Document -pie, -fpie and -fPIE options. + +--- gcc-3.3.2/gcc/config/alpha/elf.h.pie 2003-12-15 16:03:35.000000000 +0100 ++++ gcc-3.3.2/gcc/config/alpha/elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -409,11 +409,19 @@ void FN () \ + before entering `main'. */ + + #undef STARTFILE_SPEC ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared: \ ++ %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ ++ crti.o%s %{static:crtbeginT.o%s}\ ++ %{!static:%{shared|pie:crtbeginS.o%s}%{!shared:%{!pie:crtbegin.o%s}}}" ++#else + #define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ + crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}}" ++ %{!static:%{shared|pie:crtbeginS.o%s}%{!shared:%{!pie:crtbegin.o%s}}}" ++#endif + + /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the + magical crtend.o file which provides part of the support for +@@ -423,7 +431,7 @@ void FN () \ + #undef ENDFILE_SPEC + #define ENDFILE_SPEC \ + "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s" ++ %{shared|pie:crtendS.o%s}%{!shared:%{!pie:crtend.o%s}} crtn.o%s" + + /* We support #pragma. */ + #define HANDLE_SYSV_PRAGMA 1 +--- gcc-3.3.2/gcc/config/arm/linux-gas.h.pie 2002-09-15 20:24:04.000000000 +0200 ++++ gcc-3.3.2/gcc/config/arm/linux-gas.h 2003-12-15 16:03:40.000000000 +0100 +@@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA. */ + #define DEFAULT_SIGNED_CHAR 0 + + #undef SUBTARGET_CPP_SPEC +-#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}" ++#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{fPIC|fPIE:-D__PIC__ -D__pic__} %{fpic|fpie:-D__PIC__ -D__pic__}" + + #undef SIZE_TYPE + #define SIZE_TYPE "unsigned int" +--- gcc-3.3.2/gcc/config/arm/semi.h.pie 2002-05-20 19:07:04.000000000 +0200 ++++ gcc-3.3.2/gcc/config/arm/semi.h 2003-12-15 16:03:40.000000000 +0100 +@@ -59,7 +59,7 @@ Boston, MA 02111-1307, USA. */ + binutils can't. */ + #ifndef ASM_SPEC + #define ASM_SPEC "\ +-%{fpic: -k} %{fPIC: -k} \ ++%{fpic|fpie: -k} %{fPIC|fPIE: -k} \ + %{mbig-endian:-EB} \ + %{mcpu=*:-mcpu=%*} \ + %{march=*:-march=%*} \ +--- gcc-3.3.2/gcc/config/arm/netbsd-elf.h.pie 2002-11-21 22:39:17.000000000 +0100 ++++ gcc-3.3.2/gcc/config/arm/netbsd-elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -59,7 +59,7 @@ Boston, MA 02111-1307, USA. */ + + #undef SUBTARGET_EXTRA_ASM_SPEC + #define SUBTARGET_EXTRA_ASM_SPEC \ +- "-matpcs %{fpic:-k} %{fPIC:-k}" ++ "-matpcs %{fpic|fpie:-k} %{fPIC|fPIE:-k}" + + /* Default floating point model is soft-VFP. + FIXME: -mhard-float currently implies FPA. */ +--- gcc-3.3.2/gcc/config/cris/linux.h.pie 2003-03-11 04:01:35.000000000 +0100 ++++ gcc-3.3.2/gcc/config/cris/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */ + #define CRIS_ASM_SUBTARGET_SPEC \ + "--em=criself\ + %{!fleading-underscore:--no-underscore}\ +- %{fPIC|fpic: --pic}" ++ %{fPIC|fpic|fPIE|fpie: --pic}" + + /* Provide a legacy -mlinux option. */ + #undef CRIS_SUBTARGET_SWITCHES +--- gcc-3.3.2/gcc/config/frv/frv.h.pie 2003-12-15 16:03:35.000000000 +0100 ++++ gcc-3.3.2/gcc/config/frv/frv.h 2003-12-15 16:03:40.000000000 +0100 +@@ -86,7 +86,7 @@ + %{mmedia} %{mno-media} \ + %{mmuladd} %{mno-muladd} \ + %{mpack} %{mno-pack} \ +- %{fpic: -mpic} %{fPIC: -mPIC} %{mlibrary-pic}}" ++ %{fpic|fpie: -mpic} %{fPIC|fPIE: -mPIC} %{mlibrary-pic}}" + + /* Another C string constant used much like `LINK_SPEC'. The difference + between the two is that `STARTFILE_SPEC' is used at the very beginning of +--- gcc-3.3.2/gcc/config/i386/beos-elf.h.pie 2002-11-15 15:57:11.000000000 +0100 ++++ gcc-3.3.2/gcc/config/i386/beos-elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -79,7 +79,7 @@ Boston, MA 02111-1307, USA. */ + CC1_SPEC is used for both cc1 and cc1plus. */ + + #undef CC1_SPEC +-#define CC1_SPEC "%{!no-fpic:%{!fPIC:-fpic}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" ++#define CC1_SPEC "%{!no-fpic:%{!fno-pic:%{!fno-pie:%{!fpie:%{!fPIC:%{!fPIE:-fpic}}}}}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" + + #undef CC1PLUS_SPEC + #define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}" +--- gcc-3.3.2/gcc/config/i386/freebsd-aout.h.pie 2003-04-29 14:57:06.000000000 +0200 ++++ gcc-3.3.2/gcc/config/i386/freebsd-aout.h 2003-12-15 16:03:40.000000000 +0100 +@@ -208,7 +208,7 @@ do { + ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ + } while (0) + +-#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}" ++#define ASM_SPEC " %| %{fpic|fPIC|fpie|fPIE:-k}" + #define LINK_SPEC \ + "%{p:%e`-p' not supported; use `-pg' and gprof(1)} \ + %{shared:-Bshareable} \ +--- gcc-3.3.2/gcc/config/i386/linux64.h.pie 2003-12-15 16:03:35.000000000 +0100 ++++ gcc-3.3.2/gcc/config/i386/linux64.h 2003-12-15 16:03:40.000000000 +0100 +@@ -71,17 +71,6 @@ Boston, MA 02111-1307, USA. */ + %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \ + %{static:-static}}" + +-#undef STARTFILE_SPEC +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} \ +- crti.o%s %{static:crtbeginT.o%s} \ +- %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" +- +-#undef ENDFILE_SPEC +-#define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" +- + #define MULTILIB_DEFAULTS { "m64" } + + #define SUBTARGET_FILE_END(FILE) \ +--- gcc-3.3.2/gcc/config/ia64/linux.h.pie 2003-12-15 16:03:39.000000000 +0100 ++++ gcc-3.3.2/gcc/config/ia64/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -21,18 +21,27 @@ do { \ + + /* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */ + #undef STARTFILE_SPEC ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared: \ ++ %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++ %{!p:%{profile:gcrt1.o%s} \ ++ %{!profile:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}} \ ++ crti.o%s %{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}" ++#else + #define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ + %{!p:%{profile:gcrt1.o%s} \ + %{!profile:crt1.o%s}}}} \ +- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" ++ crti.o%s %{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}" ++#endif + + /* Similar to standard Linux, but adding -ffast-math support. */ + #undef ENDFILE_SPEC + #define ENDFILE_SPEC \ + "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++ %{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" + + /* Define this for shared library support because it isn't in the main + linux.h file. */ +--- gcc-3.3.2/gcc/config/m68k/linux.h.pie 2003-12-15 16:03:36.000000000 +0100 ++++ gcc-3.3.2/gcc/config/m68k/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -119,18 +119,18 @@ Boston, MA 02111-1307, USA. */ + #ifdef USE_GNULIBC_1 + #if TARGET_DEFAULT & MASK_68881 + #define CPP_SPEC \ +- "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}" ++ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}" + #else + #define CPP_SPEC \ +- "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}" ++ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}" + #endif + #else + #if TARGET_DEFAULT & MASK_68881 + #define CPP_SPEC \ +- "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" ++ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" + #else + #define CPP_SPEC \ +- "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" ++ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" + #endif + #endif + +--- gcc-3.3.2/gcc/config/m68k/netbsd.h.pie 2002-08-29 23:40:13.000000000 +0200 ++++ gcc-3.3.2/gcc/config/m68k/netbsd.h 2003-12-15 16:03:40.000000000 +0100 +@@ -31,7 +31,7 @@ + "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %(netbsd_cpp_spec)" + + #undef ASM_SPEC +-#define ASM_SPEC " %| %{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}" ++#define ASM_SPEC " %| %{m68030} %{m68040} %{m68060} %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" + + + /* Make gcc agree with <machine/ansi.h> */ +--- gcc-3.3.2/gcc/config/m68k/sun2.h.pie 2002-08-29 23:40:13.000000000 +0200 ++++ gcc-3.3.2/gcc/config/m68k/sun2.h 2003-12-15 16:03:40.000000000 +0100 +@@ -40,7 +40,7 @@ Boston, MA 02111-1307, USA. */ + + #define ASM_SPEC \ + "%{m68020:-mc68020}%{mc68020:-mc68020}%{!mc68020:%{!m68020:-mc68010}} \ +- %{fpic:-k} %{fPIC:-k} %{R} %{j} %{J} %{h} %{d2} %{keep-local-as-symbols:-L}" ++ %{fpic|fPIC|fpie|fPIE:-k} %{R} %{j} %{J} %{h} %{d2} %{keep-local-as-symbols:-L}" + + /* Names to predefine in the preprocessor for this target machine. */ + +--- gcc-3.3.2/gcc/config/m68k/openbsd.h.pie 2002-10-21 00:37:11.000000000 +0200 ++++ gcc-3.3.2/gcc/config/m68k/openbsd.h 2003-12-15 16:03:40.000000000 +0100 +@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */ + + /* m68k as needs to know about the processor subtype. */ + #undef ASM_SPEC +-#define ASM_SPEC "%| %{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}" ++#define ASM_SPEC "%| %{m68030} %{m68040} %{m68060} %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" + + /* Layout of source language data types. */ + +--- gcc-3.3.2/gcc/config/m68k/linux-aout.h.pie 2002-08-29 23:40:13.000000000 +0200 ++++ gcc-3.3.2/gcc/config/m68k/linux-aout.h 2003-12-15 16:03:40.000000000 +0100 +@@ -46,7 +46,7 @@ Boston, MA 02111-1307, USA. */ + + #undef ASM_SPEC + #define ASM_SPEC \ +- "%{m68030} %{m68040} %{fpic:-k} %{fPIC:-k}" ++ "%{m68030} %{m68040} %{fpic|fPIC|fpie|fPIE:-k}" + + #undef LIB_SPEC + #if 1 +--- gcc-3.3.2/gcc/config/m68k/netbsd-elf.h.pie 2003-12-15 16:03:36.000000000 +0100 ++++ gcc-3.3.2/gcc/config/m68k/netbsd-elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -105,7 +105,7 @@ Boston, MA 02111-1307, USA. */ + #define ASM_SPEC \ + " %| %(asm_default_spec) \ + %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \ +- %{fpic:-k} %{fPIC:-k -K}" ++ %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" + + /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */ + +--- gcc-3.3.2/gcc/config/m68k/sun3.h.pie 2002-10-16 02:40:33.000000000 +0200 ++++ gcc-3.3.2/gcc/config/m68k/sun3.h 2003-12-15 16:03:40.000000000 +0100 +@@ -80,7 +80,7 @@ Boston, MA 02111-1307, USA. */ + + #define ASM_SPEC \ + "%{m68000:-mc68010}%{mc68000:-mc68010}%{!mc68000:%{!m68000:-mc68020}} \ +- %{fpic:-k} %{fPIC:-k} %{R} %{j} %{J} %{h} %{d2} %{keep-local-as-symbols:-L}" ++ %{fpic|fPIC|fpie|fPIE:-k} %{R} %{j} %{J} %{h} %{d2} %{keep-local-as-symbols:-L}" + + /* Names to predefine in the preprocessor for this target machine. */ + /* For a while, -D_CROSS_TARGET_ARCH=SUN3 was included here, +--- gcc-3.3.2/gcc/config/mips/linux.h.pie 2003-05-08 19:31:34.000000000 +0200 ++++ gcc-3.3.2/gcc/config/mips/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -164,7 +164,7 @@ void FN () \ + #undef SUBTARGET_CPP_SPEC + #define SUBTARGET_CPP_SPEC "\ + %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \ +-%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \ ++%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \ + %{pthread:-D_REENTRANT}" + + /* From iris5.h */ +--- gcc-3.3.2/gcc/config/mips/openbsd.h.pie 2002-06-11 09:26:38.000000000 +0200 ++++ gcc-3.3.2/gcc/config/mips/openbsd.h 2003-12-15 16:03:40.000000000 +0100 +@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA. */ + /* Definitions needed for OpenBSD, to avoid picking mips 'defaults'. */ + + /* GAS must know this. */ +-#define SUBTARGET_ASM_SPEC "%{fPIC:-KPIC} %|" ++#define SUBTARGET_ASM_SPEC "%{fPIC|fPIE:-KPIC} %|" + + /* CPP specific OpenBSD specs. */ + #define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC +--- gcc-3.3.2/gcc/config/pa/pa-linux.h.pie 2002-12-10 11:55:31.000000000 +0100 ++++ gcc-3.3.2/gcc/config/pa/pa-linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -67,7 +67,7 @@ Boston, MA 02111-1307, USA. */ + while (0) + + #undef CPP_SPEC +-#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" ++#define CPP_SPEC "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" + + #undef LIB_SPEC + #define LIB_SPEC \ +--- gcc-3.3.2/gcc/config/rs6000/sysv4.h.pie 2003-12-15 16:03:36.000000000 +0100 ++++ gcc-3.3.2/gcc/config/rs6000/sysv4.h 2003-12-15 16:03:40.000000000 +0100 +@@ -816,7 +816,7 @@ do { \ + #define ASM_SPEC "%(asm_cpu) \ + %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \ + %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ +-%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \ ++%{mrelocatable} %{mrelocatable-lib} %{fpic|fPIC|fpie|fPIE:-K PIC} \ + %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \ + %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \ + %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ +@@ -1132,14 +1132,22 @@ do { \ + %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ + %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else ++#if defined HAVE_LD_PIE ++#define STARTFILE_LINUX_SPEC "\ ++%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}} \ ++%{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ ++%{static:crtbeginT.o%s} \ ++%{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#else + #define STARTFILE_LINUX_SPEC "\ + %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \ + %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ + %{static:crtbeginT.o%s} \ +-%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" ++%{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#endif + #endif + +-#define ENDFILE_LINUX_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \ ++#define ENDFILE_LINUX_SPEC "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} \ + %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}" + + #define LINK_START_LINUX_SPEC "" +--- gcc-3.3.2/gcc/config/sparc/hal.h.pie 1999-09-04 17:09:00.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/hal.h 2003-12-15 16:03:40.000000000 +0100 +@@ -25,7 +25,7 @@ Boston, MA 02111-1307, USA. */ + #undef ASM_SPEC + #define ASM_SPEC \ + "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -e1 \ +- %{fpic:-K PIC} %{fPIC:-K PIC}" ++ %{fpic|fpie|fPIC|fPIE:-K PIC}" + + /* Need DWARF for debuggers. */ + +--- gcc-3.3.2/gcc/config/sparc/linux-aout.h.pie 2002-11-26 05:54:49.000000000 +0100 ++++ gcc-3.3.2/gcc/config/sparc/linux-aout.h 2003-12-15 16:03:40.000000000 +0100 +@@ -64,7 +64,7 @@ Boston, MA 02111-1307, USA. */ + + #undef CPP_SUBTARGET_SPEC + #define CPP_SUBTARGET_SPEC \ +-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" ++"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" + + /* Don't default to pcc-struct-return, because gcc is the only compiler, + and we want to retain compatibility with older gcc versions. */ +@@ -92,5 +92,5 @@ Boston, MA 02111-1307, USA. */ + It's safe to pass -s always, even if -g is not used. */ + #undef ASM_SPEC + #define ASM_SPEC \ +- "%{V} %{v:%{!V:-V}} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}" ++ "%{V} %{v:%{!V:-V}} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic|fpie|fPIC|fPIE:-K PIC}" + +--- gcc-3.3.2/gcc/config/sparc/linux.h.pie 2003-12-15 16:03:37.000000000 +0100 ++++ gcc-3.3.2/gcc/config/sparc/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -47,11 +47,19 @@ Boston, MA 02111-1307, USA. */ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else ++#if defined HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared: \ ++ %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ ++ crti.o%s %{static:crtbeginT.o%s}\ ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#else + #define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ + crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#endif + #endif + + /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on +@@ -63,7 +71,7 @@ Boston, MA 02111-1307, USA. */ + #undef ENDFILE_SPEC + #define ENDFILE_SPEC \ + "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++ %{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" + + /* This is for -profile to use -lc_p instead of -lc. */ + #undef CC1_SPEC +@@ -104,11 +112,11 @@ Boston, MA 02111-1307, USA. */ + #undef CPP_SUBTARGET_SPEC + #ifdef USE_GNULIBC_1 + #define CPP_SUBTARGET_SPEC \ +-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ ++"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ + %{mlong-double-128:-D__LONG_DOUBLE_128__}" + #else + #define CPP_SUBTARGET_SPEC \ +-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ ++"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ + %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}" + #endif + +@@ -184,8 +192,8 @@ Boston, MA 02111-1307, USA. */ + It's safe to pass -s always, even if -g is not used. */ + #undef ASM_SPEC + #define ASM_SPEC \ +- "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} \ +- %{fPIC:-K PIC} %(asm_cpu) %(asm_relax)" ++ "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ ++ %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)" + + /* Same as sparc.h */ + #undef DBX_REGISTER_NUMBER +--- gcc-3.3.2/gcc/config/sparc/linux64.h.pie 2003-12-15 16:03:37.000000000 +0100 ++++ gcc-3.3.2/gcc/config/sparc/linux64.h 2003-12-15 16:03:40.000000000 +0100 +@@ -55,10 +55,17 @@ Boston, MA 02111-1307, USA. */ + + #undef STARTFILE_SPEC + ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ ++ crti.o%s %{static:crtbeginT.o%s}\ ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#else + #define STARTFILE_SPEC \ + "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ + crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#endif + + /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on + the GNU/Linux magical crtend.o file (see crtstuff.c) which +@@ -69,7 +76,7 @@ Boston, MA 02111-1307, USA. */ + #undef ENDFILE_SPEC + + #define ENDFILE_SPEC \ +- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s\ ++ "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s\ + %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" + + /* The GNU C++ standard library requires that these macros be defined. */ +@@ -116,8 +123,7 @@ Boston, MA 02111-1307, USA. */ + + #undef CPP_SUBTARGET_SPEC + #define CPP_SUBTARGET_SPEC "\ +-%{fPIC:-D__PIC__ -D__pic__} \ +-%{fpic:-D__PIC__ -D__pic__} \ ++%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \ + %{posix:-D_POSIX_SOURCE} \ + %{pthread:-D_REENTRANT} \ + " +@@ -246,7 +252,7 @@ Boston, MA 02111-1307, USA. */ + %{T} \ + %{Ym,*} \ + %{Wa,*:%*} \ +--s %{fpic:-K PIC} %{fPIC:-K PIC} \ ++-s %{fpic|fPIC|fpie|fPIE:-K PIC} \ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) %(asm_relax)" + +--- gcc-3.3.2/gcc/config/sparc/netbsd-elf.h.pie 2002-10-19 01:10:35.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/netbsd-elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -96,7 +96,7 @@ Boston, MA 02111-1307, USA. */ + #define USER_LABEL_PREFIX "" + + #undef ASM_SPEC +-#define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} %{V} %{v:%{!V:-V}} \ ++#define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %{V} %{v:%{!V:-V}} \ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) %(asm_relax)" + +--- gcc-3.3.2/gcc/config/sparc/openbsd64.h.pie 2002-05-30 22:35:58.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/openbsd64.h 2003-12-15 16:03:40.000000000 +0100 +@@ -42,7 +42,7 @@ Boston, MA 02111-1307, USA. */ + + #undef ASM_SPEC + #define ASM_SPEC "\ +-%{v:-V} -s %{fpic:-K PIC} %{fPIC:-K PIC} \ ++%{v:-V} -s %{fpic|fPIC|fpie|fPIE:-K PIC} \ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) \ + " +--- gcc-3.3.2/gcc/config/sparc/sp64-elf.h.pie 2002-08-29 23:40:18.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/sp64-elf.h 2003-12-15 16:03:40.000000000 +0100 +@@ -50,7 +50,7 @@ Boston, MA 02111-1307, USA. */ + + #undef ASM_SPEC + #define ASM_SPEC "\ +-%{v:-V} -s %{fpic:-K PIC} %{fPIC:-K PIC} \ ++%{v:-V} -s %{fpic|fPIC|fpie|fPIE:-K PIC} \ + %{mlittle-endian:-EL} \ + %(asm_cpu) %(asm_arch) \ + " +--- gcc-3.3.2/gcc/config/sparc/sparc.h.pie 2003-12-15 16:03:37.000000000 +0100 ++++ gcc-3.3.2/gcc/config/sparc/sparc.h 2003-12-15 16:03:40.000000000 +0100 +@@ -323,7 +323,7 @@ extern enum cmodel sparc_cmodel; + /* Special flags to the Sun-4 assembler when using pipe for input. */ + + #define ASM_SPEC "\ +-%| %{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \ ++%| %{R} %{!pg:%{!p:%{fpic|fPIC|fpie|fPIE:-k}}} %{keep-local-as-symbols:-L} \ + %(asm_cpu) %(asm_relax)" + + /* This macro defines names of additional specifications to put in the specs +--- gcc-3.3.2/gcc/config/sparc/sysv4.h.pie 2002-09-15 14:03:42.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/sysv4.h 2003-12-15 16:03:40.000000000 +0100 +@@ -66,7 +66,7 @@ Boston, MA 02111-1307, USA. */ + #undef ASM_SPEC + #define ASM_SPEC \ + "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ +- %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)" ++ %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)" + + /* Define the names of various pseudo-op used by the SPARC/svr4 assembler. + Note that many of these are different from the typical pseudo-ops used +--- gcc-3.3.2/gcc/config/sparc/vxsim.h.pie 2002-09-15 14:03:42.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sparc/vxsim.h 2003-12-15 16:03:40.000000000 +0100 +@@ -40,7 +40,7 @@ Boston, MA 02111-1307, USA. */ + #undef ASM_SPEC + #define ASM_SPEC \ + "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ +- %{fpic:-K PIC} %{fPIC:-K PIC}" ++ %{fpic|fpie|fPIC|fPIE:-K PIC}" + + /* However it appears that Solaris 2.0 uses the same reg numbering as + the old BSD-style system did. */ +--- gcc-3.3.2/gcc/config/sol2.h.pie 2002-06-20 13:03:37.000000000 +0200 ++++ gcc-3.3.2/gcc/config/sol2.h 2003-12-15 16:03:40.000000000 +0100 +@@ -79,7 +79,7 @@ Boston, MA 02111-1307, USA. */ + #undef ASM_SPEC + #define ASM_SPEC "\ + %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ +-%{fpic:-K PIC} %{fPIC:-K PIC} \ ++%{fpic|fpie|fPIC|fPIE:-K PIC} \ + %(asm_cpu) \ + " + +--- gcc-3.3.2/gcc/config/openbsd.h.pie 2002-11-26 05:54:46.000000000 +0100 ++++ gcc-3.3.2/gcc/config/openbsd.h 2003-12-15 16:03:40.000000000 +0100 +@@ -106,7 +106,7 @@ Boston, MA 02111-1307, USA. */ + still uses a special flavor of gas that needs to be told when generating + pic code. */ + #undef ASM_SPEC +-#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K} %|" ++#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K} %|" + + #else + /* Since we use gas, stdin -> - is a good idea, but we don't want to +--- gcc-3.3.2/gcc/config/linux.h.pie 2003-09-16 17:39:22.000000000 +0200 ++++ gcc-3.3.2/gcc/config/linux.h 2003-12-15 16:03:40.000000000 +0100 +@@ -54,13 +54,23 @@ Boston, MA 02111-1307, USA. */ + %{!profile:crt1.o%s}}}} \ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else ++#if defined HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared: \ ++ %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++ %{!p:%{profile:gcrt1.o%s} \ ++ %{!profile:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}} \ ++ crti.o%s %{static:crtbeginT.o%s}\ ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#else + #define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ + %{!p:%{profile:gcrt1.o%s} \ + %{!profile:crt1.o%s}}}} \ + crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" ++ %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#endif + #endif + + /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on +@@ -71,7 +81,7 @@ Boston, MA 02111-1307, USA. */ + + #undef ENDFILE_SPEC + #define ENDFILE_SPEC \ +- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++ "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" + + /* This is for -profile to use -lc_p instead of -lc. */ + #ifndef CC1_SPEC +--- gcc-3.3.2/gcc/config/freebsd-spec.h.pie 2003-03-12 03:38:01.000000000 +0100 ++++ gcc-3.3.2/gcc/config/freebsd-spec.h 2003-12-15 16:03:40.000000000 +0100 +@@ -79,7 +79,7 @@ Boston, MA 02111-1307, USA. */ + + #define FBSD_CPP_SPEC " \ + %(cpp_cpu) \ +- %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \ ++ %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \ + %{posix:-D_POSIX_SOURCE}" + + /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add +--- gcc-3.3.2/gcc/config/netbsd-aout.h.pie 2002-09-29 15:16:44.000000000 +0200 ++++ gcc-3.3.2/gcc/config/netbsd-aout.h 2003-12-15 16:03:40.000000000 +0100 +@@ -39,7 +39,7 @@ Boston, MA 02111-1307, USA. */ + with the options for generating PIC code. */ + + #undef ASM_SPEC +-#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}" ++#define ASM_SPEC " %| %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" + + + /* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we +--- gcc-3.3.2/gcc/doc/invoke.texi.pie 2003-12-15 16:03:38.000000000 +0100 ++++ gcc-3.3.2/gcc/doc/invoke.texi 2003-12-15 16:03:40.000000000 +0100 +@@ -304,7 +304,7 @@ in the following sections. + @item Linker Options + @xref{Link Options,,Options for Linking}. + @gccoptlist{@var{object-file-name} -l@var{library} @gol +--nostartfiles -nodefaultlibs -nostdlib @gol ++-nostartfiles -nodefaultlibs -nostdlib -pie @gol + -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol + -Wl,@var{option} -Xlinker @var{option} @gol + -u @var{symbol}} +@@ -656,7 +656,7 @@ in the following sections. + -fasynchronous-unwind-tables @gol + -finhibit-size-directive -finstrument-functions @gol + -fno-common -fno-ident -fno-gnu-linker @gol +--fpcc-struct-return -fpic -fPIC @gol ++-fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol + -freg-struct-return -fshared-data -fshort-enums @gol + -fshort-double -fshort-wchar -fvolatile @gol + -fvolatile-global -fvolatile-static @gol +@@ -4669,6 +4669,13 @@ library subroutines. (For example, @sam + constructors will be called; @pxref{Collect2,,@code{collect2}, gccint, + GNU Compiler Collection (GCC) Internals}.) + ++@item -pie ++@opindex pie ++Produce a position independent executable on targets which support it. ++For predictable results, you must also specify the same set of options ++that were used to generate code (@option{-fpie}, @option{-fPIE}, ++or model suboptions) when you specify this option. ++ + @item -s + @opindex s + Remove all symbol table and relocation information from the executable. +@@ -10831,6 +10838,15 @@ and the SPARC. + Position-independent code requires special support, and therefore works + only on certain machines. + ++@item -fpie ++@itemx -fPIE ++@opindex fpie ++@opindex fPIE ++These options are similar to @option{-fpic} and @option{-fPIC}, but ++generated position independent code can be only linked into executables. ++Usually these options are used when @option{-pie} GCC option will be ++used during linking. ++ + @item -ffixed-@var{reg} + @opindex ffixed + Treat the register named @var{reg} as a fixed register; generated code +--- gcc-3.3.2/gcc/toplev.c.pie 2003-12-15 16:03:39.000000000 +0100 ++++ gcc-3.3.2/gcc/toplev.c 2003-12-15 16:03:40.000000000 +0100 +@@ -759,6 +759,17 @@ int flag_delayed_branch; + + int flag_pic; + ++/* Nonzero if we are compiling position independent code for executable. ++ The value is 1 if we are doing "small" pic; value is 2 if we're doing ++ "large" pic. */ ++ ++int flag_pie; ++ ++/* Nonzero if we are compiling code for a shared library, zero for ++ executable. */ ++ ++int flag_shlib; ++ + /* Set to the default thread-local storage (tls) model to use. */ + + enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC; +@@ -1156,6 +1167,9 @@ static const lang_independent_options f_ + {"pic", &flag_pic, 1, + N_("Generate position independent code, if possible") }, + {"PIC", &flag_pic, 2, ""}, ++ {"pie", &flag_pie, 1, ++ N_("Generate position independent code for executables, if possible") }, ++ {"PIE", &flag_pie, 2, ""}, + {"exceptions", &flag_exceptions, 1, + N_("Enable exception handling") }, + {"unwind-tables", &flag_unwind_tables, 1, +@@ -5281,6 +5295,11 @@ parse_options_and_default_flags (argc, a + } + } + ++ if (flag_pie) ++ flag_pic = flag_pie; ++ if (flag_pic && !flag_pie) ++ flag_shlib = 1; ++ + if (flag_no_inline == 2) + flag_no_inline = 0; + else +--- gcc-3.3.2/gcc/flags.h.pie 2003-12-15 16:03:38.000000000 +0100 ++++ gcc-3.3.2/gcc/flags.h 2003-12-15 16:03:40.000000000 +0100 +@@ -484,6 +484,16 @@ extern int flag_pedantic_errors; + + extern int flag_pic; + ++/* Nonzero if we are compiling position independent code for executable. ++ 1 vs 2 for a target-dependent "small" or "large" mode. */ ++ ++extern int flag_pie; ++ ++/* Nonzero if we are compiling code for a shared library, zero for ++ executable. */ ++ ++extern int flag_shlib; ++ + /* Nonzero means generate extra code for exception handling and enable + exception handling. */ + +--- gcc-3.3.2/gcc/gcc.c.pie 2003-08-11 01:11:26.000000000 +0200 ++++ gcc-3.3.2/gcc/gcc.c 2003-12-15 16:03:40.000000000 +0100 +@@ -622,6 +622,14 @@ proper position among the other output f + #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G" + #endif + ++#ifndef LINK_PIE_SPEC ++#ifdef HAVE_LD_PIE ++#define LINK_PIE_SPEC "%{pie:-pie} " ++#else ++#define LINK_PIE_SPEC "%{pie:} " ++#endif ++#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. */ +@@ -957,6 +965,7 @@ static const struct option_map option_ma + {"--param", "--param", "a"}, + {"--pedantic", "-pedantic", 0}, + {"--pedantic-errors", "-pedantic-errors", 0}, ++ {"--pie", "-pie", 0}, + {"--pipe", "-pipe", 0}, + {"--prefix", "-B", "a"}, + {"--preprocess", "-E", 0}, +--- gcc-3.3.2/gcc/varasm.c.pie 2003-12-15 16:03:39.000000000 +0100 ++++ gcc-3.3.2/gcc/varasm.c 2003-12-15 16:03:40.000000000 +0100 +@@ -5485,7 +5485,7 @@ bool + default_binds_local_p (exp) + tree exp; + { +- return default_binds_local_p_1 (exp, flag_pic); ++ return default_binds_local_p_1 (exp, flag_shlib); + } + + bool +--- gcc-3.3.2/gcc/config.in.pie 2003-10-16 22:10:47.000000000 +0200 ++++ gcc-3.3.2/gcc/config.in 2003-12-15 16:03:40.000000000 +0100 +@@ -614,6 +614,9 @@ + /* Define if your linker supports --eh-frame-hdr option. */ + #undef HAVE_LD_EH_FRAME_HDR + ++/* Define if your linker supports -pie option. */ ++#undef HAVE_LD_PIE ++ + /* Define if your MIPS libgloss linker scripts consistently include STARTUP directives. */ + #undef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES + +--- gcc-3.3.2/gcc/configure.pie 2003-12-15 16:03:39.000000000 +0100 ++++ gcc-3.3.2/gcc/configure 2003-12-15 16:03:40.000000000 +0100 +@@ -8041,6 +8041,27 @@ EOF + fi + echo "$ac_t""$gcc_cv_ld_eh_frame_hdr" 1>&6 + ++echo $ac_n "checking linker position independent executable support""... $ac_c" 1>&6 ++echo "configure:8843: checking linker position independent executable support" >&5 ++gcc_cv_ld_pie=no ++if test x$gcc_cv_gld_major_version != x -a x$gcc_cv_gld_minor_version != x; then ++ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then ++ gcc_cv_ld_pie=yes ++ fi ++elif test x$gcc_cv_ld != x; then ++ # Check if linker supports -pie option ++ if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then ++ gcc_cv_ld_pie=yes ++ fi ++fi ++if test x"$gcc_cv_ld_pie" = xyes; then ++ cat >> confdefs.h <<\EOF ++#define HAVE_LD_PIE 1 ++EOF ++ ++fi ++echo "$ac_t""$gcc_cv_ld_pie" 1>&6 ++ + # Miscellaneous target-specific checks. + case "$target" in + mips*-*-*) +--- gcc-3.3.2/gcc/configure.in.pie 2003-12-15 16:03:39.000000000 +0100 ++++ gcc-3.3.2/gcc/configure.in 2003-12-15 16:03:40.000000000 +0100 +@@ -2393,6 +2393,24 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xye + fi + AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr) + ++AC_MSG_CHECKING(linker position independent executable support) ++gcc_cv_ld_pie=no ++if test x$gcc_cv_gld_major_version != x -a x$gcc_cv_gld_minor_version != x; then ++ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then ++ gcc_cv_ld_pie=yes ++ fi ++elif test x$gcc_cv_ld != x; then ++ # Check if linker supports -pie option ++ if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then ++ gcc_cv_ld_pie=yes ++ fi ++fi ++if test x"$gcc_cv_ld_pie" = xyes; then ++ AC_DEFINE(HAVE_LD_PIE, 1, ++[Define if your linker supports -pie option.]) ++fi ++AC_MSG_RESULT($gcc_cv_ld_pie) ++ + # Miscellaneous target-specific checks. + case "$target" in + mips*-*-*) diff --git a/3.3.6/pie/upstream/01_all_gcc-4.0-cvs-for-3.3.5-pic.patch b/3.3.6/pie/upstream/01_all_gcc-4.0-cvs-for-3.3.5-pic.patch new file mode 100644 index 0000000..e526608 --- /dev/null +++ b/3.3.6/pie/upstream/01_all_gcc-4.0-cvs-for-3.3.5-pic.patch @@ -0,0 +1,62 @@ +--- gcc-3.3.5/gcc/config/pa/pa-linux.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/pa/pa-linux.h Thu Nov 18 23:17:02 2004 +@@ -60,6 +60,11 @@ + builtin_define ("__gnu_linux__"); \ + builtin_define_std ("linux"); \ + builtin_define_std ("unix"); \ ++ if (flag_pic) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ + builtin_assert ("machine=bigendian"); \ + builtin_assert ("system=posix"); \ + builtin_assert ("system=unix"); \ +@@ -67,7 +72,7 @@ + while (0) + + #undef CPP_SPEC +-#define CPP_SPEC "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" ++#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" + + #undef LIB_SPEC + #define LIB_SPEC \ +--- gcc-3.3.5/gcc/config/arm/linux-gas.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/arm/linux-gas.h Thu Nov 18 23:11:39 2004 +@@ -31,7 +31,7 @@ + #define DEFAULT_SIGNED_CHAR 0 + + #undef SUBTARGET_CPP_SPEC +-#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{fPIC|fPIE:-D__PIC__ -D__pic__} %{fpic|fpie:-D__PIC__ -D__pic__}" ++#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE}" + + #undef SIZE_TYPE + #define SIZE_TYPE "unsigned int" +--- gcc-3.3.5/gcc/config/arm/linux-elf.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/arm/linux-elf.h Thu Nov 18 23:17:20 2004 +@@ -110,6 +110,11 @@ + builtin_define_std ("linux"); \ + builtin_define ("__gnu_linux__"); \ + builtin_define ("__ELF__"); \ ++ if (flag_pic) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ + builtin_assert ("system=unix"); \ + builtin_assert ("system=posix"); \ + } while (0) +--- gcc-3.3.5/gcc/config/alpha/linux.h.upstream~ Wed Oct 1 18:58:40 2003 ++++ gcc-3.3.5/gcc/config/alpha/linux.h Thu Nov 18 23:11:39 2004 +@@ -33,6 +33,11 @@ + /* The GNU C++ standard library requires this. */ \ + if (c_language == clk_cplusplus) \ + builtin_define ("_GNU_SOURCE"); \ ++ if (flag_pic) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ + } while (0) + + #undef LIB_SPEC diff --git a/3.3.6/pie/upstream/02_all_gcc-4.0-cvs-mips-pic.patch b/3.3.6/pie/upstream/02_all_gcc-4.0-cvs-mips-pic.patch new file mode 100644 index 0000000..ccb56f2 --- /dev/null +++ b/3.3.6/pie/upstream/02_all_gcc-4.0-cvs-mips-pic.patch @@ -0,0 +1,40 @@ +--- gcc-3.3.5/gcc/config/mips/linux.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/mips/linux.h Thu Nov 18 23:11:39 2004 +@@ -121,8 +121,11 @@ + do { \ + builtin_define ("__gnu_linux__"); \ + builtin_define ("__ELF__"); \ +- builtin_define ("__PIC__"); \ +- builtin_define ("__pic__"); \ ++ if (TARGET_ABICALLS) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ + builtin_define_std ("unix"); \ + builtin_define_std ("linux"); \ + builtin_assert ("system=linux"); \ +@@ -162,10 +165,7 @@ + } while (0) + + #undef SUBTARGET_CPP_SPEC +-#define SUBTARGET_CPP_SPEC "\ +-%{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \ +-%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \ +-%{pthread:-D_REENTRANT}" ++#define SUBTARGET_CPP_SPEC "%{pthread:-D_REENTRANT}" + + /* From iris5.h */ + /* -G is incompatible with -KPIC which is the default, so only allow objects +@@ -198,10 +198,7 @@ + #endif + + #undef SUBTARGET_ASM_SPEC +-#define SUBTARGET_ASM_SPEC "\ +-%{mabi=64: -64} \ +-%{!fno-PIC:%{!fno-pic:-KPIC}} \ +-%{fno-PIC:-non_shared} %{fno-pic:-non_shared}" ++#define SUBTARGET_ASM_SPEC "%{mabi=64: -64} %{!mno-abicalls:-KPIC}" + + #undef SUBTARGET_ASM_DEBUGGING_SPEC + #define SUBTARGET_ASM_DEBUGGING_SPEC "-g0" diff --git a/3.3.6/pie/upstream/11_all_gcc-3.3.5-rs6000-pic.patch b/3.3.6/pie/upstream/11_all_gcc-3.3.5-rs6000-pic.patch new file mode 100644 index 0000000..12965dc --- /dev/null +++ b/3.3.6/pie/upstream/11_all_gcc-3.3.5-rs6000-pic.patch @@ -0,0 +1,45 @@ +--- gcc-3.3.5/gcc/config/rs6000/sysv4.h.upstream~ Fri Nov 19 00:28:57 2004 ++++ gcc-3.3.5/gcc/config/rs6000/sysv4.h Fri Nov 19 10:41:44 2004 +@@ -810,6 +810,22 @@ + #define TARGET_VERSION fprintf (stderr, " (PowerPC System V.4)"); + #endif + ++#define TARGET_OS_SYSV_CPP_BUILTINS() \ ++ do \ ++ { \ ++ if (flag_pic == 1) \ ++ { \ ++ builtin_define ("__pic__=1"); \ ++ builtin_define ("__PIC__=1"); \ ++ } \ ++ else if (flag_pic == 2) \ ++ { \ ++ builtin_define ("__pic__=2"); \ ++ builtin_define ("__PIC__=2"); \ ++ } \ ++ } \ ++ while (0) ++ + #ifndef TARGET_OS_CPP_BUILTINS + #define TARGET_OS_CPP_BUILTINS() \ + do \ +@@ -821,6 +837,7 @@ + builtin_assert ("system=svr4"); \ + builtin_assert ("cpu=powerpc"); \ + builtin_assert ("machine=powerpc"); \ ++ TARGET_OS_SYSV_CPP_BUILTINS (); \ + } \ + while (0) + #endif +@@ -976,10 +993,7 @@ + + #define LINK_OS_DEFAULT_SPEC "" + +-#define CPP_SYSV_SPEC \ +-"%{mrelocatable*: -D_RELOCATABLE} \ +-%{fpic: -D__PIC__=1 -D__pic__=1} \ +-%{!fpic: %{fPIC: -D__PIC__=2 -D__pic__=2}}" ++#define CPP_SYSV_SPEC "%{mrelocatable*: -D_RELOCATABLE}" + + /* Override rs6000.h definition. */ + #undef CPP_SPEC diff --git a/3.3.6/pie/upstream/12_all_gcc-3.3.5-v8.7.6.8-sparc-pic.patch b/3.3.6/pie/upstream/12_all_gcc-3.3.5-v8.7.6.8-sparc-pic.patch new file mode 100644 index 0000000..4a7c97f --- /dev/null +++ b/3.3.6/pie/upstream/12_all_gcc-3.3.5-v8.7.6.8-sparc-pic.patch @@ -0,0 +1,66 @@ +--- gcc-3.3.5/gcc/config/sparc/linux.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux.h Thu Nov 18 23:32:55 2004 +@@ -107,16 +107,30 @@ + #define WCHAR_TYPE_SIZE 32 + + #undef CPP_PREDEFINES +-#define CPP_PREDEFINES "-D__ELF__ -Dunix -D__sparc__ -D__gnu_linux__ -Dlinux -Asystem=unix -Asystem=posix" ++#define TARGET_OS_CPP_BUILTINS() \ ++ do { \ ++ builtin_define_std ("unix"); \ ++ builtin_define_std ("linux"); \ ++ builtin_define_std ("__sparc__"); \ ++ builtin_define ("__gnu_linux__"); \ ++ builtin_define ("__ELF__"); \ ++ if (flag_pic) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ ++ builtin_assert ("system=unix"); \ ++ builtin_assert ("system=posix"); \ ++ } while (0) + + #undef CPP_SUBTARGET_SPEC + #ifdef USE_GNULIBC_1 + #define CPP_SUBTARGET_SPEC \ +-"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ ++"%{posix:-D_POSIX_SOURCE} \ + %{mlong-double-128:-D__LONG_DOUBLE_128__}" + #else + #define CPP_SUBTARGET_SPEC \ +-"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \ ++"%{posix:-D_POSIX_SOURCE} \ + %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}" + #endif + +--- gcc-3.3.5/gcc/config/sparc/linux64.h.upstream~ Thu Nov 18 23:11:39 2004 ++++ gcc-3.3.5/gcc/config/sparc/linux64.h Thu Nov 18 23:34:29 2004 +@@ -119,11 +119,25 @@ + #endif + + #undef CPP_PREDEFINES +-#define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -D__gnu_linux__ -Dlinux -Asystem=unix -Asystem=posix" ++#define TARGET_OS_CPP_BUILTINS() \ ++ do { \ ++ builtin_define_std ("unix"); \ ++ builtin_define_std ("linux"); \ ++ builtin_define_std ("__sparc__"); \ ++ builtin_define ("__gnu_linux__"); \ ++ builtin_define ("_LONGLONG"); \ ++ builtin_define ("__ELF__"); \ ++ if (flag_pic) \ ++ { \ ++ builtin_define ("__PIC__"); \ ++ builtin_define ("__pic__"); \ ++ } \ ++ builtin_assert ("system=unix"); \ ++ builtin_assert ("system=posix"); \ ++ } while (0) + + #undef CPP_SUBTARGET_SPEC + #define CPP_SUBTARGET_SPEC "\ +-%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \ + %{posix:-D_POSIX_SOURCE} \ + %{pthread:-D_REENTRANT} \ + " diff --git a/3.3.6/pie/upstream/31_all_gcc-4.0-cvs-incompat.patch b/3.3.6/pie/upstream/31_all_gcc-4.0-cvs-incompat.patch new file mode 100644 index 0000000..e5bc302 --- /dev/null +++ b/3.3.6/pie/upstream/31_all_gcc-4.0-cvs-incompat.patch @@ -0,0 +1,11 @@ +--- gcc-4.0.old/gcc/gcc.c.mps Sun Nov 14 21:10:35 2004 ++++ gcc-4.0/gcc/gcc.c Sun Nov 14 21:43:17 2004 +@@ -794,6 +794,8 @@ + /* NB: This is shared amongst all front-ends. */ + static const char *cc1_options = + "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ ++ %{shared:%{static|pie|fPIE|fpie|fno-PIC|fno-pic:%e-shared and -static|pie|fPIE|fpie|fno-PIC|fno-pic are incompatible}}\ ++ %{pie:%{static|pg|p|profile:%e-pie and -static|pg|p|profile are incompatible}}\ + %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ + %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}}\ + %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi}\ diff --git a/3.3.6/pie/upstream/41_all_gcc-3.3.3-v8.7.1-pie-generic.patch b/3.3.6/pie/upstream/41_all_gcc-3.3.3-v8.7.1-pie-generic.patch new file mode 100644 index 0000000..477c7c9 --- /dev/null +++ b/3.3.6/pie/upstream/41_all_gcc-3.3.3-v8.7.1-pie-generic.patch @@ -0,0 +1,56 @@ +--- gcc-3.3.3/gcc/config/linux.h.genericpie Tue May 4 16:34:01 2004 ++++ gcc-3.3.3/gcc/config/linux.h Tue May 4 16:41:49 2004 +@@ -54,22 +54,21 @@ + %{!profile:crt1.o%s}}}} \ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else +-#if defined HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} \ +- %{!profile:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}} \ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" + #else +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} \ +- %{!profile:crt1.o%s}}}} \ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" + #endif + #endif + +@@ -80,8 +79,14 @@ + GNU/Linux "finalizer" file, `crtn.o'. */ + + #undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" ++#else ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif + + /* This is for -profile to use -lc_p instead of -lc. */ + #ifndef CC1_SPEC diff --git a/3.3.6/pie/upstream/51_all_gcc-3.3.3-v8.7.5-pie-ia64.patch b/3.3.6/pie/upstream/51_all_gcc-3.3.3-v8.7.5-pie-ia64.patch new file mode 100644 index 0000000..0106b1e --- /dev/null +++ b/3.3.6/pie/upstream/51_all_gcc-3.3.3-v8.7.5-pie-ia64.patch @@ -0,0 +1,52 @@ +--- gcc-3.3.3/gcc/config/ia64/linux.h.ia64pie Tue May 4 16:47:02 2004 ++++ gcc-3.3.3/gcc/config/ia64/linux.h Tue May 4 16:56:32 2004 +@@ -22,26 +22,34 @@ + /* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */ + #undef STARTFILE_SPEC + #ifdef HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} \ +- %{!profile:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}} \ +- crti.o%s %{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}" ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" + #else +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} \ +- %{!profile:crt1.o%s}}}} \ +- crti.o%s %{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}" ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:crtbegin.o%s}" + #endif + + /* Similar to standard Linux, but adding -ffast-math support. */ + #undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" ++#else ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif ++ + + /* Define this for shared library support because it isn't in the main + linux.h file. */ diff --git a/3.3.6/pie/upstream/52_all_gcc-3.3.3-v8.7.5-pie-sparc.patch b/3.3.6/pie/upstream/52_all_gcc-3.3.3-v8.7.5-pie-sparc.patch new file mode 100644 index 0000000..950c42c --- /dev/null +++ b/3.3.6/pie/upstream/52_all_gcc-3.3.3-v8.7.5-pie-sparc.patch @@ -0,0 +1,54 @@ +--- gcc-3.3.3/gcc/config/sparc/linux.h.sparcpie Tue May 4 15:29:07 2004 ++++ gcc-3.3.3/gcc/config/sparc/linux.h Tue May 4 17:34:52 2004 +@@ -47,18 +47,19 @@ + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else +-#if defined HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" +-#else +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" ++#else ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" + #endif + #endif + +@@ -69,9 +70,16 @@ + GNU/Linux "finalizer" file, `crtn.o'. */ + + #undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" ++#else ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif + + /* This is for -profile to use -lc_p instead of -lc. */ + #undef CC1_SPEC diff --git a/3.3.6/pie/upstream/53_all_gcc-3.3.3-v8.7.5-pie-sparc64.patch b/3.3.6/pie/upstream/53_all_gcc-3.3.3-v8.7.5-pie-sparc64.patch new file mode 100644 index 0000000..b573652 --- /dev/null +++ b/3.3.6/pie/upstream/53_all_gcc-3.3.3-v8.7.5-pie-sparc64.patch @@ -0,0 +1,47 @@ +--- gcc-3.3.3/gcc/config/sparc/linux64.h.sparc64pie Tue May 4 15:29:07 2004 ++++ gcc-3.3.3/gcc/config/sparc/linux64.h Tue May 4 17:29:02 2004 +@@ -56,15 +56,16 @@ + #undef STARTFILE_SPEC + + #ifdef HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#define STARTFILE_SPEC "\ ++%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" + #else +-#define STARTFILE_SPEC \ +- "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++#define STARTFILE_SPEC "\ ++%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" + #endif + + /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on +@@ -75,9 +76,16 @@ + + #undef ENDFILE_SPEC + +-#define ENDFILE_SPEC \ +- "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s\ +- %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s \ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" ++#else ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s \ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" ++#endif + + /* The GNU C++ standard library requires that these macros be defined. */ + #undef CPLUSPLUS_CPP_SPEC diff --git a/3.3.6/pie/upstream/54_all_gcc-3.3.5-v8.7.1-pie-rs6000.patch b/3.3.6/pie/upstream/54_all_gcc-3.3.5-v8.7.1-pie-rs6000.patch new file mode 100644 index 0000000..c345f95 --- /dev/null +++ b/3.3.6/pie/upstream/54_all_gcc-3.3.5-v8.7.1-pie-rs6000.patch @@ -0,0 +1,77 @@ +--- gcc-3.3.3/gcc/config/rs6000/sysv4.h.piecor Mon May 3 16:15:37 2004 ++++ gcc-3.3.3/gcc/config/rs6000/sysv4.h Mon May 3 16:15:39 2004 +@@ -1140,23 +1140,32 @@ + %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ + %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" + #else +-#if defined HAVE_LD_PIE ++#ifdef HAVE_LD_PIE + #define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}} \ ++%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ + %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ +-%{static:crtbeginT.o%s} \ +-%{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++%{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" + #else + #define STARTFILE_LINUX_SPEC "\ + %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \ + %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \ +-%{static:crtbeginT.o%s} \ +-%{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}" ++%{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" + #endif + #endif + +-#define ENDFILE_LINUX_SPEC "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} \ ++#ifdef HAVE_LD_PIE ++#define ENDFILE_LINUX_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } \ + %{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}" ++#else ++#define ENDFILE_LINUX_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} \ ++%{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}" ++#endif + + #define LINK_START_LINUX_SPEC "" + +--- gcc-3.3.5/gcc/config/rs6000/linux64.h.piecor Mon May 3 16:15:37 2004 ++++ gcc-3.3.5/gcc/config/rs6000/linux64.h Mon May 3 16:15:39 2004 +@@ -165,14 +165,28 @@ + #endif + + #undef STARTFILE_LINUX_SPEC ++#ifdef HAVE_LD_PIE + #define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \ +-%{static:crtbeginT.o%s} \ +-%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" ++%{!shared: %{pg|p:gcrt1.o%s} %{!pg:%{!p:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} crti.o%s \ ++%{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}}}" ++#else ++#define STARTFILE_LINUX_SPEC "\ ++%{!shared: %{pg|p:gcrt1.o%s} %{!pg:%{!p:crt1.o%s}}} crti.o%s \ ++%{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" ++#endif + + #undef ENDFILE_LINUX_SPEC ++#ifdef HAVE_LD_PIE + #define ENDFILE_LINUX_SPEC "\ +-%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}}} crtn.o%s" ++#else ++#define ENDFILE_LINUX_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif + + #undef TOC_SECTION_ASM_OP + #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\"" diff --git a/3.3.6/pie/upstream/55_all_gcc-3.3.5-v8.7.5-pie-alpha.patch b/3.3.6/pie/upstream/55_all_gcc-3.3.5-v8.7.5-pie-alpha.patch new file mode 100644 index 0000000..1017c7d --- /dev/null +++ b/3.3.6/pie/upstream/55_all_gcc-3.3.5-v8.7.5-pie-alpha.patch @@ -0,0 +1,51 @@ +--- gcc-3.3.3/gcc/config/alpha/elf.h.alphapie Tue May 4 15:29:07 2004 ++++ gcc-3.3.3/gcc/config/alpha/elf.h Tue May 4 15:35:02 2004 +@@ -411,17 +411,18 @@ + + #undef STARTFILE_SPEC + #ifdef HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{shared|pie:crtbeginS.o%s}%{!shared:%{!pie:crtbegin.o%s}}}" ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" + #else +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\ +- crti.o%s %{static:crtbeginT.o%s}\ +- %{!static:%{shared|pie:crtbeginS.o%s}%{!shared:%{!pie:crtbegin.o%s}}}" ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s} }} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbeginT.o%s} \ ++%{!static:crtbegin.o%s} }" + #endif + + /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the +@@ -430,9 +431,16 @@ + `main', followed by a normal ELF "finalizer" file, `crtn.o'. */ + + #undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{shared|pie:crtendS.o%s}%{!shared:%{!pie:crtend.o%s}} crtn.o%s" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" ++#else ++#define ENDFILE_SPEC "\ ++%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif + + /* We support #pragma. */ + #define HANDLE_SYSV_PRAGMA 1 diff --git a/3.3.6/pie/upstream/56_all_gcc-3.3.5-v8.7.5-pie-arm.patch b/3.3.6/pie/upstream/56_all_gcc-3.3.5-v8.7.5-pie-arm.patch new file mode 100644 index 0000000..4763302 --- /dev/null +++ b/3.3.6/pie/upstream/56_all_gcc-3.3.5-v8.7.5-pie-arm.patch @@ -0,0 +1,47 @@ +--- gcc-3.3.3/gcc/config/arm/linux-elf.h.armpie Tue May 4 16:06:13 2004 ++++ gcc-3.3.3/gcc/config/arm/linux-elf.h Tue May 4 16:30:09 2004 +@@ -62,12 +62,21 @@ + object constructed before entering `main'. */ + + #undef STARTFILE_SPEC +-#define STARTFILE_SPEC \ +- "%{!shared: \ +- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ +- %{!p:%{profile:gcrt1.o%s} \ +- %{!profile:crt1.o%s}}}} \ +- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:%{static:crt1.o%s} \ ++%{!static:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}} }}}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:%{static:crtbegin.o%s} \ ++%{!static:%{pie:crtbeginS.o%s}%{!pie:crtbegin.o%s}} }" ++#else ++#define STARTFILE_SPEC "\ ++%{!shared: \ ++%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ ++%{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s} }}} \ ++crti.o%s %{shared:crtbeginS.o%s} %{!shared:crtbegin.o%s}" ++#endif + + /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on + the GNU/Linux magical crtend.o file (see crtstuff.c) which +@@ -76,8 +85,14 @@ + GNU/Linux "finalizer" file, `crtn.o'. */ + + #undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++#ifdef HAVE_LD_PIE ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:%{static:crtend.o%s} \ ++%{!static:%{pie:crtendS.o%s}%{!pie:crtend.o%s}} } crtn.o%s" ++#else ++#define ENDFILE_SPEC "\ ++%{shared:crtendS.o%s} %{!shared:crtend.o%s} crtn.o%s" ++#endif + + #undef LINK_SPEC + #ifdef USE_UCLIBC diff --git a/3.3.6/pie/upstream/57_all_gcc-3.4.0-v8.7.6.1-pie-arm.patch b/3.3.6/pie/upstream/57_all_gcc-3.4.0-v8.7.6.1-pie-arm.patch new file mode 100644 index 0000000..f4d9e10 --- /dev/null +++ b/3.3.6/pie/upstream/57_all_gcc-3.4.0-v8.7.6.1-pie-arm.patch @@ -0,0 +1,16 @@ +--- gcc-3.4.0/gcc/config/arm/linux-elf.h.mps Thu May 20 09:11:17 2004 ++++ gcc-3.4.0/gcc/config/arm/linux-elf.h Thu May 20 09:12:28 2004 +@@ -91,10 +91,11 @@ + #define LINK_SPEC "%{h*} %{version:-v} \ + %{b} %{Wl,*:%*} \ +- %{static:-Bstatic} \ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ ++ %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \ ++ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{static:-Bstatic}} \ + -X \ + %{mbig-endian:-EB}" \ + SUBTARGET_EXTRA_LINK_SPEC diff --git a/3.3.6/pie/upstream/61_all_gcc-3.4.0-v8.7.6.1-pie-arm-uclibc.patch b/3.3.6/pie/upstream/61_all_gcc-3.4.0-v8.7.6.1-pie-arm-uclibc.patch new file mode 100644 index 0000000..176b43f --- /dev/null +++ b/3.3.6/pie/upstream/61_all_gcc-3.4.0-v8.7.6.1-pie-arm-uclibc.patch @@ -0,0 +1,16 @@ +--- gcc-3.4.0/gcc/config/arm/linux-elf.h.mps Thu May 20 09:11:17 2004 ++++ gcc-3.4.0/gcc/config/arm/linux-elf.h Thu May 20 09:12:28 2004 +@@ -91,10 +91,11 @@ + #define LINK_SPEC "%{h*} %{version:-v} \ + %{b} %{Wl,*:%*} \ +- %{static:-Bstatic} \ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ ++ %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0} \ ++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}} \ ++ %{static:-Bstatic}} \ + -X \ + %{mbig-endian:-EB}" \ + SUBTARGET_EXTRA_LINK_SPEC |