recipes: tools/pmount: added version 0.9.23
[dragora.git] / patches / gcc / 0012-static-pie.patch
blobeeb8812dee0fb8b443ffdfd077071d1baa954603
1 From 913497c615c1e3708f4c532301010e1a6164da0d 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/13] 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/gcc.c | 6 +++---
16 3 files changed, 10 insertions(+), 12 deletions(-)
18 diff --git a/gcc/common.opt b/gcc/common.opt
19 index d342c4f3749..2aae4a3cefb 100644
20 --- a/gcc/common.opt
21 +++ b/gcc/common.opt
22 @@ -3287,11 +3287,11 @@ Driver
24 no-pie
25 Driver RejectNegative Negative(shared)
26 -Don't create a dynamically linked position independent executable.
27 +Don't create a position independent executable.
29 pie
30 Driver RejectNegative Negative(no-pie)
31 -Create a dynamically linked position independent executable.
32 +Create a position independent executable.
34 static-pie
35 Driver RejectNegative Negative(pie)
36 diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
37 index 055a4f0afec..7a671c6a49c 100644
38 --- a/gcc/config/gnu-user.h
39 +++ b/gcc/config/gnu-user.h
40 @@ -51,13 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
41 #define GNU_USER_TARGET_STARTFILE_SPEC \
42 "%{shared:; \
43 pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
44 - static:crt1.o%s; \
45 - static-pie:rcrt1.o%s; \
46 + static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
47 " PIE_SPEC ":Scrt1.o%s; \
48 :crt1.o%s} " \
49 GNU_USER_TARGET_CRTI " \
50 - %{static:crtbeginT.o%s; \
51 - shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
52 + %{shared|" PIE_SPEC ":crtbeginS.o%s; \
53 + static:crtbeginT.o%s; \
54 :crtbegin.o%s} \
55 %{fvtable-verify=none:%s; \
56 fvtable-verify=preinit:vtv_start_preinit.o%s; \
57 @@ -76,8 +75,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
58 "%{fvtable-verify=none:%s; \
59 fvtable-verify=preinit:vtv_end_preinit.o%s; \
60 fvtable-verify=std:vtv_end.o%s} \
61 - %{static:crtend.o%s; \
62 - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
63 + %{shared|" PIE_SPEC ":crtendS.o%s; \
64 :crtend.o%s} " \
65 GNU_USER_TARGET_CRTN " " \
66 CRTOFFLOADEND
67 @@ -106,7 +104,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
68 #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
70 #if defined(HAVE_LD_EH_FRAME_HDR)
71 -#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
72 +#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
73 #endif
75 #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
76 diff --git a/gcc/gcc.c b/gcc/gcc.c
77 index d185c01b257..5d3f81c5fc5 100644
78 --- a/gcc/gcc.c
79 +++ b/gcc/gcc.c
80 @@ -908,7 +908,7 @@ proper position among the other output files. */
81 #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
82 #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
83 #else
84 -#define PIE_SPEC "pie"
85 +#define PIE_SPEC "pie|static-pie"
86 #define FPIE1_SPEC "fpie"
87 #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
88 #define FPIE2_SPEC "fPIE"
89 @@ -932,12 +932,12 @@ proper position among the other output files. */
90 #ifndef LINK_PIE_SPEC
91 #ifdef HAVE_LD_PIE
92 #ifndef LD_PIE_SPEC
93 -#define LD_PIE_SPEC "-pie"
94 +#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
95 #endif
96 #else
97 #define LD_PIE_SPEC ""
98 #endif
99 -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
100 +#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
101 #endif
103 #ifndef LINK_BUILDID_SPEC
105 2.21.0