summaryrefslogtreecommitdiffstats
path: root/main/gcc/03_all_gcc-4.3.2-hardened-default.patch
blob: 04da4ea11bdd99d940c76bcc9c89ca02fc9880e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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.  */