website: manual: refresh qi.html to be reflected on the website
[dragora.git] / patches / gcc / 0012-static-pie.patch
blob03a4f68f60a0b2d37bfd88c14ea12a97b5939221
1 From a4aa319f7c19e564dced3daeb7222c9315af936c Mon Sep 17 00:00:00 2001
2 From: Szabolcs Nagy <nsz@port70.net>
3 Date: Sat, 18 Aug 2018 23:58:45 +0000
4 Subject: [PATCH 12/12] static-pie
6 in gcc-8 -static means static non-pie, even if -pie or -static-pie
7 are specified, -static-pie can be used to build static pie.
9 in musl toolchains -static -pie always meant static pie, so this
10 patch fixes the link specs accordingly, the new -static-pie is just
11 an alias to -static -pie.
12 ---
13 gcc/common.opt | 4 ++--
14 gcc/config/gnu-user.h | 12 +++++-------
15 gcc/config/rs6000/sysv4.h | 11 +++++------
16 gcc/gcc.c | 6 +++---
17 4 files changed, 15 insertions(+), 18 deletions(-)
19 diff --git a/gcc/common.opt b/gcc/common.opt
20 index b52ef0b38c8..0ce5857e01d 100644
21 --- a/gcc/common.opt
22 +++ b/gcc/common.opt
23 @@ -3197,11 +3197,11 @@ Driver
25 no-pie
26 Driver RejectNegative Negative(shared)
27 -Don't create a dynamically linked position independent executable.
28 +Don't create a position independent executable.
30 pie
31 Driver RejectNegative Negative(no-pie)
32 -Create a dynamically linked position independent executable.
33 +Create a position independent executable.
35 static-pie
36 Driver RejectNegative Negative(pie)
37 diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
38 index 8620de3e42d..235328a2642 100644
39 --- a/gcc/config/gnu-user.h
40 +++ b/gcc/config/gnu-user.h
41 @@ -52,13 +52,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
42 #define GNU_USER_TARGET_STARTFILE_SPEC \
43 "%{shared:; \
44 pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
45 - static:crt1.o%s; \
46 - static-pie:rcrt1.o%s; \
47 + static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
48 " PIE_SPEC ":Scrt1.o%s; \
49 :crt1.o%s} \
50 crti.o%s \
51 - %{static:crtbeginT.o%s; \
52 - shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
53 + %{shared|" PIE_SPEC ":crtbeginS.o%s; \
54 + static:crtbeginT.o%s; \
55 :crtbegin.o%s} \
56 %{fvtable-verify=none:%s; \
57 fvtable-verify=preinit:vtv_start_preinit.o%s; \
58 @@ -92,8 +91,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
59 "%{fvtable-verify=none:%s; \
60 fvtable-verify=preinit:vtv_end_preinit.o%s; \
61 fvtable-verify=std:vtv_end.o%s} \
62 - %{static:crtend.o%s; \
63 - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
64 + %{shared|" PIE_SPEC ":crtendS.o%s; \
65 :crtend.o%s} \
66 crtn.o%s \
67 " CRTOFFLOADEND
68 @@ -133,7 +131,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
69 #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
71 #if defined(HAVE_LD_EH_FRAME_HDR)
72 -#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
73 +#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
74 #endif
76 #undef LINK_GCC_C_SEQUENCE_SPEC
77 diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
78 index bb19d0dcd41..bb2a2324eb0 100644
79 --- a/gcc/config/rs6000/sysv4.h
80 +++ b/gcc/config/rs6000/sysv4.h
81 @@ -763,12 +763,12 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
82 #define STARTFILE_LINUX_SPEC \
83 "%{shared:; \
84 pg|p|profile:gcrt1.o%s; \
85 - static:crt1.o%s; \
86 - static-pie|" PIE_SPEC ":Scrt1.o%s; \
87 + static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
88 + " PIE_SPEC ":Scrt1.o%s; \
89 :crt1.o%s} \
90 %{mnewlib:ecrti.o%s;:crti.o%s} \
91 - %{static:crtbeginT.o%s; \
92 - shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
93 + %{shared|" PIE_SPEC ":crtbeginS.o%s; \
94 + static:crtbeginT.o%s; \
95 :crtbegin.o%s} \
96 %{fvtable-verify=none:%s; \
97 fvtable-verify=preinit:vtv_start_preinit.o%s; \
98 @@ -781,8 +781,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
99 "%{fvtable-verify=none:%s; \
100 fvtable-verify=preinit:vtv_end_preinit.o%s; \
101 fvtable-verify=std:vtv_end.o%s} \
102 - %{static:crtend.o%s; \
103 - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
104 + %{shared|" PIE_SPEC ":crtendS.o%s; \
105 :crtend.o%s} \
106 %{mnewlib:ecrtn.o%s;:crtn.o%s} \
107 " CRTOFFLOADEND
108 diff --git a/gcc/gcc.c b/gcc/gcc.c
109 index eb1610ba8b0..87560afb03c 100644
110 --- a/gcc/gcc.c
111 +++ b/gcc/gcc.c
112 @@ -900,7 +900,7 @@ proper position among the other output files. */
113 #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
114 #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
115 #else
116 -#define PIE_SPEC "pie"
117 +#define PIE_SPEC "pie|static-pie"
118 #define FPIE1_SPEC "fpie"
119 #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
120 #define FPIE2_SPEC "fPIE"
121 @@ -924,12 +924,12 @@ proper position among the other output files. */
122 #ifndef LINK_PIE_SPEC
123 #ifdef HAVE_LD_PIE
124 #ifndef LD_PIE_SPEC
125 -#define LD_PIE_SPEC "-pie"
126 +#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
127 #endif
128 #else
129 #define LD_PIE_SPEC ""
130 #endif
131 -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
132 +#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
133 #endif
135 #ifndef LINK_BUILDID_SPEC
137 2.17.1