aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/03_all_gcc-4.3.2-hardened-default.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/gcc/03_all_gcc-4.3.2-hardened-default.patch')
-rw-r--r--main/gcc/03_all_gcc-4.3.2-hardened-default.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/main/gcc/03_all_gcc-4.3.2-hardened-default.patch b/main/gcc/03_all_gcc-4.3.2-hardened-default.patch
new file mode 100644
index 0000000000..04da4ea11b
--- /dev/null
+++ b/main/gcc/03_all_gcc-4.3.2-hardened-default.patch
@@ -0,0 +1,53 @@
+This patch defines the hardened specs hard in the gcc.c file.
+--- gcc-4.3.2/gcc/gcc.c.orig2 Sun Nov 23 11:35:41 2008
++++ gcc-4.3.2/gcc/gcc.c Sun Nov 23 11:51:58 2008
+@@ -703,9 +703,9 @@
+
+ #ifndef LINK_PIE_SPEC
+ #ifdef HAVE_LD_PIE
+-#define LINK_PIE_SPEC "%{pie:-pie} "
+-#define CC1_PIE_SPEC "%{pie:-fPIE}"
+-#define ASM_PIE_SPEC "%{pie:-K PIC}"
++#define LINK_PIE_SPEC "%{pie:-pie} %{!pie: %{!A: %{!fno-pie:%{!fno-PIE: %{!shared:%{!static:%{!r: %{!nopie:-pie} }}} }} } }%{pie:-pie} %{!pie: %{!A: %{!fno-pie:%{!fno-PIE: %{!shared:%{!static:%{!r: %{!nopie:-pie} }}} }} } } "
++#define CC1_PIE_SPEC "%{pie:-fPIE} %{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: %{!shared: %{!nopie:-fPIE} } }}}} }}}} }"
++#define ASM_PIE_SPEC "%{pie:-K PIC} %{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: %{!shared: %{!nopie:-K PIC} } }}}} }}}} }"
+ #else
+ #define LINK_PIE_SPEC "%{pie:} "
+ #define CC1_PIE_SPEC ""
+@@ -717,28 +717,28 @@
+ #define CC1_HARDENED_SPEC " %{!D__KERNEL__: %(cc1_pie) %(cc1_ssp) %(cc1_fortify) %(cc1_strict) }"
+ #endif
+ #ifndef CC1_SSP_SPEC
+-#define CC1_SSP_SPEC ""
++#define CC1_SSP_SPEC "%{!nostdlib:%{!nodefaultlibs: %{!fno-stack-protector:%{!fstack-protector:%{!fstack-protector-all:-fstack-protector %(cc1_ssp_all) }}} }}"
+ #endif
+ #ifndef CC1_SSP_ALL_SPEC
+-#define CC1_SSP_ALL_SPEC ""
++#define CC1_SSP_ALL_SPEC ""
+ #endif
+ #ifndef CRTFILE_PIE_SPEC
+-#define CRTFILE_PIE_SPEC "%{static:crt1.o%s;pie:Scrt1.o%s;:crt1.o%s}"
++#define CRTFILE_PIE_SPEC "%{fno-pie|fno-PIE|nopie:crt1.o%s;:Scrt1.o%s}"
+ #endif
+ #ifndef STARTFILE_PIE_SPEC
+-#define STARTFILE_PIE_SPEC "%{static:crtbegin.o%s;pie:crtbeginS.o%s;:crtbegin.o%s}"
++#define STARTFILE_PIE_SPEC "%{fno-pie|fno-PIE|nopie:crtbegin.o%s;:crtbeginS.o%s}"
+ #endif
+ #ifndef STARTFILE_PIE_T_SPEC
+-#define STARTFILE_PIE_T_SPEC "%{static:crtbeginT.o%s;pie:crtbeginS.o%s;:crtbegin.o%s}"
++#define STARTFILE_PIE_T_SPEC "%{static: %{fno-pie|fno-PIE|nopie:crtbeginT.o%s;:crtbeginTS.o%s} } %{!static: %{fno-pie|fno-PIE|nopie:crtbegin.o%s;:crtbeginS.o%s} }"
+ #endif
+ #ifndef ENDFILE_PIE_SPEC
+-#define ENDFILE_PIE_SPEC "%{pie:crtendS.o%s;:crtend.o%s}"
++#define ENDFILE_PIE_SPEC "%{fno-pie|fno-PIE|nopie:crtend.o%s;:crtendS.o%s}"
+ #endif
+ #ifndef LINK_RELRO_SPEC
+-#define LINK_RELRO_SPEC "%{norelro:}"
++#define LINK_RELRO_SPEC "%{!norelro:-z relro}"
+ #endif
+ #ifndef LINK_NOW_SPEC
+-#define LINK_NOW_SPEC "%{nonow:}"
++#define LINK_NOW_SPEC "%{!nonow:-z now}"
+ #endif
+
+ /* -u* was put back because both BSD and SysV seem to support it. */