Gentoo Archives: gentoo-commits

From: Aric Belsito <lluixhi@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/musl:master commit in: sys-devel/gcc/files/, sys-devel/gcc/files/musl-gcc-patches-4.9.3/, ...
Date: Sat, 30 Jun 2018 00:56:46
Message-Id: 1530320168.877c6d3a1bf239d117bcd3fa39dce1ae248d0e51.lluixhi@gentoo
1 commit: 877c6d3a1bf239d117bcd3fa39dce1ae248d0e51
2 Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
3 AuthorDate: Sat Jun 30 00:56:08 2018 +0000
4 Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
5 CommitDate: Sat Jun 30 00:56:08 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=877c6d3a
7
8 sys-devel/gcc: cleanup
9
10 sys-devel/gcc/Manifest | 6 -
11 ...ove-struct-ix86_frame-to-machine-function.patch | 237 -----
12 ...ove-struct-ix86_frame-to-machine-function.patch | 68 --
13 .../gcc-4.8.3-musl-fix-libc5-assumption.patch | 11 -
14 sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch | 30 -
15 .../gcc/files/gcc-4.9.3-musl-linker-path.patch | 74 --
16 sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch | 12 -
17 sys-devel/gcc/files/gcc-4.9.3-pr68470.patch | 58 --
18 sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch | 39 -
19 .../gcc/files/musl-gcc-patches-4.9.3/aarch64.diff | 12 -
20 .../gcc/files/musl-gcc-patches-4.9.3/arm.diff | 46 -
21 .../musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff | 62 --
22 .../musl-gcc-patches-4.9.3/gcc-config-musl.diff | 207 ----
23 .../gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff | 12 -
24 .../files/musl-gcc-patches-4.9.3/gomp-posix.diff | 16 -
25 .../gcc/files/musl-gcc-patches-4.9.3/gthread.diff | 16 -
26 .../musl-gcc-patches-4.9.3/kill-fixincludes.diff | 17 -
27 .../musl-gcc-patches-4.9.3/libstdc++-generic.diff | 31 -
28 .../musl-gcc-patches-4.9.3/microblaze-size_t.diff | 39 -
29 .../files/musl-gcc-patches-4.9.3/microblaze.diff | 31 -
30 .../gcc/files/musl-gcc-patches-4.9.3/mips.diff | 18 -
31 .../gcc/files/musl-gcc-patches-4.9.3/powerpc.diff | 108 --
32 sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff | 18 -
33 .../musl-gcc-patches-4.9.3/unwind-dliterate.diff | 43 -
34 .../gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff | 15 -
35 .../gcc/files/musl-gcc-patches-4.9.3/x86.diff | 55 -
36 .../gcc/files/spectre-0001-mindirect-branch.patch | 1084 --------------------
37 .../gcc/files/spectre-0002-mfunction-return.patch | 447 --------
38 .../spectre-0003-mindirect-branch-register.patch | 340 ------
39 .../files/spectre-0004-v-register-modifier.patch | 128 ---
40 .../gcc/files/spectre-0005-mcmodel-large.patch | 105 --
41 sys-devel/gcc/gcc-4.9.4-r100.ebuild | 66 --
42 sys-devel/gcc/gcc-4.9.4-r99.ebuild | 65 --
43 sys-devel/gcc/gcc-7.2.0-r1.ebuild | 31 -
44 sys-devel/gcc/gcc-7.2.0-r2.ebuild | 41 -
45 sys-devel/gcc/gcc-7.3.0-r1.ebuild | 31 -
46 36 files changed, 3619 deletions(-)
47
48 diff --git a/sys-devel/gcc/Manifest b/sys-devel/gcc/Manifest
49 index 87b1ea8..a624cc8 100644
50 --- a/sys-devel/gcc/Manifest
51 +++ b/sys-devel/gcc/Manifest
52 @@ -1,9 +1,5 @@
53 DIST ecj-4.5.jar 1470676 BLAKE2B 793c10ba09fd8040c0e1181204141aea16780c9c9088e07126e00da2b510af2ad6f58d876357d7e98cbb02d783a3be434469d5de1df134ccb8cc508e45028d80 SHA512 d4e1bf7538ace56e3d69fa91da5bbd16c272923b4de0a9d8dee23ea2b75f9f38c603de72fc4061df49285c450b63f3df211cee5270e9fffc5447445d1a9c9e4e
54 DIST gcc-4.4.3-specs-0.2.0.tar.bz2 2004 BLAKE2B 96f5ba2028bc6e0ef71e009857c37118a54d13d30de24d697c85e5772f9f2b7853615648cf2e4ee81d8385f6518c64588c0b56675c00f95ef39fca2a808f075e SHA512 779ecb0a064d2138b54569c8ae501975b8a6b72e5a3acbf8597619a8db77ee42ef9b0e62608d5192a15e4393e7dfc009bb50b994782236faa744b2c46b5fe517
55 -DIST gcc-4.9.4-patches-1.0.tar.bz2 22266 BLAKE2B 38536e8a86a8296754311633b73da0bd7dddb3a6ac65e4b5ba1dde352789e9114a1129aad11bcb988a1baadec6fdf893290c6af83bb9fad5613f35a37ebbb12e SHA512 cc2407221f858bad38b57d31f635314f91794293695e23d255685d8bec20b9db19c7dc76bbf5e8184c2ba0ccb530958b09bae4d8a402ca27cadf463f46bfb995
56 -DIST gcc-4.9.4-piepatches-v0.6.4.tar.bz2 14414 BLAKE2B 2eccd4f2a164fbb32d13c7fe91627a2424c0a5570fe0cac97c2bb1c95294ba3d770832da7c445f75c91791466c5139a1e13753a3a40d87ff5e44e42749adee27 SHA512 243fa272ea0e49f700a76508bab3e03bbb353bcb930581b2f87f9a47df5cd3880e29f20b71612b21190adc463849e1e6ac2a38a49c0002b562d93d436f538285
57 -DIST gcc-4.9.4-uclibc-patches-1.0.tar.bz2 2618 BLAKE2B bff85a4088fb94fdb7a8b0bd552be98ace3e6d145889b6f8b4a1f2db2dad14342d155890ab159b42d5b55d88dfb7c392eb7f92590084e1958f6284c561da30f1 SHA512 5a1f44caa9261f4947101379628143869b31dec67fa28605e8e1f3894d4b7120c3f68ba6deb59da7a74fa906e27ab32cd3767761837dc3dfebc37865d349d6db
58 -DIST gcc-4.9.4.tar.bz2 90097606 BLAKE2B 373ff939ea72d6c4a7f3ab899b852b4c919481af2cfe3291281d9354c58a270d2eba73a0f301d90840dfabf423c82b368e113df7a2cb6cc28b2a703b0b6eb585 SHA512 93abb78e16277454f41a8e9810f41f66c0fdffdc539a762ff6b67d3037f78db971378683fd2ebf707d1d51c059fad2161fe42d110c330027f40214b7db0f3efe
59 DIST gcc-5.4.0-patches-1.8.tar.bz2 32886 BLAKE2B 85879ba552ff21e198de568b2a1f2544d6cf542174af3ca571e41a504373bbc8912a87177a413883f194d909237eeeaf65366e6b93c2b917f803b3edd10bbff5 SHA512 10c1102a37d9d485665cca606318a1da6eec2188998d340b91a371c9defa6fae285619f9cadad2546de0b7f1068e9eaf653714462d3331db3197308799927a6b
60 DIST gcc-5.4.0-piepatches-v0.6.5.tar.bz2 14551 BLAKE2B 6f3de9be0990a7580785821d8c85114a1907571c06bdf3a15ad91258f7c9e8bb6a4d2ddb8615f33bedf0ad036d215507e004fc095f788e40c824ae0ab3ffbb05 SHA512 4890f0713d261982ab81a20f93c5f65193aa1dfa171e3f9e5867f0b80ec7c1e76c5a997b1a4e6f47f8ce36af54ac91125c5bff8bf6d971b7d77c65a57a40a3c0
61 DIST gcc-5.4.0-uclibc-patches-1.0.tar.bz2 3731 BLAKE2B fa436d1c1d9c150714092132f816740f8218dfeb4f9a6a8c830ea54d211a020f209e6fd1fcc313b2560b82c7855120053d346af72b7c12c88a7a948379dd2356 SHA512 009f34197e79c5e8c6497a0db01ac45cc657e92e56a663b4f3281661d108b2a129cd977fab5f0064f225d6812ae91e82bab22a2b10ae02c486881eeed85ec7a3
62 @@ -11,8 +7,6 @@ DIST gcc-5.4.0.tar.bz2 95661481 BLAKE2B bf882acfa28cc1064cddd21e25332fff6bc65505
63 DIST gcc-6.4.0-patches-1.3.tar.bz2 13617 BLAKE2B 6bfb1d70397e6ca4359e5d190e36003c18c7a03a9be4f923461dcff11307601e6b3502a2e289585b53baeb919008d83c29ad24078f814aed9b331140e4687419 SHA512 91be7c8db0004cdd150fec0f8daa709374753d2f524c58087dcf45b6696dbd609972297e866f971fba1aa679464cf96a384dd111e104183c0939ab69add017b2
64 DIST gcc-6.4.0-uclibc-patches-1.0.tar.bz2 1586 BLAKE2B 21f97a9e1c349b3d52def092a03e5a90533521da9af586be7ee527594f2d65745491ff8758d88c99a7ac215bde7ebf4e47a0a36cfcd7e66f70e0bebf2dadd922 SHA512 266dbe2bb53d892a24cd752d5c6833ea33f8df8b11b0471700ee53865243cd41f412f9bea8a369b474c9cd1435faff2e03902c7cb5638dd3ddcaa665aa2ec522
65 DIST gcc-6.4.0.tar.xz 76156220 BLAKE2B 2018c338b28ea644cdd1b327cb0dfe7ee9aa2010357c93f7e71969f587c58d3fdfa2bb4c82a309490c48bc86924400022fa93f41dc6c4345878d1bc1d8204265 SHA512 02c60e54527c7adf584798d5251f8a0b80c93d5deafce82501b2c28e6692e0bd783927bbfc4bc527a863c0cccc025150a34740a9e29badb02d4b48e56a8aba90
66 -DIST gcc-7.2.0-patches-1.1.tar.bz2 9246 BLAKE2B f6eec8459e5ac1f177d9a417c59616ad53e4ba6da8744cf55922d3a401717bd5bfdf79296a1c0b856cfa03349e73b8034ab6024b83d3f5ef909534811ba470f2 SHA512 d08b31d1279cc4c6ba46b2dca6ebed4e5c8e4997f0859acab86c974209ce4aacd0df09632e70c3fb8ee7108ecb8208c8b8605e66a7e8d2568e45644bfeee4fbe
67 -DIST gcc-7.2.0.tar.xz 62312628 BLAKE2B 35e4b732f1a4515fc1a9d4424797177112847588e600dc5531bc9bf72305619d4100e8fd9d945920245e704fc9ac5bc5e3dbd20be6c3af49e689fc5bd1eca10f SHA512 f853cd6530b4055d8d8289da74687cb4c6d5f363598d386332d31852b581bac76c3adb7d61889edec3b779f63d8646f0122840f12965ce4a4389ba535dbbb6e1
68 DIST gcc-7.3.0-patches-1.1.tar.bz2 7439 BLAKE2B b6eff6f96cf4daf7b8debc767dc5ee1924a27be95c0a9a5d5ba957978f224c0907570e1492398865c4fa27d3b8f7c2f0fea2da813bf6b4ebb0fa66f9ccca9c46 SHA512 864a433c8f153a216c1028c553ffc3c84c474498c637ca6978e86fbb2ce4c07291c2561aabc2caa4953c012b8e18c277383ca153d56e13006967680119f9bcfa
69 DIST gcc-7.3.0-patches-1.4.tar.bz2 8238 BLAKE2B 72a5dcb046558c8f5c3a75040fe24ce1106c43af7510d6febf667b4377cb9caea5ebe9e1287af90e4ebfffa3f3f22ca85f533acf57c2e2d896f92adc1659b9f5 SHA512 24ed0d82240426efb111bbf48913b96fdc824ae3aa5a653298a726ebe64a40791f484229bbab9cc58f73d658e0b4b83ccd13081cfbea6e1673ef1d076cca3b33
70 DIST gcc-7.3.0.tar.xz 62462388 BLAKE2B dc8f132b21bd0543c3d9dd17557038aafe65675aa73c540954234a3c972b4c31c939149bd50183d072ab6c8d16919e19daeaaffd619ce2ccd62dbdf9a5bb3302 SHA512 ad41a7e4584e40e92cdf860bc0288500fbaf5dfb7e8c3fcabe9eba809c87bcfa85b46c19c19921b0cdf6d05483faede8287bb9ea120c0d1559449a70e602c8d4
71
72 diff --git a/sys-devel/gcc/files/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch b/sys-devel/gcc/files/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
73 deleted file mode 100644
74 index d85ed2c..0000000
75 --- a/sys-devel/gcc/files/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
76 +++ /dev/null
77 @@ -1,237 +0,0 @@
78 -From: "H.J. Lu" <hjl.tools@×××××.com>
79 -To: gcc-patches@×××××××.org
80 -Subject: [1/3] GCC 7: i386: Move struct ix86_frame to machine_function
81 -Date: Sun, 14 Jan 2018 07:02:35 -0800
82 -
83 -Make ix86_frame available to i386 code generation. This is needed to
84 -backport the patch set of -mindirect-branch= to mitigate variant #2 of
85 -the speculative execution vulnerabilities on x86 processors identified
86 -by CVE-2017-5715, aka Spectre.
87 -
88 - Backport from mainline
89 - * config/i386/i386.c (ix86_frame): Moved to ...
90 - * config/i386/i386.h (ix86_frame): Here.
91 - (machine_function): Add frame.
92 - * config/i386/i386.c (ix86_compute_frame_layout): Repace the
93 - frame argument with &cfun->machine->frame.
94 - (ix86_can_use_return_insn_p): Don't pass &frame to
95 - ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
96 - (ix86_can_eliminate): Likewise.
97 - (ix86_expand_prologue): Likewise.
98 - (ix86_expand_epilogue): Likewise.
99 - (ix86_expand_split_stack_prologue): Likewise.
100 ----
101 - gcc/config/i386/i386.c | 68 ++++++++++----------------------------------------
102 - gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++-
103 - 2 files changed, 65 insertions(+), 56 deletions(-)
104 -
105 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
106 -index 8a3782c0298..813337242d8 100644
107 ---- a/gcc/config/i386/i386.c
108 -+++ b/gcc/config/i386/i386.c
109 -@@ -2444,53 +2444,6 @@ struct GTY(()) stack_local_entry {
110 - struct stack_local_entry *next;
111 - };
112 -
113 --/* Structure describing stack frame layout.
114 -- Stack grows downward:
115 --
116 -- [arguments]
117 -- <- ARG_POINTER
118 -- saved pc
119 --
120 -- saved static chain if ix86_static_chain_on_stack
121 --
122 -- saved frame pointer if frame_pointer_needed
123 -- <- HARD_FRAME_POINTER
124 -- [saved regs]
125 -- <- regs_save_offset
126 -- [padding0]
127 --
128 -- [saved SSE regs]
129 -- <- sse_regs_save_offset
130 -- [padding1] |
131 -- | <- FRAME_POINTER
132 -- [va_arg registers] |
133 -- |
134 -- [frame] |
135 -- |
136 -- [padding2] | = to_allocate
137 -- <- STACK_POINTER
138 -- */
139 --struct ix86_frame
140 --{
141 -- int nsseregs;
142 -- int nregs;
143 -- int va_arg_size;
144 -- int red_zone_size;
145 -- int outgoing_arguments_size;
146 --
147 -- /* The offsets relative to ARG_POINTER. */
148 -- HOST_WIDE_INT frame_pointer_offset;
149 -- HOST_WIDE_INT hard_frame_pointer_offset;
150 -- HOST_WIDE_INT stack_pointer_offset;
151 -- HOST_WIDE_INT hfp_save_offset;
152 -- HOST_WIDE_INT reg_save_offset;
153 -- HOST_WIDE_INT sse_reg_save_offset;
154 --
155 -- /* When save_regs_using_mov is set, emit prologue using
156 -- move instead of push instructions. */
157 -- bool save_regs_using_mov;
158 --};
159 --
160 - /* Which cpu are we scheduling for. */
161 - enum attr_cpu ix86_schedule;
162 -
163 -@@ -2582,7 +2535,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode,
164 - const_tree);
165 - static rtx ix86_static_chain (const_tree, bool);
166 - static int ix86_function_regparm (const_tree, const_tree);
167 --static void ix86_compute_frame_layout (struct ix86_frame *);
168 -+static void ix86_compute_frame_layout (void);
169 - static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode,
170 - rtx, rtx, int);
171 - static void ix86_add_new_builtins (HOST_WIDE_INT, HOST_WIDE_INT);
172 -@@ -11903,7 +11856,8 @@ ix86_can_use_return_insn_p (void)
173 - if (crtl->args.pops_args && crtl->args.size >= 32768)
174 - return 0;
175 -
176 -- ix86_compute_frame_layout (&frame);
177 -+ ix86_compute_frame_layout ();
178 -+ frame = cfun->machine->frame;
179 - return (frame.stack_pointer_offset == UNITS_PER_WORD
180 - && (frame.nregs + frame.nsseregs) == 0);
181 - }
182 -@@ -12389,8 +12343,8 @@ ix86_can_eliminate (const int from, const int to)
183 - HOST_WIDE_INT
184 - ix86_initial_elimination_offset (int from, int to)
185 - {
186 -- struct ix86_frame frame;
187 -- ix86_compute_frame_layout (&frame);
188 -+ ix86_compute_frame_layout ();
189 -+ struct ix86_frame frame = cfun->machine->frame;
190 -
191 - if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
192 - return frame.hard_frame_pointer_offset;
193 -@@ -12429,8 +12383,9 @@ ix86_builtin_setjmp_frame_value (void)
194 - /* Fill structure ix86_frame about frame of currently computed function. */
195 -
196 - static void
197 --ix86_compute_frame_layout (struct ix86_frame *frame)
198 -+ix86_compute_frame_layout (void)
199 - {
200 -+ struct ix86_frame *frame = &cfun->machine->frame;
201 - unsigned HOST_WIDE_INT stack_alignment_needed;
202 - HOST_WIDE_INT offset;
203 - unsigned HOST_WIDE_INT preferred_alignment;
204 -@@ -13737,7 +13692,8 @@ ix86_expand_prologue (void)
205 - m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET;
206 - m->fs.sp_valid = true;
207 -
208 -- ix86_compute_frame_layout (&frame);
209 -+ ix86_compute_frame_layout ();
210 -+ frame = m->frame;
211 -
212 - if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
213 - {
214 -@@ -14405,7 +14361,8 @@ ix86_expand_epilogue (int style)
215 - bool using_drap;
216 -
217 - ix86_finalize_stack_realign_flags ();
218 -- ix86_compute_frame_layout (&frame);
219 -+ ix86_compute_frame_layout ();
220 -+ frame = m->frame;
221 -
222 - m->fs.sp_valid = (!frame_pointer_needed
223 - || (crtl->sp_is_unchanging
224 -@@ -14915,7 +14872,8 @@ ix86_expand_split_stack_prologue (void)
225 - gcc_assert (flag_split_stack && reload_completed);
226 -
227 - ix86_finalize_stack_realign_flags ();
228 -- ix86_compute_frame_layout (&frame);
229 -+ ix86_compute_frame_layout ();
230 -+ frame = cfun->machine->frame;
231 - allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
232 -
233 - /* This is the label we will branch to if we have enough stack
234 -diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
235 -index 9c776dc5172..f9b91286a01 100644
236 ---- a/gcc/config/i386/i386.h
237 -+++ b/gcc/config/i386/i386.h
238 -@@ -2451,9 +2451,56 @@ enum avx_u128_state
239 -
240 - #define FASTCALL_PREFIX '@'
241 -
242 -+#ifndef USED_FOR_TARGET
243 -+/* Structure describing stack frame layout.
244 -+ Stack grows downward:
245 -+
246 -+ [arguments]
247 -+ <- ARG_POINTER
248 -+ saved pc
249 -+
250 -+ saved static chain if ix86_static_chain_on_stack
251 -+
252 -+ saved frame pointer if frame_pointer_needed
253 -+ <- HARD_FRAME_POINTER
254 -+ [saved regs]
255 -+ <- regs_save_offset
256 -+ [padding0]
257 -+
258 -+ [saved SSE regs]
259 -+ <- sse_regs_save_offset
260 -+ [padding1] |
261 -+ | <- FRAME_POINTER
262 -+ [va_arg registers] |
263 -+ |
264 -+ [frame] |
265 -+ |
266 -+ [padding2] | = to_allocate
267 -+ <- STACK_POINTER
268 -+ */
269 -+struct GTY(()) ix86_frame
270 -+{
271 -+ int nsseregs;
272 -+ int nregs;
273 -+ int va_arg_size;
274 -+ int red_zone_size;
275 -+ int outgoing_arguments_size;
276 -+
277 -+ /* The offsets relative to ARG_POINTER. */
278 -+ HOST_WIDE_INT frame_pointer_offset;
279 -+ HOST_WIDE_INT hard_frame_pointer_offset;
280 -+ HOST_WIDE_INT stack_pointer_offset;
281 -+ HOST_WIDE_INT hfp_save_offset;
282 -+ HOST_WIDE_INT reg_save_offset;
283 -+ HOST_WIDE_INT sse_reg_save_offset;
284 -+
285 -+ /* When save_regs_using_mov is set, emit prologue using
286 -+ move instead of push instructions. */
287 -+ bool save_regs_using_mov;
288 -+};
289 -+
290 - /* Machine specific frame tracking during prologue/epilogue generation. */
291 -
292 --#ifndef USED_FOR_TARGET
293 - struct GTY(()) machine_frame_state
294 - {
295 - /* This pair tracks the currently active CFA as reg+offset. When reg
296 -@@ -2512,6 +2559,9 @@ struct GTY(()) machine_function {
297 - int varargs_fpr_size;
298 - int optimize_mode_switching[MAX_386_ENTITIES];
299 -
300 -+ /* Cached initial frame layout for the current function. */
301 -+ struct ix86_frame frame;
302 -+
303 - /* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE
304 - has been computed for. */
305 - int use_fast_prologue_epilogue_nregs;
306 -@@ -2594,6 +2644,7 @@ struct GTY(()) machine_function {
307 - #define ix86_current_function_calls_tls_descriptor \
308 - (ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG))
309 - #define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack)
310 -+#define ix86_red_zone_size (cfun->machine->frame.red_zone_size)
311 -
312 - /* Control behavior of x86_file_start. */
313 - #define X86_FILE_START_VERSION_DIRECTIVE false
314 -
315
316 diff --git a/sys-devel/gcc/files/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch b/sys-devel/gcc/files/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
317 deleted file mode 100644
318 index a086d03..0000000
319 --- a/sys-devel/gcc/files/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
320 +++ /dev/null
321 @@ -1,68 +0,0 @@
322 -From: "H.J. Lu" <hjl.tools@×××××.com>
323 -To: gcc-patches@×××××××.org
324 -Subject: [2/3] GCC 7: i386: Use reference of struct ix86_frame to avoid copy
325 -Date: Sun, 14 Jan 2018 07:02:36 -0800
326 -
327 -When there is no need to make a copy of ix86_frame, we can use reference
328 -of struct ix86_frame to avoid copy.
329 -
330 -Tested on x86-64.
331 -
332 - Backport from mainline
333 - * config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
334 - of struct ix86_frame.
335 - (ix86_initial_elimination_offset): Likewise.
336 - (ix86_expand_split_stack_prologue): Likewise.
337 ----
338 - gcc/config/i386/i386.c | 9 +++------
339 - 1 file changed, 3 insertions(+), 6 deletions(-)
340 -
341 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
342 -index 813337242d8..397ef7cac26 100644
343 ---- a/gcc/config/i386/i386.c
344 -+++ b/gcc/config/i386/i386.c
345 -@@ -11843,8 +11843,6 @@ symbolic_reference_mentioned_p (rtx op)
346 - bool
347 - ix86_can_use_return_insn_p (void)
348 - {
349 -- struct ix86_frame frame;
350 --
351 - /* Don't use `ret' instruction in interrupt handler. */
352 - if (! reload_completed
353 - || frame_pointer_needed
354 -@@ -11857,7 +11855,7 @@ ix86_can_use_return_insn_p (void)
355 - return 0;
356 -
357 - ix86_compute_frame_layout ();
358 -- frame = cfun->machine->frame;
359 -+ struct ix86_frame &frame = cfun->machine->frame;
360 - return (frame.stack_pointer_offset == UNITS_PER_WORD
361 - && (frame.nregs + frame.nsseregs) == 0);
362 - }
363 -@@ -12344,7 +12342,7 @@ HOST_WIDE_INT
364 - ix86_initial_elimination_offset (int from, int to)
365 - {
366 - ix86_compute_frame_layout ();
367 -- struct ix86_frame frame = cfun->machine->frame;
368 -+ struct ix86_frame &frame = cfun->machine->frame;
369 -
370 - if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
371 - return frame.hard_frame_pointer_offset;
372 -@@ -14860,7 +14858,6 @@ static GTY(()) rtx split_stack_fn_large;
373 - void
374 - ix86_expand_split_stack_prologue (void)
375 - {
376 -- struct ix86_frame frame;
377 - HOST_WIDE_INT allocate;
378 - unsigned HOST_WIDE_INT args_size;
379 - rtx_code_label *label;
380 -@@ -14873,7 +14870,7 @@ ix86_expand_split_stack_prologue (void)
381 -
382 - ix86_finalize_stack_realign_flags ();
383 - ix86_compute_frame_layout ();
384 -- frame = cfun->machine->frame;
385 -+ struct ix86_frame &frame = cfun->machine->frame;
386 - allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
387 -
388 - /* This is the label we will branch to if we have enough stack
389 -
390
391 diff --git a/sys-devel/gcc/files/gcc-4.8.3-musl-fix-libc5-assumption.patch b/sys-devel/gcc/files/gcc-4.8.3-musl-fix-libc5-assumption.patch
392 deleted file mode 100644
393 index 65bc45e..0000000
394 --- a/sys-devel/gcc/files/gcc-4.8.3-musl-fix-libc5-assumption.patch
395 +++ /dev/null
396 @@ -1,11 +0,0 @@
397 ---- /var/tmp/portage/sys-devel/gcc-4.8.3-r99/work/gcc-4.8.3/boehm-gc/os_dep.c 2013-03-06 15:08:58.000000000 +0000
398 -+++ gcc-4.8.3.new/boehm-gc/os_dep.c 2014-10-24 18:25:39.963379871 +0000
399 -@@ -41,7 +41,7 @@
400 - # else /* not 2 <= __GLIBC__ */
401 - /* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
402 - /* one. Check LINUX_VERSION_CODE to see which we should reference. */
403 --# include <asm/sigcontext.h>
404 -+//# include <asm/sigcontext.h>
405 - # endif /* 2 <= __GLIBC__ */
406 - # endif
407 - # endif
408
409 diff --git a/sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch b/sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch
410 deleted file mode 100644
411 index 4a5df48..0000000
412 --- a/sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch
413 +++ /dev/null
414 @@ -1,30 +0,0 @@
415 -diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
416 -index 901001b..321fcd3 100644
417 ---- a/gcc/config/i386/pmm_malloc.h
418 -+++ b/gcc/config/i386/pmm_malloc.h
419 -@@ -27,12 +27,13 @@
420 - #include <stdlib.h>
421 -
422 - /* We can't depend on <stdlib.h> since the prototype of posix_memalign
423 -- may not be visible. */
424 -+ may not be visible and we can't pollute the namespace either. */
425 - #ifndef __cplusplus
426 --extern int posix_memalign (void **, size_t, size_t);
427 -+extern int __gcc_posix_memalign (void **, size_t, size_t)
428 - #else
429 --extern "C" int posix_memalign (void **, size_t, size_t) throw ();
430 -+extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
431 - #endif
432 -+__asm__("posix_memalign");
433 -
434 - static __inline void *
435 - _mm_malloc (size_t size, size_t alignment)
436 -@@ -42,7 +43,7 @@ _mm_malloc (size_t size, size_t alignment)
437 - return malloc (size);
438 - if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
439 - alignment = sizeof (void *);
440 -- if (posix_memalign (&ptr, alignment, size) == 0)
441 -+ if (__gcc_posix_memalign (&ptr, alignment, size) == 0)
442 - return ptr;
443 - else
444 - return NULL;
445
446 diff --git a/sys-devel/gcc/files/gcc-4.9.3-musl-linker-path.patch b/sys-devel/gcc/files/gcc-4.9.3-musl-linker-path.patch
447 deleted file mode 100644
448 index 2fc076a..0000000
449 --- a/sys-devel/gcc/files/gcc-4.9.3-musl-linker-path.patch
450 +++ /dev/null
451 @@ -1,74 +0,0 @@
452 -diff -Naur gcc-4.9.3.orig/gcc/config/arm/linux-eabi.h gcc-4.9.3/gcc/config/arm/linux-eabi.h
453 ---- gcc-4.9.3.orig/gcc/config/arm/linux-eabi.h 2014-01-02 22:23:26.000000000 +0000
454 -+++ gcc-4.9.3/gcc/config/arm/linux-eabi.h 2015-10-02 19:12:32.583700214 +0000
455 -@@ -68,8 +68,8 @@
456 - GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
457 -
458 - #undef GLIBC_DYNAMIC_LINKER
459 --#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
460 --#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
461 -+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-musl-arm.so.1"
462 -+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-musl-armhf.so.1"
463 - #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
464 -
465 - #define GLIBC_DYNAMIC_LINKER \
466 -diff -Naur gcc-4.9.3.orig/gcc/config/i386/linux64.h gcc-4.9.3/gcc/config/i386/linux64.h
467 ---- gcc-4.9.3.orig/gcc/config/i386/linux64.h 2014-01-02 22:23:26.000000000 +0000
468 -+++ gcc-4.9.3/gcc/config/i386/linux64.h 2015-10-02 19:12:32.583700214 +0000
469 -@@ -27,6 +27,6 @@
470 - #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
471 - #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
472 -
473 --#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
474 --#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
475 -+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
476 -+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
477 - #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
478 -diff -Naur gcc-4.9.3.orig/gcc/config/mips/linux.h gcc-4.9.3/gcc/config/mips/linux.h
479 ---- gcc-4.9.3.orig/gcc/config/mips/linux.h 2014-01-02 22:23:26.000000000 +0000
480 -+++ gcc-4.9.3/gcc/config/mips/linux.h 2015-10-02 19:12:32.584700214 +0000
481 -@@ -17,8 +17,12 @@
482 - along with GCC; see the file COPYING3. If not see
483 - <http://www.gnu.org/licenses/>. */
484 -
485 --#define GLIBC_DYNAMIC_LINKER \
486 -- "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
487 -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
488 -+#define GLIBC_DYNAMIC_LINKER_E "%{EB:;:el}"
489 -+#else
490 -+#define GLIBC_DYNAMIC_LINKER_E "%{EL:el}"
491 -+#endif
492 -+#define GLIBC_DYNAMIC_LINKER "/lib/ld-musl-mips" GLIBC_DYNAMIC_LINKER_E ".so.1"
493 -
494 - #undef UCLIBC_DYNAMIC_LINKER
495 - #define UCLIBC_DYNAMIC_LINKER \
496 -diff -Naur gcc-4.9.3.orig/gcc/config/rs6000/linux64.h gcc-4.9.3/gcc/config/rs6000/linux64.h
497 ---- gcc-4.9.3.orig/gcc/config/rs6000/linux64.h 2015-03-09 23:19:19.000000000 +0000
498 -+++ gcc-4.9.3/gcc/config/rs6000/linux64.h 2015-10-02 19:12:32.584700214 +0000
499 -@@ -363,12 +363,8 @@
500 - #undef LINK_OS_DEFAULT_SPEC
501 - #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
502 -
503 --#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
504 --#ifdef LINUX64_DEFAULT_ABI_ELFv2
505 --#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/lib64/ld64.so.1;:/lib64/ld64.so.2}"
506 --#else
507 --#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/lib64/ld64.so.2;:/lib64/ld64.so.1}"
508 --#endif
509 -+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
510 -+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
511 - #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
512 - #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
513 - #if DEFAULT_LIBC == LIBC_UCLIBC
514 -diff -Naur gcc-4.9.3.orig/gcc/config/rs6000/sysv4.h gcc-4.9.3/gcc/config/rs6000/sysv4.h
515 ---- gcc-4.9.3.orig/gcc/config/rs6000/sysv4.h 2014-07-24 17:25:19.000000000 +0000
516 -+++ gcc-4.9.3/gcc/config/rs6000/sysv4.h 2015-10-02 19:12:32.584700214 +0000
517 -@@ -761,7 +761,7 @@
518 -
519 - #define LINK_START_LINUX_SPEC ""
520 -
521 --#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
522 -+#define GLIBC_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
523 - #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
524 - #if DEFAULT_LIBC == LIBC_UCLIBC
525 - #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
526
527 diff --git a/sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch b/sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch
528 deleted file mode 100644
529 index 363020d..0000000
530 --- a/sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch
531 +++ /dev/null
532 @@ -1,12 +0,0 @@
533 -diff -Naur gcc-4.9.3.orig/libsanitizer/tsan/tsan_platform_linux.cc gcc-4.9.3/libsanitizer/tsan/tsan_platform_linux.cc
534 ---- gcc-4.9.3.orig/libsanitizer/tsan/tsan_platform_linux.cc 2013-12-05 09:18:38.000000000 +0000
535 -+++ gcc-4.9.3/libsanitizer/tsan/tsan_platform_linux.cc 2015-10-02 19:19:15.765680892 +0000
536 -@@ -351,7 +351,7 @@
537 - // closes within glibc. The code is a pure hack.
538 - int ExtractResolvFDs(void *state, int *fds, int nfd) {
539 - int cnt = 0;
540 -- __res_state *statp = (__res_state*)state;
541 -+ res_state statp = (res_state)state;
542 - for (int i = 0; i < MAXNS && cnt < nfd; i++) {
543 - if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
544 - fds[cnt++] = statp->_u._ext.nssocks[i];
545
546 diff --git a/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch b/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch
547 deleted file mode 100644
548 index f1a7464..0000000
549 --- a/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch
550 +++ /dev/null
551 @@ -1,58 +0,0 @@
552 -diff --git a/gcc-4.9.3.orig/gcc/ipa-split.c b/gcc-4.9.3/gcc/ipa-split.c
553 -index 0d1495d..688c954 100644
554 ---- a/gcc-4.9.3.orig/gcc/ipa-split.c
555 -+++ b/gcc-4.9.3/gcc/ipa-split.c
556 -@@ -1122,7 +1122,6 @@ split_function (struct split_point *split_point)
557 - edge e;
558 - edge_iterator ei;
559 - tree retval = NULL, real_retval = NULL;
560 -- bool split_part_return_p = false;
561 - gimple last_stmt = NULL;
562 - unsigned int i;
563 - tree arg, ddef;
564 -@@ -1162,12 +1161,28 @@ split_function (struct split_point *split_point)
565 - args_to_pass.safe_push (arg);
566 - }
567 -
568 -- /* See if the split function will return. */
569 -+ /* See if the split function or the main part will return. */
570 -+ bool main_part_return_p = false;
571 -+ bool split_part_return_p = false;
572 - FOR_EACH_EDGE (e, ei, return_bb->preds)
573 -- if (bitmap_bit_p (split_point->split_bbs, e->src->index))
574 -- break;
575 -- if (e)
576 -- split_part_return_p = true;
577 -+ {
578 -+ if (bitmap_bit_p (split_point->split_bbs, e->src->index))
579 -+ split_part_return_p = true;
580 -+ else
581 -+ main_part_return_p = true;
582 -+ }
583 -+ /* The main part also returns if we we split on a fallthru edge
584 -+ and the split part returns. */
585 -+ if (split_part_return_p)
586 -+ FOR_EACH_EDGE (e, ei, split_point->entry_bb->preds)
587 -+ {
588 -+ if (! bitmap_bit_p (split_point->split_bbs, e->src->index)
589 -+ && single_succ_p (e->src))
590 -+ {
591 -+ main_part_return_p = true;
592 -+ break;
593 -+ }
594 -+ }
595 -
596 - /* Add return block to what will become the split function.
597 - We do not return; no return block is needed. */
598 -@@ -1212,6 +1227,11 @@ split_function (struct split_point *split_point)
599 - else
600 - bitmap_set_bit (split_point->split_bbs, return_bb->index);
601 -
602 -+ /* If the main part doesn't return pretend the return block wasn't
603 -+ found for all of the following. */
604 -+ if (! main_part_return_p)
605 -+ return_bb = EXIT_BLOCK_PTR_FOR_FN (cfun);
606 -+
607 - /* If RETURN_BB has virtual operand PHIs, they must be removed and the
608 - virtual operand marked for renaming as we change the CFG in a way that
609 - tree-inline is not able to compensate for.
610
611 diff --git a/sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch b/sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch
612 deleted file mode 100644
613 index bc52cec..0000000
614 --- a/sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch
615 +++ /dev/null
616 @@ -1,39 +0,0 @@
617 -diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h
618 -index b463463..77edf2a 100644
619 ---- a/gcc/config/rs6000/secureplt.h
620 -+++ b/gcc/config/rs6000/secureplt.h
621 -@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. If not see
622 - <http://www.gnu.org/licenses/>. */
623 -
624 - #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
625 -+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
626 -diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
627 -index 7b2f9bd..c77bf5c 100644
628 ---- a/gcc/config/rs6000/sysv4.h
629 -+++ b/gcc/config/rs6000/sysv4.h
630 -@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
631 - #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
632 - #define CC1_SECURE_PLT_DEFAULT_SPEC ""
633 - #endif
634 -+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
635 -+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
636 -+#endif
637 -
638 - /* Pass -G xxx to the compiler. */
639 - #undef CC1_SPEC
640 -@@ -574,6 +577,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
641 - %{R*} \
642 - %(link_shlib) \
643 - %{!T*: %(link_start) } \
644 -+%{!static: %(link_secure_plt_default)} \
645 - %(link_target) \
646 - %(link_os)"
647 -
648 -@@ -889,6 +893,7 @@ ncrtn.o%s"
649 - { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
650 - { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
651 - { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
652 -+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
653 - { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
654 - { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
655 - { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
656
657 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/aarch64.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/aarch64.diff
658 deleted file mode 100644
659 index 90eb4fa..0000000
660 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/aarch64.diff
661 +++ /dev/null
662 @@ -1,12 +0,0 @@
663 -diff -r 7c6d89fb1832 gcc/config/aarch64/aarch64-linux.h
664 ---- a/gcc/config/aarch64/aarch64-linux.h Sun Jul 26 15:32:28 2015 -0400
665 -+++ b/gcc/config/aarch64/aarch64-linux.h Sun Jul 26 15:32:30 2015 -0400
666 -@@ -23,6 +23,8 @@
667 -
668 - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}.so.1"
669 -
670 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
671 -+
672 - #define CPP_SPEC "%{pthread:-D_REENTRANT}"
673 -
674 - #define LINUX_TARGET_LINK_SPEC "%{h*} \
675
676 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/arm.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/arm.diff
677 deleted file mode 100644
678 index 777e0f6..0000000
679 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/arm.diff
680 +++ /dev/null
681 @@ -1,46 +0,0 @@
682 -# HG changeset patch
683 -# Parent 92d83561106d17ca896328fcb4ec36cd4e2e9e16
684 -Support for arm-linux-musl.
685 -
686 -diff -r 92d83561106d gcc/config/arm/linux-eabi.h
687 ---- a/gcc/config/arm/linux-eabi.h Sun Jul 26 15:32:23 2015 -0400
688 -+++ b/gcc/config/arm/linux-eabi.h Sun Jul 26 15:32:25 2015 -0400
689 -@@ -77,6 +77,23 @@
690 - %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
691 - %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
692 -
693 -+/* For ARM musl currently supports four dynamic linkers:
694 -+ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
695 -+ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
696 -+ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
697 -+ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
698 -+ musl does not support the legacy OABI mode.
699 -+ All the dynamic linkers live in /lib.
700 -+ We default to soft-float, EL. */
701 -+#undef MUSL_DYNAMIC_LINKER
702 -+#if TARGET_BIG_ENDIAN_DEFAULT
703 -+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
704 -+#else
705 -+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
706 -+#endif
707 -+#define MUSL_DYNAMIC_LINKER \
708 -+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
709 -+
710 - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
711 - use the GNU/Linux version, not the generic BPABI version. */
712 - #undef LINK_SPEC
713 -diff -r 92d83561106d libitm/config/arm/hwcap.cc
714 ---- a/libitm/config/arm/hwcap.cc Sun Jul 26 15:32:23 2015 -0400
715 -+++ b/libitm/config/arm/hwcap.cc Sun Jul 26 15:32:25 2015 -0400
716 -@@ -40,7 +40,11 @@
717 -
718 - #ifdef __linux__
719 - #include <unistd.h>
720 -+#ifdef __GLIBC__
721 - #include <sys/fcntl.h>
722 -+#else
723 -+#include <fcntl.h>
724 -+#endif
725 - #include <elf.h>
726 -
727 - static void __attribute__((constructor))
728
729 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff
730 deleted file mode 100644
731 index dba0077..0000000
732 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff
733 +++ /dev/null
734 @@ -1,62 +0,0 @@
735 -diff -r 3baeaed6c155 gcc/configure
736 ---- a/gcc/configure Sun Jul 26 15:32:15 2015 -0400
737 -+++ b/gcc/configure Sun Jul 26 15:32:17 2015 -0400
738 -@@ -27449,6 +27449,9 @@
739 - else
740 - gcc_cv_libc_provides_ssp=no
741 - case "$target" in
742 -+ *-*-musl*)
743 -+ # All versions of musl provide stack protector
744 -+ gcc_cv_libc_provides_ssp=yes;;
745 - *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
746 - # glibc 2.4 and later provides __stack_chk_fail and
747 - # either __stack_chk_guard, or TLS access to stack guard canary.
748 -@@ -27481,6 +27484,7 @@
749 - # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
750 - # simply assert that glibc does provide this, which is true for all
751 - # realistically usable GNU/Hurd configurations.
752 -+ # All supported versions of musl provide it as well
753 - gcc_cv_libc_provides_ssp=yes;;
754 - *-*-darwin* | *-*-freebsd*)
755 - ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
756 -@@ -27570,6 +27574,9 @@
757 - gcc_cv_target_dl_iterate_phdr=no
758 - fi
759 - ;;
760 -+ *-linux-musl*)
761 -+ gcc_cv_target_dl_iterate_phdr=yes
762 -+ ;;
763 - esac
764 -
765 - if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
766 -diff -r 3baeaed6c155 gcc/configure.ac
767 ---- a/gcc/configure.ac Sun Jul 26 15:32:15 2015 -0400
768 -+++ b/gcc/configure.ac Sun Jul 26 15:32:17 2015 -0400
769 -@@ -5076,6 +5076,9 @@
770 - gcc_cv_libc_provides_ssp,
771 - [gcc_cv_libc_provides_ssp=no
772 - case "$target" in
773 -+ *-*-musl*)
774 -+ # All versions of musl provide stack protector
775 -+ gcc_cv_libc_provides_ssp=yes;;
776 - *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
777 - # glibc 2.4 and later provides __stack_chk_fail and
778 - # either __stack_chk_guard, or TLS access to stack guard canary.
779 -@@ -5102,6 +5105,7 @@
780 - # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
781 - # simply assert that glibc does provide this, which is true for all
782 - # realistically usable GNU/Hurd configurations.
783 -+ # All supported versions of musl provide it as well
784 - gcc_cv_libc_provides_ssp=yes;;
785 - *-*-darwin* | *-*-freebsd*)
786 - AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
787 -@@ -5168,6 +5172,9 @@
788 - gcc_cv_target_dl_iterate_phdr=no
789 - fi
790 - ;;
791 -+ *-linux-musl*)
792 -+ gcc_cv_target_dl_iterate_phdr=yes
793 -+ ;;
794 - esac
795 - GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
796 - if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
797
798 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-config-musl.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-config-musl.diff
799 deleted file mode 100644
800 index e635573..0000000
801 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-config-musl.diff
802 +++ /dev/null
803 @@ -1,207 +0,0 @@
804 -# HG changeset patch
805 -# Parent fef9a6ed009159f294d8524a0bc1dda731990754
806 -Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
807 -
808 -diff -r fef9a6ed0091 gcc/config.gcc
809 ---- a/gcc/config.gcc Sun Jul 26 15:32:09 2015 -0400
810 -+++ b/gcc/config.gcc Sun Jul 26 15:32:11 2015 -0400
811 -@@ -594,7 +594,7 @@
812 - esac
813 -
814 - # Common C libraries.
815 --tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
816 -+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
817 -
818 - # 32-bit x86 processors supported by --with-arch=. Each processor
819 - # MUST be separated by exactly one space.
820 -@@ -719,6 +719,9 @@
821 - *-*-*uclibc*)
822 - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
823 - ;;
824 -+ *-*-*musl*)
825 -+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
826 -+ ;;
827 - *)
828 - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
829 - ;;
830 -diff -r fef9a6ed0091 gcc/config/linux.h
831 ---- a/gcc/config/linux.h Sun Jul 26 15:32:09 2015 -0400
832 -+++ b/gcc/config/linux.h Sun Jul 26 15:32:11 2015 -0400
833 -@@ -32,10 +32,12 @@
834 - #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
835 - #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
836 - #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
837 -+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
838 - #else
839 - #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
840 - #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
841 - #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
842 -+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
843 - #endif
844 -
845 - #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
846 -@@ -53,18 +55,21 @@
847 - uClibc or Bionic is the default C library and whether
848 - -muclibc or -mglibc or -mbionic has been passed to change the default. */
849 -
850 --#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
851 -- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
852 -+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
853 -+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
854 -
855 - #if DEFAULT_LIBC == LIBC_GLIBC
856 --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
857 -- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
858 -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
859 -+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
860 - #elif DEFAULT_LIBC == LIBC_UCLIBC
861 --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
862 -- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
863 -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
864 -+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
865 - #elif DEFAULT_LIBC == LIBC_BIONIC
866 --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
867 -- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
868 -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
869 -+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
870 -+#elif DEFAULT_LIBC == LIBC_MUSL
871 -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
872 -+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
873 - #else
874 - #error "Unsupported DEFAULT_LIBC"
875 - #endif /* DEFAULT_LIBC */
876 -@@ -84,21 +89,92 @@
877 -
878 - #define GNU_USER_DYNAMIC_LINKER \
879 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
880 -- BIONIC_DYNAMIC_LINKER)
881 -+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
882 - #define GNU_USER_DYNAMIC_LINKER32 \
883 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
884 -- BIONIC_DYNAMIC_LINKER32)
885 -+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
886 - #define GNU_USER_DYNAMIC_LINKER64 \
887 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
888 -- BIONIC_DYNAMIC_LINKER64)
889 -+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
890 - #define GNU_USER_DYNAMIC_LINKERX32 \
891 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
892 -- BIONIC_DYNAMIC_LINKERX32)
893 -+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
894 -
895 - /* Whether we have Bionic libc runtime */
896 - #undef TARGET_HAS_BIONIC
897 - #define TARGET_HAS_BIONIC (OPTION_BIONIC)
898 -
899 -+/* musl avoids problematic includes by rearranging the include directories.
900 -+ * Unfortunately, this is mostly duplicated from cppdefault.c */
901 -+#if DEFAULT_LIBC == LIBC_MUSL
902 -+#define INCLUDE_DEFAULTS_MUSL_GPP \
903 -+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
904 -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
905 -+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
906 -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
907 -+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
908 -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
909 -+
910 -+#ifdef LOCAL_INCLUDE_DIR
911 -+#define INCLUDE_DEFAULTS_MUSL_LOCAL \
912 -+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
913 -+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
914 -+#else
915 -+#define INCLUDE_DEFAULTS_MUSL_LOCAL
916 -+#endif
917 -+
918 -+#ifdef PREFIX_INCLUDE_DIR
919 -+#define INCLUDE_DEFAULTS_MUSL_PREFIX \
920 -+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
921 -+#else
922 -+#define INCLUDE_DEFAULTS_MUSL_PREFIX
923 -+#endif
924 -+
925 -+#ifdef CROSS_INCLUDE_DIR
926 -+#define INCLUDE_DEFAULTS_MUSL_CROSS \
927 -+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
928 -+#else
929 -+#define INCLUDE_DEFAULTS_MUSL_CROSS
930 -+#endif
931 -+
932 -+#ifdef TOOL_INCLUDE_DIR
933 -+#define INCLUDE_DEFAULTS_MUSL_TOOL \
934 -+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
935 -+#else
936 -+#define INCLUDE_DEFAULTS_MUSL_TOOL
937 -+#endif
938 -+
939 -+#ifdef NATIVE_SYSTEM_HEADER_DIR
940 -+#define INCLUDE_DEFAULTS_MUSL_NATIVE \
941 -+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
942 -+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
943 -+#else
944 -+#define INCLUDE_DEFAULTS_MUSL_NATIVE
945 -+#endif
946 -+
947 -+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
948 -+# undef INCLUDE_DEFAULTS_MUSL_LOCAL
949 -+# define INCLUDE_DEFAULTS_MUSL_LOCAL
950 -+# undef INCLUDE_DEFAULTS_MUSL_NATIVE
951 -+# define INCLUDE_DEFAULTS_MUSL_NATIVE
952 -+#else
953 -+# undef INCLUDE_DEFAULTS_MUSL_CROSS
954 -+# define INCLUDE_DEFAULTS_MUSL_CROSS
955 -+#endif
956 -+
957 -+#undef INCLUDE_DEFAULTS
958 -+#define INCLUDE_DEFAULTS \
959 -+ { \
960 -+ INCLUDE_DEFAULTS_MUSL_GPP \
961 -+ INCLUDE_DEFAULTS_MUSL_PREFIX \
962 -+ INCLUDE_DEFAULTS_MUSL_CROSS \
963 -+ INCLUDE_DEFAULTS_MUSL_TOOL \
964 -+ INCLUDE_DEFAULTS_MUSL_NATIVE \
965 -+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
966 -+ { 0, 0, 0, 0, 0, 0 } \
967 -+ }
968 -+#endif
969 -+
970 - #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
971 - /* This is a *uclinux* target. We don't define below macros to normal linux
972 - versions, because doing so would require *uclinux* targets to include
973 -diff -r fef9a6ed0091 gcc/config/linux.opt
974 ---- a/gcc/config/linux.opt Sun Jul 26 15:32:09 2015 -0400
975 -+++ b/gcc/config/linux.opt Sun Jul 26 15:32:11 2015 -0400
976 -@@ -30,3 +30,7 @@
977 - muclibc
978 - Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
979 - Use uClibc C library
980 -+
981 -+mmusl
982 -+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
983 -+Use musl C library
984 -diff -r fef9a6ed0091 gcc/ginclude/stddef.h
985 ---- a/gcc/ginclude/stddef.h Sun Jul 26 15:32:09 2015 -0400
986 -+++ b/gcc/ginclude/stddef.h Sun Jul 26 15:32:11 2015 -0400
987 -@@ -181,6 +181,7 @@
988 - #ifndef _GCC_SIZE_T
989 - #ifndef _SIZET_
990 - #ifndef __size_t
991 -+#ifndef __DEFINED_size_t /* musl */
992 - #define __size_t__ /* BeOS */
993 - #define __SIZE_T__ /* Cray Unicos/Mk */
994 - #define _SIZE_T
995 -@@ -197,6 +198,7 @@
996 - #define ___int_size_t_h
997 - #define _GCC_SIZE_T
998 - #define _SIZET_
999 -+#define __DEFINED_size_t /* musl */
1000 - #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
1001 - || defined(__FreeBSD_kernel__)
1002 - /* __size_t is a typedef on FreeBSD 5, must not trash it. */
1003 -@@ -214,6 +216,7 @@
1004 - typedef long ssize_t;
1005 - #endif /* __BEOS__ */
1006 - #endif /* !(defined (__GNUG__) && defined (size_t)) */
1007 -+#endif /* __DEFINED_size_t */
1008 - #endif /* __size_t */
1009 - #endif /* _SIZET_ */
1010 - #endif /* _GCC_SIZE_T */
1011
1012 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff
1013 deleted file mode 100644
1014 index 7846623..0000000
1015 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff
1016 +++ /dev/null
1017 @@ -1,12 +0,0 @@
1018 -diff -r 581c4dd64733 gcc/gcc.c
1019 ---- a/gcc/gcc.c Sun Jul 26 15:32:17 2015 -0400
1020 -+++ b/gcc/gcc.c Sun Jul 26 15:32:19 2015 -0400
1021 -@@ -670,7 +670,7 @@
1022 -
1023 - #ifndef LINK_SSP_SPEC
1024 - #ifdef TARGET_LIBC_PROVIDES_SSP
1025 --#define LINK_SSP_SPEC "%{fstack-protector:}"
1026 -+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared}"
1027 - #else
1028 - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
1029 - #endif
1030
1031 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gomp-posix.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gomp-posix.diff
1032 deleted file mode 100644
1033 index 7b80fdf..0000000
1034 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gomp-posix.diff
1035 +++ /dev/null
1036 @@ -1,16 +0,0 @@
1037 -# HG changeset patch
1038 -# Parent 47dcb1f7b3a9c1b5d6b9d56303e7603fbe5a51f9
1039 -A fix for libgomp to correctly request a POSIX version for time support.
1040 -
1041 -diff -r 47dcb1f7b3a9 libgomp/config/posix/time.c
1042 ---- a/libgomp/config/posix/time.c Sun Jul 26 15:32:11 2015 -0400
1043 -+++ b/libgomp/config/posix/time.c Sun Jul 26 15:32:13 2015 -0400
1044 -@@ -28,6 +28,8 @@
1045 - The following implementation uses the most simple POSIX routines.
1046 - If present, POSIX 4 clocks should be used instead. */
1047 -
1048 -+#define _POSIX_C_SOURCE 199309L /* for clocks */
1049 -+
1050 - #include "libgomp.h"
1051 - #include <unistd.h>
1052 - #if TIME_WITH_SYS_TIME
1053
1054 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gthread.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gthread.diff
1055 deleted file mode 100644
1056 index af74e50..0000000
1057 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gthread.diff
1058 +++ /dev/null
1059 @@ -1,16 +0,0 @@
1060 -Do not use weak references on any targets for gthread. Necessary on musl, safe elsewhere.
1061 -
1062 -diff -r d2b373a6ad39 libgcc/gthr.h
1063 ---- a/libgcc/gthr.h Thu Jan 29 18:59:33 2015 -0500
1064 -+++ b/libgcc/gthr.h Thu Jan 29 19:00:03 2015 -0500
1065 -@@ -136,10 +136,8 @@
1066 - /* The pe-coff weak support isn't fully compatible to ELF's weak.
1067 - For static libraries it might would work, but as we need to deal
1068 - with shared versions too, we disable it for mingw-targets. */
1069 --#ifdef __MINGW32__
1070 - #undef GTHREAD_USE_WEAK
1071 - #define GTHREAD_USE_WEAK 0
1072 --#endif
1073 -
1074 - #ifndef GTHREAD_USE_WEAK
1075 - #define GTHREAD_USE_WEAK 1
1076
1077 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/kill-fixincludes.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/kill-fixincludes.diff
1078 deleted file mode 100644
1079 index b8f8d0c..0000000
1080 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/kill-fixincludes.diff
1081 +++ /dev/null
1082 @@ -1,17 +0,0 @@
1083 -# HG changeset patch
1084 -# Parent 9f2f4e02fced4d4810910db6cced26ed0d47c23f
1085 -Get rid of ever-broken fixincludes on musl.
1086 -
1087 -diff -r 9f2f4e02fced fixincludes/mkfixinc.sh
1088 ---- a/fixincludes/mkfixinc.sh Sun Jul 26 15:32:19 2015 -0400
1089 -+++ b/fixincludes/mkfixinc.sh Sun Jul 26 15:32:21 2015 -0400
1090 -@@ -19,7 +19,8 @@
1091 - powerpc-*-eabi* | \
1092 - powerpc-*-rtems* | \
1093 - powerpcle-*-eabisim* | \
1094 -- powerpcle-*-eabi* )
1095 -+ powerpcle-*-eabi* | \
1096 -+ *-musl* )
1097 - # IF there is no include fixing,
1098 - # THEN create a no-op fixer and exit
1099 - (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
1100
1101 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/libstdc++-generic.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/libstdc++-generic.diff
1102 deleted file mode 100644
1103 index de7acff..0000000
1104 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/libstdc++-generic.diff
1105 +++ /dev/null
1106 @@ -1,31 +0,0 @@
1107 -# HG changeset patch
1108 -# Parent 889b7d97216603795ba8c5f4da8e616bef8feb9d
1109 -Use the generic implementation of libstdc++ primitives when we're on musl, not the glibc one.
1110 -
1111 -diff -r 889b7d972166 libstdc++-v3/configure.host
1112 ---- a/libstdc++-v3/configure.host Sun Jul 26 15:30:11 2015 -0400
1113 -+++ b/libstdc++-v3/configure.host Sun Jul 26 15:32:09 2015 -0400
1114 -@@ -266,6 +266,13 @@
1115 - os_include_dir="os/bsd/freebsd"
1116 - ;;
1117 - gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
1118 -+ # check for musl by target
1119 -+ case "${host_os}" in
1120 -+ *-musl*)
1121 -+ os_include_dir="os/generic"
1122 -+ ;;
1123 -+ *)
1124 -+
1125 - if [ "$uclibc" = "yes" ]; then
1126 - os_include_dir="os/uclibc"
1127 - elif [ "$bionic" = "yes" ]; then
1128 -@@ -274,6 +281,9 @@
1129 - os_include_dir="os/gnu-linux"
1130 - fi
1131 - ;;
1132 -+
1133 -+ esac
1134 -+ ;;
1135 - hpux*)
1136 - os_include_dir="os/hpux"
1137 - ;;
1138
1139 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze-size_t.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze-size_t.diff
1140 deleted file mode 100644
1141 index 9ddc092..0000000
1142 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze-size_t.diff
1143 +++ /dev/null
1144 @@ -1,39 +0,0 @@
1145 -From 478ee0c03a08e2ef9371fd88d516738936943e78 Mon Sep 17 00:00:00 2001
1146 -From: David Holsgrove <david.holsgrove@××××××.com>
1147 -Date: Fri, 28 Sep 2012 16:32:03 +1000
1148 -Subject: [PATCH 06/11] [Patch, microblaze]: Add SIZE_TYPE and PTRDIFF_TYPE to
1149 - microblaze.h
1150 -
1151 -Fixes warnings like;
1152 -
1153 -warning: format '%zX' expects argument of type 'size_t',
1154 -but argument 3 has type 'unsigned int' [-Wformat]
1155 -
1156 -Changelog
1157 -
1158 -2013-03-18 David Holsgrove <david.holsgrove@××××××.com>
1159 -
1160 - * gcc/config/microblaze/microblaze.h: Define SIZE_TYPE
1161 - and PTRDIFF_TYPE.
1162 -
1163 -Signed-off-by: David Holsgrove <david.holsgrove@××××××.com>
1164 ----
1165 - gcc/config/microblaze/microblaze.h | 6 ++++++
1166 - 1 file changed, 6 insertions(+)
1167 -
1168 -diff -r 97f8346ce240 gcc/config/microblaze/microblaze.h
1169 ---- a/gcc/config/microblaze/microblaze.h Sun Jul 26 15:32:32 2015 -0400
1170 -+++ b/gcc/config/microblaze/microblaze.h Sun Jul 26 15:32:34 2015 -0400
1171 -@@ -218,6 +218,12 @@
1172 - #undef PTRDIFF_TYPE
1173 - #define PTRDIFF_TYPE "int"
1174 -
1175 -+#undef SIZE_TYPE
1176 -+#define SIZE_TYPE "unsigned int"
1177 -+
1178 -+#undef PTRDIFF_TYPE
1179 -+#define PTRDIFF_TYPE "int"
1180 -+
1181 - #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
1182 - ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
1183 - && (ALIGN) < BITS_PER_WORD \
1184
1185 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze.diff
1186 deleted file mode 100644
1187 index ac5a87f..0000000
1188 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze.diff
1189 +++ /dev/null
1190 @@ -1,31 +0,0 @@
1191 -# HG changeset patch
1192 -# Parent d548cc2d1cfea3241205efc347caec8ad78c21d4
1193 -Microblaze support (again).
1194 -
1195 -diff -r d548cc2d1cfe gcc/config/microblaze/linux.h
1196 ---- a/gcc/config/microblaze/linux.h Sun Jul 26 15:32:30 2015 -0400
1197 -+++ b/gcc/config/microblaze/linux.h Sun Jul 26 15:32:32 2015 -0400
1198 -@@ -28,7 +28,22 @@
1199 - #undef TLS_NEEDS_GOT
1200 - #define TLS_NEEDS_GOT 1
1201 -
1202 --#define DYNAMIC_LINKER "/lib/ld.so.1"
1203 -+#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
1204 -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
1205 -+#else
1206 -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
1207 -+#endif
1208 -+
1209 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
1210 -+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
1211 -+
1212 -+#if DEFAULT_LIBC == LIBC_MUSL
1213 -+#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
1214 -+#else
1215 -+#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
1216 -+#endif
1217 -+
1218 -+
1219 - #undef SUBTARGET_EXTRA_SPECS
1220 - #define SUBTARGET_EXTRA_SPECS \
1221 - { "dynamic_linker", DYNAMIC_LINKER }
1222
1223 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/mips.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/mips.diff
1224 deleted file mode 100644
1225 index 9ccc516..0000000
1226 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/mips.diff
1227 +++ /dev/null
1228 @@ -1,18 +0,0 @@
1229 -# HG changeset patch
1230 -# Parent 270d6afd029dd396b69553e1d96f35d2ebdd2f99
1231 -Support for mips-linux-musl.
1232 -
1233 -diff -r 270d6afd029d gcc/config/mips/linux.h
1234 ---- a/gcc/config/mips/linux.h Sun Jul 26 15:32:25 2015 -0400
1235 -+++ b/gcc/config/mips/linux.h Sun Jul 26 15:32:26 2015 -0400
1236 -@@ -23,3 +23,10 @@
1237 - #undef UCLIBC_DYNAMIC_LINKER
1238 - #define UCLIBC_DYNAMIC_LINKER \
1239 - "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
1240 -+
1241 -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
1242 -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
1243 -+#else
1244 -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
1245 -+#endif
1246 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
1247
1248 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/powerpc.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/powerpc.diff
1249 deleted file mode 100644
1250 index 92276e2..0000000
1251 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/powerpc.diff
1252 +++ /dev/null
1253 @@ -1,108 +0,0 @@
1254 -# HG changeset patch
1255 -# Parent 3974ad9269f7e4c5605e0bb38db7418a69e6ee95
1256 -Support for powerpc-linux-musl.
1257 -
1258 -diff -r 3974ad9269f7 gcc/config.gcc
1259 ---- a/gcc/config.gcc Sun Jul 26 15:32:26 2015 -0400
1260 -+++ b/gcc/config.gcc Sun Jul 26 15:32:28 2015 -0400
1261 -@@ -2344,6 +2344,10 @@
1262 - powerpc*-*-linux*paired*)
1263 - tm_file="${tm_file} rs6000/750cl.h" ;;
1264 - esac
1265 -+ case ${target} in
1266 -+ *-linux*-musl*)
1267 -+ enable_secureplt=yes ;;
1268 -+ esac
1269 - if test x${enable_secureplt} = xyes; then
1270 - tm_file="rs6000/secureplt.h ${tm_file}"
1271 - fi
1272 -diff -r 3974ad9269f7 gcc/config/rs6000/linux64.h
1273 ---- a/gcc/config/rs6000/linux64.h Sun Jul 26 15:32:26 2015 -0400
1274 -+++ b/gcc/config/rs6000/linux64.h Sun Jul 26 15:32:28 2015 -0400
1275 -@@ -371,17 +371,21 @@
1276 - #endif
1277 - #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
1278 - #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
1279 -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
1280 -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
1281 - #if DEFAULT_LIBC == LIBC_UCLIBC
1282 --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
1283 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
1284 - #elif DEFAULT_LIBC == LIBC_GLIBC
1285 --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
1286 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
1287 -+#elif DEFAULT_LIBC == LIBC_MUSL
1288 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
1289 - #else
1290 - #error "Unsupported DEFAULT_LIBC"
1291 - #endif
1292 - #define GNU_USER_DYNAMIC_LINKER32 \
1293 -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
1294 -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
1295 - #define GNU_USER_DYNAMIC_LINKER64 \
1296 -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
1297 -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
1298 -
1299 - #undef DEFAULT_ASM_ENDIAN
1300 - #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
1301 -diff -r 3974ad9269f7 gcc/config/rs6000/secureplt.h
1302 ---- a/gcc/config/rs6000/secureplt.h Sun Jul 26 15:32:26 2015 -0400
1303 -+++ b/gcc/config/rs6000/secureplt.h Sun Jul 26 15:32:28 2015 -0400
1304 -@@ -18,3 +18,4 @@
1305 - <http://www.gnu.org/licenses/>. */
1306 -
1307 - #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
1308 -+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
1309 -diff -r 3974ad9269f7 gcc/config/rs6000/sysv4.h
1310 ---- a/gcc/config/rs6000/sysv4.h Sun Jul 26 15:32:26 2015 -0400
1311 -+++ b/gcc/config/rs6000/sysv4.h Sun Jul 26 15:32:28 2015 -0400
1312 -@@ -537,6 +537,9 @@
1313 - #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
1314 - #define CC1_SECURE_PLT_DEFAULT_SPEC ""
1315 - #endif
1316 -+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
1317 -+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
1318 -+#endif
1319 -
1320 - /* Pass -G xxx to the compiler. */
1321 - #define CC1_SPEC "%{G*} %(cc1_cpu)" \
1322 -@@ -585,7 +588,8 @@
1323 -
1324 - /* Override the default target of the linker. */
1325 - #define LINK_TARGET_SPEC \
1326 -- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
1327 -+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
1328 -+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
1329 -
1330 - /* Any specific OS flags. */
1331 - #define LINK_OS_SPEC "\
1332 -@@ -763,15 +767,18 @@
1333 -
1334 - #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
1335 - #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
1336 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
1337 - #if DEFAULT_LIBC == LIBC_UCLIBC
1338 --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
1339 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
1340 -+#elif DEFAULT_LIBC == LIBC_MUSL
1341 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
1342 - #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
1343 --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
1344 -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
1345 - #else
1346 - #error "Unsupported DEFAULT_LIBC"
1347 - #endif
1348 - #define GNU_USER_DYNAMIC_LINKER \
1349 -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
1350 -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
1351 -
1352 - #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
1353 - %{rdynamic:-export-dynamic} \
1354 -@@ -894,6 +901,7 @@
1355 - { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
1356 - { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
1357 - { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
1358 -+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
1359 - { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
1360 - { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
1361 - { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
1362
1363 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff
1364 deleted file mode 100644
1365 index f7be443..0000000
1366 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff
1367 +++ /dev/null
1368 @@ -1,18 +0,0 @@
1369 -diff -r c5b39ce7672b gcc/config/sh/linux.h
1370 ---- a/gcc/config/sh/linux.h Fri Sep 28 16:32:03 2012 +1000
1371 -+++ b/gcc/config/sh/linux.h Sun Jul 26 15:32:36 2015 -0400
1372 -@@ -43,7 +43,14 @@
1373 -
1374 - #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
1375 -
1376 -+#if TARGET_BIG_ENDIAN_DEFAULT /* BE */
1377 -+#define MUSL_DYNAMIC_LINKER_E "eb"
1378 -+#else
1379 -+#define MUSL_DYNAMIC_LINKER_E
1380 -+#endif
1381 -+
1382 - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
1383 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
1384 -
1385 - #undef SUBTARGET_LINK_EMUL_SUFFIX
1386 - #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
1387
1388 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/unwind-dliterate.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/unwind-dliterate.diff
1389 deleted file mode 100644
1390 index 2add290..0000000
1391 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/unwind-dliterate.diff
1392 +++ /dev/null
1393 @@ -1,43 +0,0 @@
1394 -diff -r ddc4b4034e51 libgcc/unwind-dw2-fde-dip.c
1395 ---- a/libgcc/unwind-dw2-fde-dip.c Sun Jul 26 15:32:13 2015 -0400
1396 -+++ b/libgcc/unwind-dw2-fde-dip.c Sun Jul 26 15:32:15 2015 -0400
1397 -@@ -46,33 +46,13 @@
1398 - #include "unwind-compat.h"
1399 - #include "gthr.h"
1400 -
1401 --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
1402 -- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
1403 -- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
1404 -+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
1405 - # define USE_PT_GNU_EH_FRAME
1406 --#endif
1407 --
1408 --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
1409 -- && defined(__BIONIC__)
1410 --# define USE_PT_GNU_EH_FRAME
1411 --#endif
1412 --
1413 --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
1414 -- && defined(__FreeBSD__) && __FreeBSD__ >= 7
1415 --# define ElfW __ElfN
1416 --# define USE_PT_GNU_EH_FRAME
1417 --#endif
1418 --
1419 --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
1420 -- && defined(__OpenBSD__)
1421 --# define ElfW(type) Elf_##type
1422 --# define USE_PT_GNU_EH_FRAME
1423 --#endif
1424 --
1425 --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
1426 -- && defined(TARGET_DL_ITERATE_PHDR) \
1427 -- && defined(__sun__) && defined(__svr4__)
1428 --# define USE_PT_GNU_EH_FRAME
1429 -+# ifdef __OpenBSD__
1430 -+# define ElfW(type) Elf_##type
1431 -+# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
1432 -+# define ElfW __ElfN
1433 -+# endif
1434 - #endif
1435 -
1436 - #if defined(USE_PT_GNU_EH_FRAME)
1437
1438 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff
1439 deleted file mode 100644
1440 index 16df34a..0000000
1441 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff
1442 +++ /dev/null
1443 @@ -1,15 +0,0 @@
1444 -Fix hidden visibility of libgcc.a symbols when building gcc stage 2 with
1445 - --disable-shared, as per musl ml:
1446 -http://www.openwall.com/lists/musl/2014/01/12/4
1447 -
1448 -diff -Naur gcc-4.7.3.orig/libgcc/Makefile.in gcc-4.7.3/libgcc/Makefile.in
1449 ---- gcc-4.7.3.orig/libgcc/Makefile.in 2012-12-04 14:09:59.000000000 -0500
1450 -+++ gcc-4.7.3/libgcc/Makefile.in 2014-02-27 08:33:31.537611370 -0500
1451 -@@ -388,7 +388,7 @@
1452 - else
1453 - # Not enable_shared.
1454 - iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
1455 --vis_hide =
1456 -+vis_hide = @vis_hide@
1457 - gen-hide-list = echo > \$@
1458 - endif
1459
1460 diff --git a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/x86.diff b/sys-devel/gcc/files/musl-gcc-patches-4.9.3/x86.diff
1461 deleted file mode 100644
1462 index f62f27e..0000000
1463 --- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/x86.diff
1464 +++ /dev/null
1465 @@ -1,55 +0,0 @@
1466 -# HG changeset patch
1467 -# Parent ab9383ed51ae0c261e0c860fc6b953eb57976eef
1468 -Support for i386-linux-musl and x86_64-linux-musl.
1469 -
1470 -diff -r ab9383ed51ae gcc/config/i386/linux.h
1471 ---- a/gcc/config/i386/linux.h Sun Jul 26 15:32:21 2015 -0400
1472 -+++ b/gcc/config/i386/linux.h Sun Jul 26 15:32:23 2015 -0400
1473 -@@ -21,3 +21,4 @@
1474 -
1475 - #define GNU_USER_LINK_EMULATION "elf_i386"
1476 - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
1477 -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
1478 -diff -r ab9383ed51ae gcc/config/i386/linux64.h
1479 ---- a/gcc/config/i386/linux64.h Sun Jul 26 15:32:21 2015 -0400
1480 -+++ b/gcc/config/i386/linux64.h Sun Jul 26 15:32:23 2015 -0400
1481 -@@ -30,3 +30,7 @@
1482 - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
1483 - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
1484 - #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
1485 -+
1486 -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
1487 -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
1488 -+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
1489 -diff -r ab9383ed51ae libitm/config/linux/x86/tls.h
1490 ---- a/libitm/config/linux/x86/tls.h Sun Jul 26 15:32:21 2015 -0400
1491 -+++ b/libitm/config/linux/x86/tls.h Sun Jul 26 15:32:23 2015 -0400
1492 -@@ -25,16 +25,19 @@
1493 - #ifndef LIBITM_X86_TLS_H
1494 - #define LIBITM_X86_TLS_H 1
1495 -
1496 --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
1497 -+#if defined(__GLIBC_PREREQ)
1498 -+#if __GLIBC_PREREQ(2, 10)
1499 - /* Use slots in the TCB head rather than __thread lookups.
1500 - GLIBC has reserved words 10 through 13 for TM. */
1501 - #define HAVE_ARCH_GTM_THREAD 1
1502 - #define HAVE_ARCH_GTM_THREAD_DISP 1
1503 - #endif
1504 -+#endif
1505 -
1506 - #include "config/generic/tls.h"
1507 -
1508 --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
1509 -+#if defined(__GLIBC_PREREQ)
1510 -+#if __GLIBC_PREREQ(2, 10)
1511 - namespace GTM HIDDEN {
1512 -
1513 - #ifdef __x86_64__
1514 -@@ -101,5 +104,6 @@
1515 -
1516 - } // namespace GTM
1517 - #endif /* >= GLIBC 2.10 */
1518 -+#endif
1519 -
1520 - #endif // LIBITM_X86_TLS_H
1521
1522 diff --git a/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch b/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch
1523 deleted file mode 100644
1524 index c0267fa..0000000
1525 --- a/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch
1526 +++ /dev/null
1527 @@ -1,1084 +0,0 @@
1528 -From c6b72be421ded17e0c156070ba6e90aa6c335ed6 Mon Sep 17 00:00:00 2001
1529 -From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
1530 -Date: Tue, 16 Jan 2018 10:59:42 +0000
1531 -Subject: [PATCH] x86: Add -mindirect-branch=
1532 -
1533 -Add -mindirect-branch= option to convert indirect call and jump to call
1534 -and return thunks. The default is 'keep', which keeps indirect call and
1535 -jump unmodified. 'thunk' converts indirect call and jump to call and
1536 -return thunk. 'thunk-inline' converts indirect call and jump to inlined
1537 -call and return thunk. 'thunk-extern' converts indirect call and jump to
1538 -external call and return thunk provided in a separate object file. You
1539 -can control this behavior for a specific function by using the function
1540 -attribute indirect_branch.
1541 -
1542 -2 kinds of thunks are geneated. Memory thunk where the function address
1543 -is at the top of the stack:
1544 -
1545 -__x86_indirect_thunk:
1546 - call L2
1547 -L1:
1548 - pause
1549 - lfence
1550 - jmp L1
1551 -L2:
1552 - lea 8(%rsp), %rsp|lea 4(%esp), %esp
1553 - ret
1554 -
1555 -Indirect jmp via memory, "jmp mem", is converted to
1556 -
1557 - push memory
1558 - jmp __x86_indirect_thunk
1559 -
1560 -Indirect call via memory, "call mem", is converted to
1561 -
1562 - jmp L2
1563 -L1:
1564 - push [mem]
1565 - jmp __x86_indirect_thunk
1566 -L2:
1567 - call L1
1568 -
1569 -Register thunk where the function address is in a register, reg:
1570 -
1571 -__x86_indirect_thunk_reg:
1572 - call L2
1573 -L1:
1574 - pause
1575 - lfence
1576 - jmp L1
1577 -L2:
1578 - movq %reg, (%rsp)|movl %reg, (%esp)
1579 - ret
1580 -
1581 -where reg is one of (r|e)ax, (r|e)dx, (r|e)cx, (r|e)bx, (r|e)si, (r|e)di,
1582 -(r|e)bp, r8, r9, r10, r11, r12, r13, r14 and r15.
1583 -
1584 -Indirect jmp via register, "jmp reg", is converted to
1585 -
1586 - jmp __x86_indirect_thunk_reg
1587 -
1588 -Indirect call via register, "call reg", is converted to
1589 -
1590 - call __x86_indirect_thunk_reg
1591 -
1592 -gcc/
1593 -
1594 - Backport from mainline
1595 - * config/i386/i386-opts.h (indirect_branch): New.
1596 - * config/i386/i386-protos.h (ix86_output_indirect_jmp): Likewise.
1597 - * config/i386/i386.c (ix86_using_red_zone): Disallow red-zone
1598 - with local indirect jump when converting indirect call and jump.
1599 - (ix86_set_indirect_branch_type): New.
1600 - (ix86_set_current_function): Call ix86_set_indirect_branch_type.
1601 - (indirectlabelno): New.
1602 - (indirect_thunk_needed): Likewise.
1603 - (indirect_thunk_bnd_needed): Likewise.
1604 - (indirect_thunks_used): Likewise.
1605 - (indirect_thunks_bnd_used): Likewise.
1606 - (INDIRECT_LABEL): Likewise.
1607 - (indirect_thunk_name): Likewise.
1608 - (output_indirect_thunk): Likewise.
1609 - (output_indirect_thunk_function): Likewise.
1610 - (ix86_output_indirect_branch_via_reg): Likewise.
1611 - (ix86_output_indirect_branch_via_push): Likewise.
1612 - (ix86_output_indirect_branch): Likewise.
1613 - (ix86_output_indirect_jmp): Likewise.
1614 - (ix86_code_end): Call output_indirect_thunk_function if needed.
1615 - (ix86_output_call_insn): Call ix86_output_indirect_branch if
1616 - needed.
1617 - (ix86_handle_fndecl_attribute): Handle indirect_branch.
1618 - (ix86_attribute_table): Add indirect_branch.
1619 - * config/i386/i386.h (machine_function): Add indirect_branch_type
1620 - and has_local_indirect_jump.
1621 - * config/i386/i386.md (indirect_jump): Set has_local_indirect_jump
1622 - to true.
1623 - (tablejump): Likewise.
1624 - (*indirect_jump): Use ix86_output_indirect_jmp.
1625 - (*tablejump_1): Likewise.
1626 - (simple_return_indirect_internal): Likewise.
1627 - * config/i386/i386.opt (mindirect-branch=): New option.
1628 - (indirect_branch): New.
1629 - (keep): Likewise.
1630 - (thunk): Likewise.
1631 - (thunk-inline): Likewise.
1632 - (thunk-extern): Likewise.
1633 - * doc/extend.texi: Document indirect_branch function attribute.
1634 - * doc/invoke.texi: Document -mindirect-branch= option.
1635 -
1636 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256732 138bc75d-0d04-0410-961f-82ee72b054a4
1637 ----
1638 - gcc/config/i386/i386-opts.h | 13 +
1639 - gcc/config/i386/i386-protos.h | 1 +
1640 - gcc/config/i386/i386.c | 648 ++++++++++++++++++++-
1641 - gcc/config/i386/i386.h | 7 +
1642 - gcc/config/i386/i386.md | 26 +-
1643 - gcc/config/i386/i386.opt | 20 +
1644 - gcc/doc/extend.texi | 10 +
1645 - gcc/doc/invoke.texi | 14 +-
1646 - 43 files changed, 1575 insertions(+), 19 deletions(-)
1647 -
1648 -diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
1649 -index 542cd0f..efcdc3b 100644
1650 ---- a/gcc/config/i386/i386-opts.h
1651 -+++ b/gcc/config/i386/i386-opts.h
1652 -@@ -99,4 +99,17 @@ enum stack_protector_guard {
1653 - SSP_GLOBAL /* global canary */
1654 - };
1655 -
1656 -+/* This is used to mitigate variant #2 of the speculative execution
1657 -+ vulnerabilities on x86 processors identified by CVE-2017-5715, aka
1658 -+ Spectre. They convert indirect branches and function returns to
1659 -+ call and return thunks to avoid speculative execution via indirect
1660 -+ call, jmp and ret. */
1661 -+enum indirect_branch {
1662 -+ indirect_branch_unset = 0,
1663 -+ indirect_branch_keep,
1664 -+ indirect_branch_thunk,
1665 -+ indirect_branch_thunk_inline,
1666 -+ indirect_branch_thunk_extern
1667 -+};
1668 -+
1669 - #endif
1670 -diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
1671 -index d2cccf1..bcdd987 100644
1672 ---- a/gcc/config/i386/i386-protos.h
1673 -+++ b/gcc/config/i386/i386-protos.h
1674 -@@ -313,6 +313,7 @@ extern enum attr_cpu ix86_schedule;
1675 - #endif
1676 -
1677 - extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
1678 -+extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
1679 - extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
1680 - enum machine_mode mode);
1681 -
1682 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
1683 -index 1786640..7e779c1 100644
1684 ---- a/gcc/config/i386/i386.c
1685 -+++ b/gcc/config/i386/i386.c
1686 -@@ -4212,12 +4212,23 @@ make_pass_stv (gcc::context *ctxt)
1687 - return new pass_stv (ctxt);
1688 - }
1689 -
1690 --/* Return true if a red-zone is in use. */
1691 -+/* Return true if a red-zone is in use. We can't use red-zone when
1692 -+ there are local indirect jumps, like "indirect_jump" or "tablejump",
1693 -+ which jumps to another place in the function, since "call" in the
1694 -+ indirect thunk pushes the return address onto stack, destroying
1695 -+ red-zone.
1696 -+
1697 -+ TODO: If we can reserve the first 2 WORDs, for PUSH and, another
1698 -+ for CALL, in red-zone, we can allow local indirect jumps with
1699 -+ indirect thunk. */
1700 -
1701 - bool
1702 - ix86_using_red_zone (void)
1703 - {
1704 -- return TARGET_RED_ZONE && !TARGET_64BIT_MS_ABI;
1705 -+ return (TARGET_RED_ZONE
1706 -+ && !TARGET_64BIT_MS_ABI
1707 -+ && (!cfun->machine->has_local_indirect_jump
1708 -+ || cfun->machine->indirect_branch_type == indirect_branch_keep));
1709 - }
1710 -
1711 - /* Return a string that documents the current -m options. The caller is
1712 -@@ -7148,6 +7159,37 @@ ix86_set_func_type (tree fndecl)
1713 - }
1714 - }
1715 -
1716 -+/* Set the indirect_branch_type field from the function FNDECL. */
1717 -+
1718 -+static void
1719 -+ix86_set_indirect_branch_type (tree fndecl)
1720 -+{
1721 -+ if (cfun->machine->indirect_branch_type == indirect_branch_unset)
1722 -+ {
1723 -+ tree attr = lookup_attribute ("indirect_branch",
1724 -+ DECL_ATTRIBUTES (fndecl));
1725 -+ if (attr != NULL)
1726 -+ {
1727 -+ tree args = TREE_VALUE (attr);
1728 -+ if (args == NULL)
1729 -+ gcc_unreachable ();
1730 -+ tree cst = TREE_VALUE (args);
1731 -+ if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
1732 -+ cfun->machine->indirect_branch_type = indirect_branch_keep;
1733 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
1734 -+ cfun->machine->indirect_branch_type = indirect_branch_thunk;
1735 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
1736 -+ cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
1737 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
1738 -+ cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
1739 -+ else
1740 -+ gcc_unreachable ();
1741 -+ }
1742 -+ else
1743 -+ cfun->machine->indirect_branch_type = ix86_indirect_branch;
1744 -+ }
1745 -+}
1746 -+
1747 - /* Establish appropriate back-end context for processing the function
1748 - FNDECL. The argument might be NULL to indicate processing at top
1749 - level, outside of any function scope. */
1750 -@@ -7163,7 +7205,10 @@ ix86_set_current_function (tree fndecl)
1751 - one is extern inline and one isn't. Call ix86_set_func_type
1752 - to set the func_type field. */
1753 - if (fndecl != NULL_TREE)
1754 -- ix86_set_func_type (fndecl);
1755 -+ {
1756 -+ ix86_set_func_type (fndecl);
1757 -+ ix86_set_indirect_branch_type (fndecl);
1758 -+ }
1759 - return;
1760 - }
1761 -
1762 -@@ -7183,6 +7228,7 @@ ix86_set_current_function (tree fndecl)
1763 - }
1764 -
1765 - ix86_set_func_type (fndecl);
1766 -+ ix86_set_indirect_branch_type (fndecl);
1767 -
1768 - tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
1769 - if (new_tree == NULL_TREE)
1770 -@@ -11930,6 +11976,220 @@ ix86_setup_frame_addresses (void)
1771 - # endif
1772 - #endif
1773 -
1774 -+/* Label count for call and return thunks. It is used to make unique
1775 -+ labels in call and return thunks. */
1776 -+static int indirectlabelno;
1777 -+
1778 -+/* True if call and return thunk functions are needed. */
1779 -+static bool indirect_thunk_needed = false;
1780 -+/* True if call and return thunk functions with the BND prefix are
1781 -+ needed. */
1782 -+static bool indirect_thunk_bnd_needed = false;
1783 -+
1784 -+/* Bit masks of integer registers, which contain branch target, used
1785 -+ by call and return thunks functions. */
1786 -+static int indirect_thunks_used;
1787 -+/* Bit masks of integer registers, which contain branch target, used
1788 -+ by call and return thunks functions with the BND prefix. */
1789 -+static int indirect_thunks_bnd_used;
1790 -+
1791 -+#ifndef INDIRECT_LABEL
1792 -+# define INDIRECT_LABEL "LIND"
1793 -+#endif
1794 -+
1795 -+/* Fills in the label name that should be used for the indirect thunk. */
1796 -+
1797 -+static void
1798 -+indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
1799 -+{
1800 -+ if (USE_HIDDEN_LINKONCE)
1801 -+ {
1802 -+ const char *bnd = need_bnd_p ? "_bnd" : "";
1803 -+ if (regno >= 0)
1804 -+ {
1805 -+ const char *reg_prefix;
1806 -+ if (LEGACY_INT_REGNO_P (regno))
1807 -+ reg_prefix = TARGET_64BIT ? "r" : "e";
1808 -+ else
1809 -+ reg_prefix = "";
1810 -+ sprintf (name, "__x86_indirect_thunk%s_%s%s",
1811 -+ bnd, reg_prefix, reg_names[regno]);
1812 -+ }
1813 -+ else
1814 -+ sprintf (name, "__x86_indirect_thunk%s", bnd);
1815 -+ }
1816 -+ else
1817 -+ {
1818 -+ if (regno >= 0)
1819 -+ {
1820 -+ if (need_bnd_p)
1821 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno);
1822 -+ else
1823 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LITR", regno);
1824 -+ }
1825 -+ else
1826 -+ {
1827 -+ if (need_bnd_p)
1828 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
1829 -+ else
1830 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
1831 -+ }
1832 -+ }
1833 -+}
1834 -+
1835 -+/* Output a call and return thunk for indirect branch. If BND_P is
1836 -+ true, the BND prefix is needed. If REGNO != -1, the function
1837 -+ address is in REGNO and the call and return thunk looks like:
1838 -+
1839 -+ call L2
1840 -+ L1:
1841 -+ pause
1842 -+ jmp L1
1843 -+ L2:
1844 -+ mov %REG, (%sp)
1845 -+ ret
1846 -+
1847 -+ Otherwise, the function address is on the top of stack and the
1848 -+ call and return thunk looks like:
1849 -+
1850 -+ call L2
1851 -+ L1:
1852 -+ pause
1853 -+ jmp L1
1854 -+ L2:
1855 -+ lea WORD_SIZE(%sp), %sp
1856 -+ ret
1857 -+ */
1858 -+
1859 -+static void
1860 -+output_indirect_thunk (bool need_bnd_p, int regno)
1861 -+{
1862 -+ char indirectlabel1[32];
1863 -+ char indirectlabel2[32];
1864 -+
1865 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1, INDIRECT_LABEL,
1866 -+ indirectlabelno++);
1867 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2, INDIRECT_LABEL,
1868 -+ indirectlabelno++);
1869 -+
1870 -+ /* Call */
1871 -+ if (need_bnd_p)
1872 -+ fputs ("\tbnd call\t", asm_out_file);
1873 -+ else
1874 -+ fputs ("\tcall\t", asm_out_file);
1875 -+ assemble_name_raw (asm_out_file, indirectlabel2);
1876 -+ fputc ('\n', asm_out_file);
1877 -+
1878 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
1879 -+
1880 -+ /* Pause + lfence. */
1881 -+ fprintf (asm_out_file, "\tpause\n\tlfence\n");
1882 -+
1883 -+ /* Jump. */
1884 -+ fputs ("\tjmp\t", asm_out_file);
1885 -+ assemble_name_raw (asm_out_file, indirectlabel1);
1886 -+ fputc ('\n', asm_out_file);
1887 -+
1888 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
1889 -+
1890 -+ if (regno >= 0)
1891 -+ {
1892 -+ /* MOV. */
1893 -+ rtx xops[2];
1894 -+ xops[0] = gen_rtx_MEM (word_mode, stack_pointer_rtx);
1895 -+ xops[1] = gen_rtx_REG (word_mode, regno);
1896 -+ output_asm_insn ("mov\t{%1, %0|%0, %1}", xops);
1897 -+ }
1898 -+ else
1899 -+ {
1900 -+ /* LEA. */
1901 -+ rtx xops[2];
1902 -+ xops[0] = stack_pointer_rtx;
1903 -+ xops[1] = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
1904 -+ output_asm_insn ("lea\t{%E1, %0|%0, %E1}", xops);
1905 -+ }
1906 -+
1907 -+ if (need_bnd_p)
1908 -+ fputs ("\tbnd ret\n", asm_out_file);
1909 -+ else
1910 -+ fputs ("\tret\n", asm_out_file);
1911 -+}
1912 -+
1913 -+/* Output a funtion with a call and return thunk for indirect branch.
1914 -+ If BND_P is true, the BND prefix is needed. If REGNO != -1, the
1915 -+ function address is in REGNO. Otherwise, the function address is
1916 -+ on the top of stack. */
1917 -+
1918 -+static void
1919 -+output_indirect_thunk_function (bool need_bnd_p, int regno)
1920 -+{
1921 -+ char name[32];
1922 -+ tree decl;
1923 -+
1924 -+ /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
1925 -+ indirect_thunk_name (name, regno, need_bnd_p);
1926 -+ decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
1927 -+ get_identifier (name),
1928 -+ build_function_type_list (void_type_node, NULL_TREE));
1929 -+ DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL,
1930 -+ NULL_TREE, void_type_node);
1931 -+ TREE_PUBLIC (decl) = 1;
1932 -+ TREE_STATIC (decl) = 1;
1933 -+ DECL_IGNORED_P (decl) = 1;
1934 -+
1935 -+#if TARGET_MACHO
1936 -+ if (TARGET_MACHO)
1937 -+ {
1938 -+ switch_to_section (darwin_sections[picbase_thunk_section]);
1939 -+ fputs ("\t.weak_definition\t", asm_out_file);
1940 -+ assemble_name (asm_out_file, name);
1941 -+ fputs ("\n\t.private_extern\t", asm_out_file);
1942 -+ assemble_name (asm_out_file, name);
1943 -+ putc ('\n', asm_out_file);
1944 -+ ASM_OUTPUT_LABEL (asm_out_file, name);
1945 -+ DECL_WEAK (decl) = 1;
1946 -+ }
1947 -+ else
1948 -+#endif
1949 -+ if (USE_HIDDEN_LINKONCE)
1950 -+ {
1951 -+ cgraph_node::create (decl)->set_comdat_group (DECL_ASSEMBLER_NAME (decl));
1952 -+
1953 -+ targetm.asm_out.unique_section (decl, 0);
1954 -+ switch_to_section (get_named_section (decl, NULL, 0));
1955 -+
1956 -+ targetm.asm_out.globalize_label (asm_out_file, name);
1957 -+ fputs ("\t.hidden\t", asm_out_file);
1958 -+ assemble_name (asm_out_file, name);
1959 -+ putc ('\n', asm_out_file);
1960 -+ ASM_DECLARE_FUNCTION_NAME (asm_out_file, name, decl);
1961 -+ }
1962 -+ else
1963 -+ {
1964 -+ switch_to_section (text_section);
1965 -+ ASM_OUTPUT_LABEL (asm_out_file, name);
1966 -+ }
1967 -+
1968 -+ DECL_INITIAL (decl) = make_node (BLOCK);
1969 -+ current_function_decl = decl;
1970 -+ allocate_struct_function (decl, false);
1971 -+ init_function_start (decl);
1972 -+ /* We're about to hide the function body from callees of final_* by
1973 -+ emitting it directly; tell them we're a thunk, if they care. */
1974 -+ cfun->is_thunk = true;
1975 -+ first_function_block_is_cold = false;
1976 -+ /* Make sure unwind info is emitted for the thunk if needed. */
1977 -+ final_start_function (emit_barrier (), asm_out_file, 1);
1978 -+
1979 -+ output_indirect_thunk (need_bnd_p, regno);
1980 -+
1981 -+ final_end_function ();
1982 -+ init_insn_lengths ();
1983 -+ free_after_compilation (cfun);
1984 -+ set_cfun (NULL);
1985 -+ current_function_decl = NULL;
1986 -+}
1987 -+
1988 - static int pic_labels_used;
1989 -
1990 - /* Fills in the label name that should be used for a pc thunk for
1991 -@@ -11956,11 +12216,32 @@ ix86_code_end (void)
1992 - rtx xops[2];
1993 - int regno;
1994 -
1995 -+ if (indirect_thunk_needed)
1996 -+ output_indirect_thunk_function (false, -1);
1997 -+ if (indirect_thunk_bnd_needed)
1998 -+ output_indirect_thunk_function (true, -1);
1999 -+
2000 -+ for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
2001 -+ {
2002 -+ int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
2003 -+ if ((indirect_thunks_used & (1 << i)))
2004 -+ output_indirect_thunk_function (false, regno);
2005 -+
2006 -+ if ((indirect_thunks_bnd_used & (1 << i)))
2007 -+ output_indirect_thunk_function (true, regno);
2008 -+ }
2009 -+
2010 - for (regno = AX_REG; regno <= SP_REG; regno++)
2011 - {
2012 - char name[32];
2013 - tree decl;
2014 -
2015 -+ if ((indirect_thunks_used & (1 << regno)))
2016 -+ output_indirect_thunk_function (false, regno);
2017 -+
2018 -+ if ((indirect_thunks_bnd_used & (1 << regno)))
2019 -+ output_indirect_thunk_function (true, regno);
2020 -+
2021 - if (!(pic_labels_used & (1 << regno)))
2022 - continue;
2023 -
2024 -@@ -28461,12 +28742,292 @@ ix86_nopic_noplt_attribute_p (rtx call_op)
2025 - return false;
2026 - }
2027 -
2028 -+/* Output indirect branch via a call and return thunk. CALL_OP is a
2029 -+ register which contains the branch target. XASM is the assembly
2030 -+ template for CALL_OP. Branch is a tail call if SIBCALL_P is true.
2031 -+ A normal call is converted to:
2032 -+
2033 -+ call __x86_indirect_thunk_reg
2034 -+
2035 -+ and a tail call is converted to:
2036 -+
2037 -+ jmp __x86_indirect_thunk_reg
2038 -+ */
2039 -+
2040 -+static void
2041 -+ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
2042 -+{
2043 -+ char thunk_name_buf[32];
2044 -+ char *thunk_name;
2045 -+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
2046 -+ int regno = REGNO (call_op);
2047 -+
2048 -+ if (cfun->machine->indirect_branch_type
2049 -+ != indirect_branch_thunk_inline)
2050 -+ {
2051 -+ if (cfun->machine->indirect_branch_type == indirect_branch_thunk)
2052 -+ {
2053 -+ int i = regno;
2054 -+ if (i >= FIRST_REX_INT_REG)
2055 -+ i -= (FIRST_REX_INT_REG - LAST_INT_REG - 1);
2056 -+ if (need_bnd_p)
2057 -+ indirect_thunks_bnd_used |= 1 << i;
2058 -+ else
2059 -+ indirect_thunks_used |= 1 << i;
2060 -+ }
2061 -+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
2062 -+ thunk_name = thunk_name_buf;
2063 -+ }
2064 -+ else
2065 -+ thunk_name = NULL;
2066 -+
2067 -+ if (sibcall_p)
2068 -+ {
2069 -+ if (thunk_name != NULL)
2070 -+ {
2071 -+ if (need_bnd_p)
2072 -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
2073 -+ else
2074 -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
2075 -+ }
2076 -+ else
2077 -+ output_indirect_thunk (need_bnd_p, regno);
2078 -+ }
2079 -+ else
2080 -+ {
2081 -+ if (thunk_name != NULL)
2082 -+ {
2083 -+ if (need_bnd_p)
2084 -+ fprintf (asm_out_file, "\tbnd call\t%s\n", thunk_name);
2085 -+ else
2086 -+ fprintf (asm_out_file, "\tcall\t%s\n", thunk_name);
2087 -+ return;
2088 -+ }
2089 -+
2090 -+ char indirectlabel1[32];
2091 -+ char indirectlabel2[32];
2092 -+
2093 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1,
2094 -+ INDIRECT_LABEL,
2095 -+ indirectlabelno++);
2096 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2,
2097 -+ INDIRECT_LABEL,
2098 -+ indirectlabelno++);
2099 -+
2100 -+ /* Jump. */
2101 -+ if (need_bnd_p)
2102 -+ fputs ("\tbnd jmp\t", asm_out_file);
2103 -+ else
2104 -+ fputs ("\tjmp\t", asm_out_file);
2105 -+ assemble_name_raw (asm_out_file, indirectlabel2);
2106 -+ fputc ('\n', asm_out_file);
2107 -+
2108 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
2109 -+
2110 -+ if (thunk_name != NULL)
2111 -+ {
2112 -+ if (need_bnd_p)
2113 -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
2114 -+ else
2115 -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
2116 -+ }
2117 -+ else
2118 -+ output_indirect_thunk (need_bnd_p, regno);
2119 -+
2120 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
2121 -+
2122 -+ /* Call. */
2123 -+ if (need_bnd_p)
2124 -+ fputs ("\tbnd call\t", asm_out_file);
2125 -+ else
2126 -+ fputs ("\tcall\t", asm_out_file);
2127 -+ assemble_name_raw (asm_out_file, indirectlabel1);
2128 -+ fputc ('\n', asm_out_file);
2129 -+ }
2130 -+}
2131 -+
2132 -+/* Output indirect branch via a call and return thunk. CALL_OP is
2133 -+ the branch target. XASM is the assembly template for CALL_OP.
2134 -+ Branch is a tail call if SIBCALL_P is true. A normal call is
2135 -+ converted to:
2136 -+
2137 -+ jmp L2
2138 -+ L1:
2139 -+ push CALL_OP
2140 -+ jmp __x86_indirect_thunk
2141 -+ L2:
2142 -+ call L1
2143 -+
2144 -+ and a tail call is converted to:
2145 -+
2146 -+ push CALL_OP
2147 -+ jmp __x86_indirect_thunk
2148 -+ */
2149 -+
2150 -+static void
2151 -+ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm,
2152 -+ bool sibcall_p)
2153 -+{
2154 -+ char thunk_name_buf[32];
2155 -+ char *thunk_name;
2156 -+ char push_buf[64];
2157 -+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
2158 -+ int regno = -1;
2159 -+
2160 -+ if (cfun->machine->indirect_branch_type
2161 -+ != indirect_branch_thunk_inline)
2162 -+ {
2163 -+ if (cfun->machine->indirect_branch_type == indirect_branch_thunk)
2164 -+ {
2165 -+ if (need_bnd_p)
2166 -+ indirect_thunk_bnd_needed = true;
2167 -+ else
2168 -+ indirect_thunk_needed = true;
2169 -+ }
2170 -+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
2171 -+ thunk_name = thunk_name_buf;
2172 -+ }
2173 -+ else
2174 -+ thunk_name = NULL;
2175 -+
2176 -+ snprintf (push_buf, sizeof (push_buf), "push{%c}\t%s",
2177 -+ TARGET_64BIT ? 'q' : 'l', xasm);
2178 -+
2179 -+ if (sibcall_p)
2180 -+ {
2181 -+ output_asm_insn (push_buf, &call_op);
2182 -+ if (thunk_name != NULL)
2183 -+ {
2184 -+ if (need_bnd_p)
2185 -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
2186 -+ else
2187 -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
2188 -+ }
2189 -+ else
2190 -+ output_indirect_thunk (need_bnd_p, regno);
2191 -+ }
2192 -+ else
2193 -+ {
2194 -+ char indirectlabel1[32];
2195 -+ char indirectlabel2[32];
2196 -+
2197 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1,
2198 -+ INDIRECT_LABEL,
2199 -+ indirectlabelno++);
2200 -+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2,
2201 -+ INDIRECT_LABEL,
2202 -+ indirectlabelno++);
2203 -+
2204 -+ /* Jump. */
2205 -+ if (need_bnd_p)
2206 -+ fputs ("\tbnd jmp\t", asm_out_file);
2207 -+ else
2208 -+ fputs ("\tjmp\t", asm_out_file);
2209 -+ assemble_name_raw (asm_out_file, indirectlabel2);
2210 -+ fputc ('\n', asm_out_file);
2211 -+
2212 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
2213 -+
2214 -+ /* An external function may be called via GOT, instead of PLT. */
2215 -+ if (MEM_P (call_op))
2216 -+ {
2217 -+ struct ix86_address parts;
2218 -+ rtx addr = XEXP (call_op, 0);
2219 -+ if (ix86_decompose_address (addr, &parts)
2220 -+ && parts.base == stack_pointer_rtx)
2221 -+ {
2222 -+ /* Since call will adjust stack by -UNITS_PER_WORD,
2223 -+ we must convert "disp(stack, index, scale)" to
2224 -+ "disp+UNITS_PER_WORD(stack, index, scale)". */
2225 -+ if (parts.index)
2226 -+ {
2227 -+ addr = gen_rtx_MULT (Pmode, parts.index,
2228 -+ GEN_INT (parts.scale));
2229 -+ addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
2230 -+ addr);
2231 -+ }
2232 -+ else
2233 -+ addr = stack_pointer_rtx;
2234 -+
2235 -+ rtx disp;
2236 -+ if (parts.disp != NULL_RTX)
2237 -+ disp = plus_constant (Pmode, parts.disp,
2238 -+ UNITS_PER_WORD);
2239 -+ else
2240 -+ disp = GEN_INT (UNITS_PER_WORD);
2241 -+
2242 -+ addr = gen_rtx_PLUS (Pmode, addr, disp);
2243 -+ call_op = gen_rtx_MEM (GET_MODE (call_op), addr);
2244 -+ }
2245 -+ }
2246 -+
2247 -+ output_asm_insn (push_buf, &call_op);
2248 -+
2249 -+ if (thunk_name != NULL)
2250 -+ {
2251 -+ if (need_bnd_p)
2252 -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
2253 -+ else
2254 -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
2255 -+ }
2256 -+ else
2257 -+ output_indirect_thunk (need_bnd_p, regno);
2258 -+
2259 -+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
2260 -+
2261 -+ /* Call. */
2262 -+ if (need_bnd_p)
2263 -+ fputs ("\tbnd call\t", asm_out_file);
2264 -+ else
2265 -+ fputs ("\tcall\t", asm_out_file);
2266 -+ assemble_name_raw (asm_out_file, indirectlabel1);
2267 -+ fputc ('\n', asm_out_file);
2268 -+ }
2269 -+}
2270 -+
2271 -+/* Output indirect branch via a call and return thunk. CALL_OP is
2272 -+ the branch target. XASM is the assembly template for CALL_OP.
2273 -+ Branch is a tail call if SIBCALL_P is true. */
2274 -+
2275 -+static void
2276 -+ix86_output_indirect_branch (rtx call_op, const char *xasm,
2277 -+ bool sibcall_p)
2278 -+{
2279 -+ if (REG_P (call_op))
2280 -+ ix86_output_indirect_branch_via_reg (call_op, sibcall_p);
2281 -+ else
2282 -+ ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
2283 -+}
2284 -+/* Output indirect jump. CALL_OP is the jump target. Jump is a
2285 -+ function return if RET_P is true. */
2286 -+
2287 -+const char *
2288 -+ix86_output_indirect_jmp (rtx call_op, bool ret_p)
2289 -+{
2290 -+ if (cfun->machine->indirect_branch_type != indirect_branch_keep)
2291 -+ {
2292 -+ /* We can't have red-zone if this isn't a function return since
2293 -+ "call" in the indirect thunk pushes the return address onto
2294 -+ stack, destroying red-zone. */
2295 -+ if (!ret_p && ix86_red_zone_size != 0)
2296 -+ gcc_unreachable ();
2297 -+
2298 -+ ix86_output_indirect_branch (call_op, "%0", true);
2299 -+ return "";
2300 -+ }
2301 -+ else
2302 -+ return "%!jmp\t%A0";
2303 -+}
2304 -+
2305 - /* Output the assembly for a call instruction. */
2306 -
2307 - const char *
2308 - ix86_output_call_insn (rtx_insn *insn, rtx call_op)
2309 - {
2310 - bool direct_p = constant_call_address_operand (call_op, VOIDmode);
2311 -+ bool output_indirect_p
2312 -+ = (!TARGET_SEH
2313 -+ && cfun->machine->indirect_branch_type != indirect_branch_keep);
2314 - bool seh_nop_p = false;
2315 - const char *xasm;
2316 -
2317 -@@ -28476,10 +29037,21 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
2318 - {
2319 - if (ix86_nopic_noplt_attribute_p (call_op))
2320 - {
2321 -+ direct_p = false;
2322 - if (TARGET_64BIT)
2323 -- xasm = "%!jmp\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2324 -+ {
2325 -+ if (output_indirect_p)
2326 -+ xasm = "{%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2327 -+ else
2328 -+ xasm = "%!jmp\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2329 -+ }
2330 - else
2331 -- xasm = "%!jmp\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
2332 -+ {
2333 -+ if (output_indirect_p)
2334 -+ xasm = "{%p0@GOT|[DWORD PTR %p0@GOT]}";
2335 -+ else
2336 -+ xasm = "%!jmp\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
2337 -+ }
2338 - }
2339 - else
2340 - xasm = "%!jmp\t%P0";
2341 -@@ -28489,9 +29061,17 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
2342 - else if (TARGET_SEH)
2343 - xasm = "%!rex.W jmp\t%A0";
2344 - else
2345 -- xasm = "%!jmp\t%A0";
2346 -+ {
2347 -+ if (output_indirect_p)
2348 -+ xasm = "%0";
2349 -+ else
2350 -+ xasm = "%!jmp\t%A0";
2351 -+ }
2352 -
2353 -- output_asm_insn (xasm, &call_op);
2354 -+ if (output_indirect_p && !direct_p)
2355 -+ ix86_output_indirect_branch (call_op, xasm, true);
2356 -+ else
2357 -+ output_asm_insn (xasm, &call_op);
2358 - return "";
2359 - }
2360 -
2361 -@@ -28529,18 +29109,37 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
2362 - {
2363 - if (ix86_nopic_noplt_attribute_p (call_op))
2364 - {
2365 -+ direct_p = false;
2366 - if (TARGET_64BIT)
2367 -- xasm = "%!call\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2368 -+ {
2369 -+ if (output_indirect_p)
2370 -+ xasm = "{%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2371 -+ else
2372 -+ xasm = "%!call\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
2373 -+ }
2374 - else
2375 -- xasm = "%!call\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
2376 -+ {
2377 -+ if (output_indirect_p)
2378 -+ xasm = "{%p0@GOT|[DWORD PTR %p0@GOT]}";
2379 -+ else
2380 -+ xasm = "%!call\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
2381 -+ }
2382 - }
2383 - else
2384 - xasm = "%!call\t%P0";
2385 - }
2386 - else
2387 -- xasm = "%!call\t%A0";
2388 -+ {
2389 -+ if (output_indirect_p)
2390 -+ xasm = "%0";
2391 -+ else
2392 -+ xasm = "%!call\t%A0";
2393 -+ }
2394 -
2395 -- output_asm_insn (xasm, &call_op);
2396 -+ if (output_indirect_p && !direct_p)
2397 -+ ix86_output_indirect_branch (call_op, xasm, false);
2398 -+ else
2399 -+ output_asm_insn (xasm, &call_op);
2400 -
2401 - if (seh_nop_p)
2402 - return "nop";
2403 -@@ -41459,7 +42058,7 @@ ix86_handle_struct_attribute (tree *node, tree name, tree, int,
2404 - }
2405 -
2406 - static tree
2407 --ix86_handle_fndecl_attribute (tree *node, tree name, tree, int,
2408 -+ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
2409 - bool *no_add_attrs)
2410 - {
2411 - if (TREE_CODE (*node) != FUNCTION_DECL)
2412 -@@ -41468,6 +42067,29 @@ ix86_handle_fndecl_attribute (tree *node, tree name, tree, int,
2413 - name);
2414 - *no_add_attrs = true;
2415 - }
2416 -+
2417 -+ if (is_attribute_p ("indirect_branch", name))
2418 -+ {
2419 -+ tree cst = TREE_VALUE (args);
2420 -+ if (TREE_CODE (cst) != STRING_CST)
2421 -+ {
2422 -+ warning (OPT_Wattributes,
2423 -+ "%qE attribute requires a string constant argument",
2424 -+ name);
2425 -+ *no_add_attrs = true;
2426 -+ }
2427 -+ else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
2428 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
2429 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
2430 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
2431 -+ {
2432 -+ warning (OPT_Wattributes,
2433 -+ "argument to %qE attribute is not "
2434 -+ "(keep|thunk|thunk-inline|thunk-extern)", name);
2435 -+ *no_add_attrs = true;
2436 -+ }
2437 -+ }
2438 -+
2439 - return NULL_TREE;
2440 - }
2441 -
2442 -@@ -45776,6 +46398,8 @@ static const struct attribute_spec ix86_attribute_table[] =
2443 - ix86_handle_interrupt_attribute, false },
2444 - { "no_caller_saved_registers", 0, 0, false, true, true,
2445 - ix86_handle_no_caller_saved_registers_attribute, false },
2446 -+ { "indirect_branch", 1, 1, true, false, false,
2447 -+ ix86_handle_fndecl_attribute, false },
2448 -
2449 - /* End element. */
2450 - { NULL, 0, 0, false, false, false, NULL, false }
2451 -diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
2452 -index 11727e5..d8370ae 100644
2453 ---- a/gcc/config/i386/i386.h
2454 -+++ b/gcc/config/i386/i386.h
2455 -@@ -2609,6 +2609,13 @@ struct GTY(()) machine_function {
2456 - /* Function type. */
2457 - ENUM_BITFIELD(function_type) func_type : 2;
2458 -
2459 -+ /* How to generate indirec branch. */
2460 -+ ENUM_BITFIELD(indirect_branch) indirect_branch_type : 3;
2461 -+
2462 -+ /* If true, the current function has local indirect jumps, like
2463 -+ "indirect_jump" or "tablejump". */
2464 -+ BOOL_BITFIELD has_local_indirect_jump : 1;
2465 -+
2466 - /* If true, the current function is a function specified with
2467 - the "interrupt" or "no_caller_saved_registers" attribute. */
2468 - BOOL_BITFIELD no_caller_saved_registers : 1;
2469 -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
2470 -index dbe88f4..cd2e73c 100644
2471 ---- a/gcc/config/i386/i386.md
2472 -+++ b/gcc/config/i386/i386.md
2473 -@@ -11627,13 +11627,18 @@
2474 - {
2475 - if (TARGET_X32)
2476 - operands[0] = convert_memory_address (word_mode, operands[0]);
2477 -+ cfun->machine->has_local_indirect_jump = true;
2478 - })
2479 -
2480 - (define_insn "*indirect_jump"
2481 - [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))]
2482 - ""
2483 -- "%!jmp\t%A0"
2484 -- [(set_attr "type" "ibr")
2485 -+ "* return ix86_output_indirect_jmp (operands[0], false);"
2486 -+ [(set (attr "type")
2487 -+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
2488 -+ != indirect_branch_keep)")
2489 -+ (const_string "multi")
2490 -+ (const_string "ibr")))
2491 - (set_attr "length_immediate" "0")
2492 - (set_attr "maybe_prefix_bnd" "1")])
2493 -
2494 -@@ -11676,14 +11681,19 @@
2495 -
2496 - if (TARGET_X32)
2497 - operands[0] = convert_memory_address (word_mode, operands[0]);
2498 -+ cfun->machine->has_local_indirect_jump = true;
2499 - })
2500 -
2501 - (define_insn "*tablejump_1"
2502 - [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))
2503 - (use (label_ref (match_operand 1)))]
2504 - ""
2505 -- "%!jmp\t%A0"
2506 -- [(set_attr "type" "ibr")
2507 -+ "* return ix86_output_indirect_jmp (operands[0], false);"
2508 -+ [(set (attr "type")
2509 -+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
2510 -+ != indirect_branch_keep)")
2511 -+ (const_string "multi")
2512 -+ (const_string "ibr")))
2513 - (set_attr "length_immediate" "0")
2514 - (set_attr "maybe_prefix_bnd" "1")])
2515 -
2516 -@@ -12354,8 +12364,12 @@
2517 - [(simple_return)
2518 - (use (match_operand:SI 0 "register_operand" "r"))]
2519 - "reload_completed"
2520 -- "%!jmp\t%A0"
2521 -- [(set_attr "type" "ibr")
2522 -+ "* return ix86_output_indirect_jmp (operands[0], true);"
2523 -+ [(set (attr "type")
2524 -+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
2525 -+ != indirect_branch_keep)")
2526 -+ (const_string "multi")
2527 -+ (const_string "ibr")))
2528 - (set_attr "length_immediate" "0")
2529 - (set_attr "maybe_prefix_bnd" "1")])
2530 -
2531 -diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
2532 -index 9384e29..c076d9c 100644
2533 ---- a/gcc/config/i386/i386.opt
2534 -+++ b/gcc/config/i386/i386.opt
2535 -@@ -927,3 +927,23 @@ Attempt to avoid generating instruction sequences containing ret bytes.
2536 - mgeneral-regs-only
2537 - Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Var(ix86_target_flags) Save
2538 - Generate code which uses only the general registers.
2539 -+
2540 -+mindirect-branch=
2541 -+Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_indirect_branch) Init(indirect_branch_keep)
2542 -+Convert indirect call and jump to call and return thunks.
2543 -+
2544 -+Enum
2545 -+Name(indirect_branch) Type(enum indirect_branch)
2546 -+Known indirect branch choices (for use with the -mindirect-branch= option):
2547 -+
2548 -+EnumValue
2549 -+Enum(indirect_branch) String(keep) Value(indirect_branch_keep)
2550 -+
2551 -+EnumValue
2552 -+Enum(indirect_branch) String(thunk) Value(indirect_branch_thunk)
2553 -+
2554 -+EnumValue
2555 -+Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
2556 -+
2557 -+EnumValue
2558 -+Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
2559 -diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
2560 -index ba309d0..935381d 100644
2561 ---- a/gcc/doc/extend.texi
2562 -+++ b/gcc/doc/extend.texi
2563 -@@ -5540,6 +5540,16 @@ Specify which floating-point unit to use. You must specify the
2564 - @code{target("fpmath=sse,387")} option as
2565 - @code{target("fpmath=sse+387")} because the comma would separate
2566 - different options.
2567 -+
2568 -+@item indirect_branch("@var{choice}")
2569 -+@cindex @code{indirect_branch} function attribute, x86
2570 -+On x86 targets, the @code{indirect_branch} attribute causes the compiler
2571 -+to convert indirect call and jump with @var{choice}. @samp{keep}
2572 -+keeps indirect call and jump unmodified. @samp{thunk} converts indirect
2573 -+call and jump to call and return thunk. @samp{thunk-inline} converts
2574 -+indirect call and jump to inlined call and return thunk.
2575 -+@samp{thunk-extern} converts indirect call and jump to external call
2576 -+and return thunk provided in a separate object file.
2577 - @end table
2578 -
2579 - On the x86, the inliner does not inline a
2580 -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
2581 -index 7311c10..4979c8c 100644
2582 ---- a/gcc/doc/invoke.texi
2583 -+++ b/gcc/doc/invoke.texi
2584 -@@ -1210,7 +1210,8 @@ See RS/6000 and PowerPC Options.
2585 - -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
2586 - -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
2587 - -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
2588 ---mmitigate-rop -mgeneral-regs-only}
2589 -+-mmitigate-rop -mgeneral-regs-only @gol
2590 -+-mindirect-branch=@var{choice}}
2591 -
2592 - @emph{x86 Windows Options}
2593 - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
2594 -@@ -25686,6 +25687,17 @@ Generate code that uses only the general-purpose registers. This
2595 - prevents the compiler from using floating-point, vector, mask and bound
2596 - registers.
2597 -
2598 -+@item -mindirect-branch=@var{choice}
2599 -+@opindex -mindirect-branch
2600 -+Convert indirect call and jump with @var{choice}. The default is
2601 -+@samp{keep}, which keeps indirect call and jump unmodified.
2602 -+@samp{thunk} converts indirect call and jump to call and return thunk.
2603 -+@samp{thunk-inline} converts indirect call and jump to inlined call
2604 -+and return thunk. @samp{thunk-extern} converts indirect call and jump
2605 -+to external call and return thunk provided in a separate object file.
2606 -+You can control this behavior for a specific function by using the
2607 -+function attribute @code{indirect_branch}. @xref{Function Attributes}.
2608 -+
2609 - @end table
2610 -
2611 - These @samp{-m} switches are supported in addition to the above
2612
2613 diff --git a/sys-devel/gcc/files/spectre-0002-mfunction-return.patch b/sys-devel/gcc/files/spectre-0002-mfunction-return.patch
2614 deleted file mode 100644
2615 index 391e89d..0000000
2616 --- a/sys-devel/gcc/files/spectre-0002-mfunction-return.patch
2617 +++ /dev/null
2618 @@ -1,447 +0,0 @@
2619 -From 357311dd400f7f72d2132f2f94161ece39bf08c6 Mon Sep 17 00:00:00 2001
2620 -From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
2621 -Date: Tue, 16 Jan 2018 11:10:44 +0000
2622 -Subject: [PATCH] x86: Add -mfunction-return=
2623 -
2624 -Add -mfunction-return= option to convert function return to call and
2625 -return thunks. The default is 'keep', which keeps function return
2626 -unmodified. 'thunk' converts function return to call and return thunk.
2627 -'thunk-inline' converts function return to inlined call and return thunk.
2628 -'thunk-extern' converts function return to external call and return
2629 -thunk provided in a separate object file. You can control this behavior
2630 -for a specific function by using the function attribute function_return.
2631 -
2632 -Function return thunk is the same as memory thunk for -mindirect-branch=
2633 -where the return address is at the top of the stack:
2634 -
2635 -__x86_return_thunk:
2636 - call L2
2637 -L1:
2638 - pause
2639 - lfence
2640 - jmp L1
2641 -L2:
2642 - lea 8(%rsp), %rsp|lea 4(%esp), %esp
2643 - ret
2644 -
2645 -and function return becomes
2646 -
2647 - jmp __x86_return_thunk
2648 -
2649 -gcc/
2650 -
2651 - Backport from mainline
2652 - 2018-01-14 H.J. Lu <hongjiu.lu@×××××.com>
2653 -
2654 - * config/i386/i386-protos.h (ix86_output_function_return): New.
2655 - * config/i386/i386.c (ix86_set_indirect_branch_type): Also
2656 - set function_return_type.
2657 - (indirect_thunk_name): Add ret_p to indicate thunk for function
2658 - return.
2659 - (output_indirect_thunk_function): Pass false to
2660 - indirect_thunk_name.
2661 - (ix86_output_indirect_branch_via_reg): Likewise.
2662 - (ix86_output_indirect_branch_via_push): Likewise.
2663 - (output_indirect_thunk_function): Create alias for function
2664 - return thunk if regno < 0.
2665 - (ix86_output_function_return): New function.
2666 - (ix86_handle_fndecl_attribute): Handle function_return.
2667 - (ix86_attribute_table): Add function_return.
2668 - * config/i386/i386.h (machine_function): Add
2669 - function_return_type.
2670 - * config/i386/i386.md (simple_return_internal): Use
2671 - ix86_output_function_return.
2672 - (simple_return_internal_long): Likewise.
2673 - * config/i386/i386.opt (mfunction-return=): New option.
2674 - (indirect_branch): Mention -mfunction-return=.
2675 - * doc/extend.texi: Document function_return function attribute.
2676 - * doc/invoke.texi: Document -mfunction-return= option.
2677 -
2678 -i386: Don't use ASM_OUTPUT_DEF for TARGET_MACHO
2679 -
2680 -ASM_OUTPUT_DEF isn't defined for TARGET_MACHO. Use ASM_OUTPUT_LABEL to
2681 -generate the __x86_return_thunk label, instead of the set directive.
2682 -Update testcase to remove the __x86_return_thunk label check. Since
2683 --fno-pic is ignored on Darwin, update testcases to sscan or "push"
2684 -only on Linux.
2685 -
2686 -gcc/
2687 -
2688 - Backport from mainline
2689 - 2018-01-15 H.J. Lu <hongjiu.lu@×××××.com>
2690 -
2691 - PR target/83839
2692 - * config/i386/i386.c (output_indirect_thunk_function): Use
2693 - ASM_OUTPUT_LABEL, instead of ASM_OUTPUT_DEF, for TARGET_MACHO
2694 - for __x86.return_thunk.
2695 -
2696 -
2697 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256734 138bc75d-0d04-0410-961f-82ee72b054a4
2698 ----
2699 - gcc/config/i386/i386-protos.h | 1 +
2700 - gcc/config/i386/i386.c | 152 +++++++++++++++++++--
2701 - gcc/config/i386/i386.h | 3 +
2702 - gcc/config/i386/i386.md | 9 +-
2703 - gcc/config/i386/i386.opt | 6 +-
2704 - gcc/doc/extend.texi | 9 ++
2705 - gcc/doc/invoke.texi | 13 +-
2706 - 58 files changed, 641 insertions(+), 74 deletions(-)
2707 -
2708 -diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
2709 -index bcdd987..42eece3 100644
2710 ---- a/gcc/config/i386/i386-protos.h
2711 -+++ b/gcc/config/i386/i386-protos.h
2712 -@@ -314,6 +314,7 @@ extern enum attr_cpu ix86_schedule;
2713 -
2714 - extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
2715 - extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
2716 -+extern const char * ix86_output_function_return (bool long_p);
2717 - extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
2718 - enum machine_mode mode);
2719 -
2720 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
2721 -index 7e779c1..8fb8902 100644
2722 ---- a/gcc/config/i386/i386.c
2723 -+++ b/gcc/config/i386/i386.c
2724 -@@ -7188,6 +7188,31 @@ ix86_set_indirect_branch_type (tree fndecl)
2725 - else
2726 - cfun->machine->indirect_branch_type = ix86_indirect_branch;
2727 - }
2728 -+
2729 -+ if (cfun->machine->function_return_type == indirect_branch_unset)
2730 -+ {
2731 -+ tree attr = lookup_attribute ("function_return",
2732 -+ DECL_ATTRIBUTES (fndecl));
2733 -+ if (attr != NULL)
2734 -+ {
2735 -+ tree args = TREE_VALUE (attr);
2736 -+ if (args == NULL)
2737 -+ gcc_unreachable ();
2738 -+ tree cst = TREE_VALUE (args);
2739 -+ if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
2740 -+ cfun->machine->function_return_type = indirect_branch_keep;
2741 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
2742 -+ cfun->machine->function_return_type = indirect_branch_thunk;
2743 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
2744 -+ cfun->machine->function_return_type = indirect_branch_thunk_inline;
2745 -+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
2746 -+ cfun->machine->function_return_type = indirect_branch_thunk_extern;
2747 -+ else
2748 -+ gcc_unreachable ();
2749 -+ }
2750 -+ else
2751 -+ cfun->machine->function_return_type = ix86_function_return;
2752 -+ }
2753 - }
2754 -
2755 - /* Establish appropriate back-end context for processing the function
2756 -@@ -12000,8 +12025,12 @@ static int indirect_thunks_bnd_used;
2757 - /* Fills in the label name that should be used for the indirect thunk. */
2758 -
2759 - static void
2760 --indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
2761 -+indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
2762 -+ bool ret_p)
2763 - {
2764 -+ if (regno >= 0 && ret_p)
2765 -+ gcc_unreachable ();
2766 -+
2767 - if (USE_HIDDEN_LINKONCE)
2768 - {
2769 - const char *bnd = need_bnd_p ? "_bnd" : "";
2770 -@@ -12016,7 +12045,10 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
2771 - bnd, reg_prefix, reg_names[regno]);
2772 - }
2773 - else
2774 -- sprintf (name, "__x86_indirect_thunk%s", bnd);
2775 -+ {
2776 -+ const char *ret = ret_p ? "return" : "indirect";
2777 -+ sprintf (name, "__x86_%s_thunk%s", ret, bnd);
2778 -+ }
2779 - }
2780 - else
2781 - {
2782 -@@ -12029,10 +12061,20 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
2783 - }
2784 - else
2785 - {
2786 -- if (need_bnd_p)
2787 -- ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
2788 -+ if (ret_p)
2789 -+ {
2790 -+ if (need_bnd_p)
2791 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LRTB", 0);
2792 -+ else
2793 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LRT", 0);
2794 -+ }
2795 - else
2796 -- ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
2797 -+ {
2798 -+ if (need_bnd_p)
2799 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
2800 -+ else
2801 -+ ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
2802 -+ }
2803 - }
2804 - }
2805 - }
2806 -@@ -12127,7 +12169,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
2807 - tree decl;
2808 -
2809 - /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
2810 -- indirect_thunk_name (name, regno, need_bnd_p);
2811 -+ indirect_thunk_name (name, regno, need_bnd_p, false);
2812 - decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
2813 - get_identifier (name),
2814 - build_function_type_list (void_type_node, NULL_TREE));
2815 -@@ -12170,6 +12212,36 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
2816 - ASM_OUTPUT_LABEL (asm_out_file, name);
2817 - }
2818 -
2819 -+ if (regno < 0)
2820 -+ {
2821 -+ /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
2822 -+ char alias[32];
2823 -+
2824 -+ indirect_thunk_name (alias, regno, need_bnd_p, true);
2825 -+#if TARGET_MACHO
2826 -+ if (TARGET_MACHO)
2827 -+ {
2828 -+ fputs ("\t.weak_definition\t", asm_out_file);
2829 -+ assemble_name (asm_out_file, alias);
2830 -+ fputs ("\n\t.private_extern\t", asm_out_file);
2831 -+ assemble_name (asm_out_file, alias);
2832 -+ putc ('\n', asm_out_file);
2833 -+ ASM_OUTPUT_LABEL (asm_out_file, alias);
2834 -+ }
2835 -+#else
2836 -+ ASM_OUTPUT_DEF (asm_out_file, alias, name);
2837 -+ if (USE_HIDDEN_LINKONCE)
2838 -+ {
2839 -+ fputs ("\t.globl\t", asm_out_file);
2840 -+ assemble_name (asm_out_file, alias);
2841 -+ putc ('\n', asm_out_file);
2842 -+ fputs ("\t.hidden\t", asm_out_file);
2843 -+ assemble_name (asm_out_file, alias);
2844 -+ putc ('\n', asm_out_file);
2845 -+ }
2846 -+#endif
2847 -+ }
2848 -+
2849 - DECL_INITIAL (decl) = make_node (BLOCK);
2850 - current_function_decl = decl;
2851 - allocate_struct_function (decl, false);
2852 -@@ -28775,7 +28847,7 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
2853 - else
2854 - indirect_thunks_used |= 1 << i;
2855 - }
2856 -- indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
2857 -+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p, false);
2858 - thunk_name = thunk_name_buf;
2859 - }
2860 - else
2861 -@@ -28884,7 +28956,7 @@ ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm,
2862 - else
2863 - indirect_thunk_needed = true;
2864 - }
2865 -- indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
2866 -+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p, false);
2867 - thunk_name = thunk_name_buf;
2868 - }
2869 - else
2870 -@@ -29019,6 +29091,46 @@ ix86_output_indirect_jmp (rtx call_op, bool ret_p)
2871 - return "%!jmp\t%A0";
2872 - }
2873 -
2874 -+/* Output function return. CALL_OP is the jump target. Add a REP
2875 -+ prefix to RET if LONG_P is true and function return is kept. */
2876 -+
2877 -+const char *
2878 -+ix86_output_function_return (bool long_p)
2879 -+{
2880 -+ if (cfun->machine->function_return_type != indirect_branch_keep)
2881 -+ {
2882 -+ char thunk_name[32];
2883 -+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
2884 -+
2885 -+ if (cfun->machine->function_return_type
2886 -+ != indirect_branch_thunk_inline)
2887 -+ {
2888 -+ bool need_thunk = (cfun->machine->function_return_type
2889 -+ == indirect_branch_thunk);
2890 -+ indirect_thunk_name (thunk_name, -1, need_bnd_p, true);
2891 -+ if (need_bnd_p)
2892 -+ {
2893 -+ indirect_thunk_bnd_needed |= need_thunk;
2894 -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
2895 -+ }
2896 -+ else
2897 -+ {
2898 -+ indirect_thunk_needed |= need_thunk;
2899 -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
2900 -+ }
2901 -+ }
2902 -+ else
2903 -+ output_indirect_thunk (need_bnd_p, -1);
2904 -+
2905 -+ return "";
2906 -+ }
2907 -+
2908 -+ if (!long_p || ix86_bnd_prefixed_insn_p (current_output_insn))
2909 -+ return "%!ret";
2910 -+
2911 -+ return "rep%; ret";
2912 -+}
2913 -+
2914 - /* Output the assembly for a call instruction. */
2915 -
2916 - const char *
2917 -@@ -42090,6 +42202,28 @@ ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
2918 - }
2919 - }
2920 -
2921 -+ if (is_attribute_p ("function_return", name))
2922 -+ {
2923 -+ tree cst = TREE_VALUE (args);
2924 -+ if (TREE_CODE (cst) != STRING_CST)
2925 -+ {
2926 -+ warning (OPT_Wattributes,
2927 -+ "%qE attribute requires a string constant argument",
2928 -+ name);
2929 -+ *no_add_attrs = true;
2930 -+ }
2931 -+ else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
2932 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
2933 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
2934 -+ && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
2935 -+ {
2936 -+ warning (OPT_Wattributes,
2937 -+ "argument to %qE attribute is not "
2938 -+ "(keep|thunk|thunk-inline|thunk-extern)", name);
2939 -+ *no_add_attrs = true;
2940 -+ }
2941 -+ }
2942 -+
2943 - return NULL_TREE;
2944 - }
2945 -
2946 -@@ -46400,6 +46534,8 @@ static const struct attribute_spec ix86_attribute_table[] =
2947 - ix86_handle_no_caller_saved_registers_attribute, false },
2948 - { "indirect_branch", 1, 1, true, false, false,
2949 - ix86_handle_fndecl_attribute, false },
2950 -+ { "function_return", 1, 1, true, false, false,
2951 -+ ix86_handle_fndecl_attribute, false },
2952 -
2953 - /* End element. */
2954 - { NULL, 0, 0, false, false, false, NULL, false }
2955 -diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
2956 -index d8370ae..e7da790 100644
2957 ---- a/gcc/config/i386/i386.h
2958 -+++ b/gcc/config/i386/i386.h
2959 -@@ -2616,6 +2616,9 @@ struct GTY(()) machine_function {
2960 - "indirect_jump" or "tablejump". */
2961 - BOOL_BITFIELD has_local_indirect_jump : 1;
2962 -
2963 -+ /* How to generate function return. */
2964 -+ ENUM_BITFIELD(indirect_branch) function_return_type : 3;
2965 -+
2966 - /* If true, the current function is a function specified with
2967 - the "interrupt" or "no_caller_saved_registers" attribute. */
2968 - BOOL_BITFIELD no_caller_saved_registers : 1;
2969 -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
2970 -index cd2e73c..d112bdb 100644
2971 ---- a/gcc/config/i386/i386.md
2972 -+++ b/gcc/config/i386/i386.md
2973 -@@ -12315,7 +12315,7 @@
2974 - (define_insn "simple_return_internal"
2975 - [(simple_return)]
2976 - "reload_completed"
2977 -- "%!ret"
2978 -+ "* return ix86_output_function_return (false);"
2979 - [(set_attr "length" "1")
2980 - (set_attr "atom_unit" "jeu")
2981 - (set_attr "length_immediate" "0")
2982 -@@ -12337,12 +12337,7 @@
2983 - [(simple_return)
2984 - (unspec [(const_int 0)] UNSPEC_REP)]
2985 - "reload_completed"
2986 --{
2987 -- if (ix86_bnd_prefixed_insn_p (insn))
2988 -- return "%!ret";
2989 --
2990 -- return "rep%; ret";
2991 --}
2992 -+ "* return ix86_output_function_return (true);"
2993 - [(set_attr "length" "2")
2994 - (set_attr "atom_unit" "jeu")
2995 - (set_attr "length_immediate" "0")
2996 -diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
2997 -index c076d9c..b07388d 100644
2998 ---- a/gcc/config/i386/i386.opt
2999 -+++ b/gcc/config/i386/i386.opt
3000 -@@ -932,9 +932,13 @@ mindirect-branch=
3001 - Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_indirect_branch) Init(indirect_branch_keep)
3002 - Convert indirect call and jump to call and return thunks.
3003 -
3004 -+mfunction-return=
3005 -+Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_function_return) Init(indirect_branch_keep)
3006 -+Convert function return to call and return thunk.
3007 -+
3008 - Enum
3009 - Name(indirect_branch) Type(enum indirect_branch)
3010 --Known indirect branch choices (for use with the -mindirect-branch= option):
3011 -+Known indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):
3012 -
3013 - EnumValue
3014 - Enum(indirect_branch) String(keep) Value(indirect_branch_keep)
3015 -diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
3016 -index 935381d..46e0a36 100644
3017 ---- a/gcc/doc/extend.texi
3018 -+++ b/gcc/doc/extend.texi
3019 -@@ -5550,6 +5550,15 @@ call and jump to call and return thunk. @samp{thunk-inline} converts
3020 - indirect call and jump to inlined call and return thunk.
3021 - @samp{thunk-extern} converts indirect call and jump to external call
3022 - and return thunk provided in a separate object file.
3023 -+
3024 -+@item function_return("@var{choice}")
3025 -+@cindex @code{function_return} function attribute, x86
3026 -+On x86 targets, the @code{function_return} attribute causes the compiler
3027 -+to convert function return with @var{choice}. @samp{keep} keeps function
3028 -+return unmodified. @samp{thunk} converts function return to call and
3029 -+return thunk. @samp{thunk-inline} converts function return to inlined
3030 -+call and return thunk. @samp{thunk-extern} converts function return to
3031 -+external call and return thunk provided in a separate object file.
3032 - @end table
3033 -
3034 - On the x86, the inliner does not inline a
3035 -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
3036 -index 4979c8c..f3eb54b 100644
3037 ---- a/gcc/doc/invoke.texi
3038 -+++ b/gcc/doc/invoke.texi
3039 -@@ -1211,7 +1211,7 @@ See RS/6000 and PowerPC Options.
3040 - -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
3041 - -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
3042 - -mmitigate-rop -mgeneral-regs-only @gol
3043 ---mindirect-branch=@var{choice}}
3044 -+-mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
3045 -
3046 - @emph{x86 Windows Options}
3047 - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
3048 -@@ -25698,6 +25698,17 @@ to external call and return thunk provided in a separate object file.
3049 - You can control this behavior for a specific function by using the
3050 - function attribute @code{indirect_branch}. @xref{Function Attributes}.
3051 -
3052 -+@item -mfunction-return=@var{choice}
3053 -+@opindex -mfunction-return
3054 -+Convert function return with @var{choice}. The default is @samp{keep},
3055 -+which keeps function return unmodified. @samp{thunk} converts function
3056 -+return to call and return thunk. @samp{thunk-inline} converts function
3057 -+return to inlined call and return thunk. @samp{thunk-extern} converts
3058 -+function return to external call and return thunk provided in a separate
3059 -+object file. You can control this behavior for a specific function by
3060 -+using the function attribute @code{function_return}.
3061 -+@xref{Function Attributes}.
3062 -+
3063 - @end table
3064 -
3065 - These @samp{-m} switches are supported in addition to the above
3066
3067 diff --git a/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch b/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch
3068 deleted file mode 100644
3069 index 2e5e779..0000000
3070 --- a/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch
3071 +++ /dev/null
3072 @@ -1,340 +0,0 @@
3073 -From 86118fbdbafe6af54b2da467e1073c49e1742116 Mon Sep 17 00:00:00 2001
3074 -From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
3075 -Date: Tue, 16 Jan 2018 11:17:49 +0000
3076 -Subject: [PATCH] x86: Add -mindirect-branch-register
3077 -
3078 -Add -mindirect-branch-register to force indirect branch via register.
3079 -This is implemented by disabling patterns of indirect branch via memory,
3080 -similar to TARGET_X32.
3081 -
3082 --mindirect-branch= and -mfunction-return= tests are updated with
3083 --mno-indirect-branch-register to avoid false test failures when
3084 --mindirect-branch-register is added to RUNTESTFLAGS for "make check".
3085 -
3086 -gcc/
3087 -
3088 - Backport from mainline
3089 - 2018-01-14 H.J. Lu <hongjiu.lu@×××××.com>
3090 -
3091 - * config/i386/constraints.md (Bs): Disallow memory operand for
3092 - -mindirect-branch-register.
3093 - (Bw): Likewise.
3094 - * config/i386/predicates.md (indirect_branch_operand): Likewise.
3095 - (GOT_memory_operand): Likewise.
3096 - (call_insn_operand): Likewise.
3097 - (sibcall_insn_operand): Likewise.
3098 - (GOT32_symbol_operand): Likewise.
3099 - * config/i386/i386.md (indirect_jump): Call convert_memory_address
3100 - for -mindirect-branch-register.
3101 - (tablejump): Likewise.
3102 - (*sibcall_memory): Likewise.
3103 - (*sibcall_value_memory): Likewise.
3104 - Disallow peepholes of indirect call and jump via memory for
3105 - -mindirect-branch-register.
3106 - (*call_pop): Replace m with Bw.
3107 - (*call_value_pop): Likewise.
3108 - (*sibcall_pop_memory): Replace m with Bs.
3109 - * config/i386/i386.opt (mindirect-branch-register): New option.
3110 - * doc/invoke.texi: Document -mindirect-branch-register option.
3111 -
3112 -i386: Rename to ix86_indirect_branch_register
3113 -
3114 -Rename the variable for -mindirect-branch-register to
3115 -ix86_indirect_branch_register to match the command-line option name.
3116 -
3117 - Backport from mainline
3118 - 2018-01-15 H.J. Lu <hongjiu.lu@×××××.com>
3119 -
3120 - * config/i386/constraints.md (Bs): Replace
3121 - ix86_indirect_branch_thunk_register with
3122 - ix86_indirect_branch_register.
3123 - (Bw): Likewise.
3124 - * config/i386/i386.md (indirect_jump): Likewise.
3125 - (tablejump): Likewise.
3126 - (*sibcall_memory): Likewise.
3127 - (*sibcall_value_memory): Likewise.
3128 - Peepholes of indirect call and jump via memory: Likewise.
3129 - * config/i386/i386.opt: Likewise.
3130 - * config/i386/predicates.md (indirect_branch_operand): Likewise.
3131 - (GOT_memory_operand): Likewise.
3132 - (call_insn_operand): Likewise.
3133 - (sibcall_insn_operand): Likewise.
3134 - (GOT32_symbol_operand): Likewise.
3135 -
3136 -x86: Rewrite ix86_indirect_branch_register logic
3137 -
3138 -Rewrite ix86_indirect_branch_register logic with
3139 -
3140 -(and (not (match_test "ix86_indirect_branch_register"))
3141 - (original condition before r256662))
3142 -
3143 - Backport from mainline
3144 - 2018-01-15 H.J. Lu <hongjiu.lu@×××××.com>
3145 -
3146 - * config/i386/predicates.md (constant_call_address_operand):
3147 - Rewrite ix86_indirect_branch_register logic.
3148 - (sibcall_insn_operand): Likewise.
3149 -
3150 -Don't check ix86_indirect_branch_register for GOT operand
3151 -
3152 -Since GOT_memory_operand and GOT32_symbol_operand are simple pattern
3153 -matches, don't check ix86_indirect_branch_register here. If needed,
3154 --mindirect-branch= will convert indirect branch via GOT slot to a call
3155 -and return thunk.
3156 -
3157 - Backport from mainline
3158 - 2018-01-15 H.J. Lu <hongjiu.lu@×××××.com>
3159 -
3160 - * config/i386/constraints.md (Bs): Update
3161 - ix86_indirect_branch_register check. Don't check
3162 - ix86_indirect_branch_register with GOT_memory_operand.
3163 - (Bw): Likewise.
3164 - * config/i386/predicates.md (GOT_memory_operand): Don't check
3165 - ix86_indirect_branch_register here.
3166 - (GOT32_symbol_operand): Likewise.
3167 -
3168 -i386: Rewrite indirect_branch_operand logic
3169 -
3170 - Backport from mainline
3171 - 2018-01-15 H.J. Lu <hongjiu.lu@×××××.com>
3172 -
3173 - * config/i386/predicates.md (indirect_branch_operand): Rewrite
3174 - ix86_indirect_branch_register logic.
3175 -
3176 -
3177 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256735 138bc75d-0d04-0410-961f-82ee72b054a4
3178 ----
3179 - gcc/config/i386/constraints.md | 6 +-
3180 - gcc/config/i386/i386.md | 34 +++++++----
3181 - gcc/config/i386/i386.opt | 4 ++
3182 - gcc/config/i386/predicates.md | 21 ++++---
3183 - gcc/doc/invoke.texi | 7 ++-
3184 - 49 files changed, 266 insertions(+), 63 deletions(-)
3185 -
3186 -diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
3187 -index 38d604f..a0a632a 100644
3188 ---- a/gcc/config/i386/constraints.md
3189 -+++ b/gcc/config/i386/constraints.md
3190 -@@ -198,14 +198,16 @@
3191 -
3192 - (define_constraint "Bs"
3193 - "@internal Sibcall memory operand."
3194 -- (ior (and (not (match_test "TARGET_X32"))
3195 -+ (ior (and (not (match_test "ix86_indirect_branch_register"))
3196 -+ (not (match_test "TARGET_X32"))
3197 - (match_operand 0 "sibcall_memory_operand"))
3198 - (and (match_test "TARGET_X32 && Pmode == DImode")
3199 - (match_operand 0 "GOT_memory_operand"))))
3200 -
3201 - (define_constraint "Bw"
3202 - "@internal Call memory operand."
3203 -- (ior (and (not (match_test "TARGET_X32"))
3204 -+ (ior (and (not (match_test "ix86_indirect_branch_register"))
3205 -+ (not (match_test "TARGET_X32"))
3206 - (match_operand 0 "memory_operand"))
3207 - (and (match_test "TARGET_X32 && Pmode == DImode")
3208 - (match_operand 0 "GOT_memory_operand"))))
3209 -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
3210 -index d112bdb..d074c2f 100644
3211 ---- a/gcc/config/i386/i386.md
3212 -+++ b/gcc/config/i386/i386.md
3213 -@@ -11625,7 +11625,7 @@
3214 - [(set (pc) (match_operand 0 "indirect_branch_operand"))]
3215 - ""
3216 - {
3217 -- if (TARGET_X32)
3218 -+ if (TARGET_X32 || ix86_indirect_branch_register)
3219 - operands[0] = convert_memory_address (word_mode, operands[0]);
3220 - cfun->machine->has_local_indirect_jump = true;
3221 - })
3222 -@@ -11679,7 +11679,7 @@
3223 - OPTAB_DIRECT);
3224 - }
3225 -
3226 -- if (TARGET_X32)
3227 -+ if (TARGET_X32 || ix86_indirect_branch_register)
3228 - operands[0] = convert_memory_address (word_mode, operands[0]);
3229 - cfun->machine->has_local_indirect_jump = true;
3230 - })
3231 -@@ -11871,7 +11871,7 @@
3232 - [(call (mem:QI (match_operand:W 0 "memory_operand" "m"))
3233 - (match_operand 1))
3234 - (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
3235 -- "!TARGET_X32"
3236 -+ "!TARGET_X32 && !ix86_indirect_branch_register"
3237 - "* return ix86_output_call_insn (insn, operands[0]);"
3238 - [(set_attr "type" "call")])
3239 -
3240 -@@ -11880,7 +11880,9 @@
3241 - (match_operand:W 1 "memory_operand"))
3242 - (call (mem:QI (match_dup 0))
3243 - (match_operand 3))]
3244 -- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
3245 -+ "!TARGET_X32
3246 -+ && !ix86_indirect_branch_register
3247 -+ && SIBLING_CALL_P (peep2_next_insn (1))
3248 - && !reg_mentioned_p (operands[0],
3249 - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
3250 - [(parallel [(call (mem:QI (match_dup 1))
3251 -@@ -11893,7 +11895,9 @@
3252 - (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
3253 - (call (mem:QI (match_dup 0))
3254 - (match_operand 3))]
3255 -- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
3256 -+ "!TARGET_X32
3257 -+ && !ix86_indirect_branch_register
3258 -+ && SIBLING_CALL_P (peep2_next_insn (2))
3259 - && !reg_mentioned_p (operands[0],
3260 - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
3261 - [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
3262 -@@ -11915,7 +11919,7 @@
3263 - })
3264 -
3265 - (define_insn "*call_pop"
3266 -- [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lmBz"))
3267 -+ [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lBwBz"))
3268 - (match_operand 1))
3269 - (set (reg:SI SP_REG)
3270 - (plus:SI (reg:SI SP_REG)
3271 -@@ -11935,7 +11939,7 @@
3272 - [(set_attr "type" "call")])
3273 -
3274 - (define_insn "*sibcall_pop_memory"
3275 -- [(call (mem:QI (match_operand:SI 0 "memory_operand" "m"))
3276 -+ [(call (mem:QI (match_operand:SI 0 "memory_operand" "Bs"))
3277 - (match_operand 1))
3278 - (set (reg:SI SP_REG)
3279 - (plus:SI (reg:SI SP_REG)
3280 -@@ -11989,7 +11993,9 @@
3281 - [(set (match_operand:W 0 "register_operand")
3282 - (match_operand:W 1 "memory_operand"))
3283 - (set (pc) (match_dup 0))]
3284 -- "!TARGET_X32 && peep2_reg_dead_p (2, operands[0])"
3285 -+ "!TARGET_X32
3286 -+ && !ix86_indirect_branch_register
3287 -+ && peep2_reg_dead_p (2, operands[0])"
3288 - [(set (pc) (match_dup 1))])
3289 -
3290 - ;; Call subroutine, returning value in operand 0
3291 -@@ -12070,7 +12076,7 @@
3292 - (call (mem:QI (match_operand:W 1 "memory_operand" "m"))
3293 - (match_operand 2)))
3294 - (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
3295 -- "!TARGET_X32"
3296 -+ "!TARGET_X32 && !ix86_indirect_branch_register"
3297 - "* return ix86_output_call_insn (insn, operands[1]);"
3298 - [(set_attr "type" "callv")])
3299 -
3300 -@@ -12080,7 +12086,9 @@
3301 - (set (match_operand 2)
3302 - (call (mem:QI (match_dup 0))
3303 - (match_operand 3)))]
3304 -- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
3305 -+ "!TARGET_X32
3306 -+ && !ix86_indirect_branch_register
3307 -+ && SIBLING_CALL_P (peep2_next_insn (1))
3308 - && !reg_mentioned_p (operands[0],
3309 - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
3310 - [(parallel [(set (match_dup 2)
3311 -@@ -12095,7 +12103,9 @@
3312 - (set (match_operand 2)
3313 - (call (mem:QI (match_dup 0))
3314 - (match_operand 3)))]
3315 -- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
3316 -+ "!TARGET_X32
3317 -+ && !ix86_indirect_branch_register
3318 -+ && SIBLING_CALL_P (peep2_next_insn (2))
3319 - && !reg_mentioned_p (operands[0],
3320 - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
3321 - [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
3322 -@@ -12120,7 +12130,7 @@
3323 -
3324 - (define_insn "*call_value_pop"
3325 - [(set (match_operand 0)
3326 -- (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lmBz"))
3327 -+ (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lBwBz"))
3328 - (match_operand 2)))
3329 - (set (reg:SI SP_REG)
3330 - (plus:SI (reg:SI SP_REG)
3331 -diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
3332 -index b07388d..b90da9f 100644
3333 ---- a/gcc/config/i386/i386.opt
3334 -+++ b/gcc/config/i386/i386.opt
3335 -@@ -951,3 +951,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
3336 -
3337 - EnumValue
3338 - Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
3339 -+
3340 -+mindirect-branch-register
3341 -+Target Report Var(ix86_indirect_branch_register) Init(0)
3342 -+Force indirect call and jump via register.
3343 -diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
3344 -index 2fc2c60..e4da309 100644
3345 ---- a/gcc/config/i386/predicates.md
3346 -+++ b/gcc/config/i386/predicates.md
3347 -@@ -635,7 +635,8 @@
3348 - ;; Test for a valid operand for indirect branch.
3349 - (define_predicate "indirect_branch_operand"
3350 - (ior (match_operand 0 "register_operand")
3351 -- (and (not (match_test "TARGET_X32"))
3352 -+ (and (not (match_test "ix86_indirect_branch_register"))
3353 -+ (not (match_test "TARGET_X32"))
3354 - (match_operand 0 "memory_operand"))))
3355 -
3356 - ;; Return true if OP is a memory operands that can be used in sibcalls.
3357 -@@ -678,20 +679,22 @@
3358 - (ior (match_test "constant_call_address_operand
3359 - (op, mode == VOIDmode ? mode : Pmode)")
3360 - (match_operand 0 "call_register_no_elim_operand")
3361 -- (ior (and (not (match_test "TARGET_X32"))
3362 -- (match_operand 0 "memory_operand"))
3363 -- (and (match_test "TARGET_X32 && Pmode == DImode")
3364 -- (match_operand 0 "GOT_memory_operand")))))
3365 -+ (and (not (match_test "ix86_indirect_branch_register"))
3366 -+ (ior (and (not (match_test "TARGET_X32"))
3367 -+ (match_operand 0 "memory_operand"))
3368 -+ (and (match_test "TARGET_X32 && Pmode == DImode")
3369 -+ (match_operand 0 "GOT_memory_operand"))))))
3370 -
3371 - ;; Similarly, but for tail calls, in which we cannot allow memory references.
3372 - (define_special_predicate "sibcall_insn_operand"
3373 - (ior (match_test "constant_call_address_operand
3374 - (op, mode == VOIDmode ? mode : Pmode)")
3375 - (match_operand 0 "register_no_elim_operand")
3376 -- (ior (and (not (match_test "TARGET_X32"))
3377 -- (match_operand 0 "sibcall_memory_operand"))
3378 -- (and (match_test "TARGET_X32 && Pmode == DImode")
3379 -- (match_operand 0 "GOT_memory_operand")))))
3380 -+ (and (not (match_test "ix86_indirect_branch_register"))
3381 -+ (ior (and (not (match_test "TARGET_X32"))
3382 -+ (match_operand 0 "sibcall_memory_operand"))
3383 -+ (and (match_test "TARGET_X32 && Pmode == DImode")
3384 -+ (match_operand 0 "GOT_memory_operand"))))))
3385 -
3386 - ;; Return true if OP is a 32-bit GOT symbol operand.
3387 - (define_predicate "GOT32_symbol_operand"
3388 -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
3389 -index f3eb54b..1e572b1 100644
3390 ---- a/gcc/doc/invoke.texi
3391 -+++ b/gcc/doc/invoke.texi
3392 -@@ -1211,7 +1211,8 @@ See RS/6000 and PowerPC Options.
3393 - -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
3394 - -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
3395 - -mmitigate-rop -mgeneral-regs-only @gol
3396 ---mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
3397 -+-mindirect-branch=@var{choice} -mfunction-return==@var{choice} @gol
3398 -+-mindirect-branch-register}
3399 -
3400 - @emph{x86 Windows Options}
3401 - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
3402 -@@ -25709,6 +25710,10 @@ object file. You can control this behavior for a specific function by
3403 - using the function attribute @code{function_return}.
3404 - @xref{Function Attributes}.
3405 -
3406 -+@item -mindirect-branch-register
3407 -+@opindex -mindirect-branch-register
3408 -+Force indirect call and jump via register.
3409 -+
3410 - @end table
3411 -
3412 - These @samp{-m} switches are supported in addition to the above
3413
3414 diff --git a/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch b/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch
3415 deleted file mode 100644
3416 index afbccca..0000000
3417 --- a/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch
3418 +++ /dev/null
3419 @@ -1,128 +0,0 @@
3420 -From: "H dot J dot Lu" <hjl dot tools at gmail dot com>
3421 -To: gcc-patches at gcc dot gnu dot org
3422 -Subject: [PATCH 4/4] x86: Add 'V' register operand modifier
3423 -Date: Fri, 12 Jan 2018 05:15:49 -0800
3424 -
3425 -Add 'V', a special modifier which prints the name of the full integer
3426 -register without '%'. For
3427 -
3428 -extern void (*func_p) (void);
3429 -
3430 -void
3431 -foo (void)
3432 -{
3433 - asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
3434 -}
3435 -
3436 -it generates:
3437 -
3438 -foo:
3439 - movq func_p(%rip), %rax
3440 - call __x86_indirect_thunk_rax
3441 - ret
3442 -
3443 -gcc/
3444 -
3445 - * config/i386/i386.c (print_reg): Print the name of the full
3446 - integer register without '%'.
3447 - (ix86_print_operand): Handle 'V'.
3448 - * doc/extend.texi: Document 'V' modifier.
3449 -
3450 -gcc/testsuite/
3451 -
3452 - * gcc.target/i386/indirect-thunk-register-4.c: New test.
3453 ----
3454 - gcc/config/i386/i386.c | 13 ++++++++++++-
3455 - gcc/doc/extend.texi | 3 +++
3456 - gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c | 13 +++++++++++++
3457 - 3 files changed, 28 insertions(+), 1 deletion(-)
3458 - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
3459 -
3460 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
3461 -index 9ffcb69d6d7..e69135d7191 100644
3462 ---- a/gcc/config/i386/i386.c
3463 -+++ b/gcc/config/i386/i386.c
3464 -@@ -17617,6 +17617,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
3465 - If CODE is 'h', pretend the reg is the 'high' byte register.
3466 - If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
3467 - If CODE is 'd', duplicate the operand for AVX instruction.
3468 -+ If CODE is 'V', print naked full integer register name without %.
3469 - */
3470 -
3471 - void
3472 -@@ -17627,7 +17628,7 @@ print_reg (rtx x, int code, FILE *file)
3473 - unsigned int regno;
3474 - bool duplicated;
3475 -
3476 -- if (ASSEMBLER_DIALECT == ASM_ATT)
3477 -+ if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
3478 - putc ('%', file);
3479 -
3480 - if (x == pc_rtx)
3481 -@@ -17679,6 +17680,14 @@ print_reg (rtx x, int code, FILE *file)
3482 - return;
3483 - }
3484 -
3485 -+ if (code == 'V')
3486 -+ {
3487 -+ if (GENERAL_REGNO_P (regno))
3488 -+ msize = GET_MODE_SIZE (word_mode);
3489 -+ else
3490 -+ error ("'V' modifier on non-integer register");
3491 -+ }
3492 -+
3493 - duplicated = code == 'd' && TARGET_AVX;
3494 -
3495 - switch (msize)
3496 -@@ -17798,6 +17807,7 @@ print_reg (rtx x, int code, FILE *file)
3497 - & -- print some in-use local-dynamic symbol name.
3498 - H -- print a memory address offset by 8; used for sse high-parts
3499 - Y -- print condition for XOP pcom* instruction.
3500 -+ V -- print naked full integer register name without %.
3501 - + -- print a branch hint as 'cs' or 'ds' prefix
3502 - ; -- print a semicolon (after prefixes due to bug in older gas).
3503 - ~ -- print "i" if TARGET_AVX2, "f" otherwise.
3504 -@@ -18021,6 +18031,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
3505 - case 'X':
3506 - case 'P':
3507 - case 'p':
3508 -+ case 'V':
3509 - break;
3510 -
3511 - case 's':
3512 -diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
3513 -index f120b2a1429..dce808f1eab 100644
3514 ---- a/gcc/doc/extend.texi
3515 -+++ b/gcc/doc/extend.texi
3516 -@@ -9292,6 +9292,9 @@ The table below shows the list of supported modifiers and their effects.
3517 - @tab @code{2}
3518 - @end multitable
3519 -
3520 -+@code{V} is a special modifier which prints the name of the full integer
3521 -+register without @code{%}.
3522 -+
3523 - @anchor{x86floatingpointasmoperands}
3524 - @subsubsection x86 Floating-Point @code{asm} Operands
3525 -
3526 -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
3527 -new file mode 100644
3528 -index 00000000000..f0cd9b75be8
3529 ---- /dev/null
3530 -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
3531 -@@ -0,0 +1,13 @@
3532 -+/* { dg-do compile } */
3533 -+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
3534 -+
3535 -+extern void (*func_p) (void);
3536 -+
3537 -+void
3538 -+foo (void)
3539 -+{
3540 -+ asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
3541 -+}
3542 -+
3543 -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
3544 -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */
3545 ---
3546 -2.14.3
3547 -
3548
3549 diff --git a/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch b/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch
3550 deleted file mode 100644
3551 index 25574d4..0000000
3552 --- a/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch
3553 +++ /dev/null
3554 @@ -1,105 +0,0 @@
3555 -From 5d1c53c6fd593de2360c1a2ae44ebf5fa3c5263b Mon Sep 17 00:00:00 2001
3556 -From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
3557 -Date: Tue, 16 Jan 2018 11:22:01 +0000
3558 -Subject: [PATCH] x86: Disallow -mindirect-branch=/-mfunction-return= with
3559 - -mcmodel=large
3560 -
3561 -Since the thunk function may not be reachable in large code model,
3562 --mcmodel=large is incompatible with -mindirect-branch=thunk,
3563 --mindirect-branch=thunk-extern, -mfunction-return=thunk and
3564 --mfunction-return=thunk-extern. Issue an error when they are used with
3565 --mcmodel=large.
3566 -
3567 -gcc/
3568 -
3569 - Backport from mainline
3570 - 2018-01-14 H.J. Lu <hongjiu.lu@×××××.com>
3571 -
3572 - * config/i386/i386.c (ix86_set_indirect_branch_type): Disallow
3573 - -mcmodel=large with -mindirect-branch=thunk,
3574 - -mindirect-branch=thunk-extern, -mfunction-return=thunk and
3575 - -mfunction-return=thunk-extern.
3576 - * doc/invoke.texi: Document -mcmodel=large is incompatible with
3577 - -mindirect-branch=thunk, -mindirect-branch=thunk-extern,
3578 - -mfunction-return=thunk and -mfunction-return=thunk-extern.
3579 -
3580 -
3581 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256737 138bc75d-0d04-0410-961f-82ee72b054a4
3582 ----
3583 - gcc/config/i386/i386.c | 26 ++++++++++++++++++++++
3584 - gcc/doc/invoke.texi | 11 +++++++++
3585 - 15 files changed, 156 insertions(+)
3586 -
3587 -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
3588 -index 1bbdd0c..e758387 100644
3589 ---- a/gcc/config/i386/i386.c
3590 -+++ b/gcc/config/i386/i386.c
3591 -@@ -7187,6 +7187,19 @@ ix86_set_indirect_branch_type (tree fndecl)
3592 - }
3593 - else
3594 - cfun->machine->indirect_branch_type = ix86_indirect_branch;
3595 -+
3596 -+ /* -mcmodel=large is not compatible with -mindirect-branch=thunk
3597 -+ nor -mindirect-branch=thunk-extern. */
3598 -+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3599 -+ && ((cfun->machine->indirect_branch_type
3600 -+ == indirect_branch_thunk_extern)
3601 -+ || (cfun->machine->indirect_branch_type
3602 -+ == indirect_branch_thunk)))
3603 -+ error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
3604 -+ "compatible",
3605 -+ ((cfun->machine->indirect_branch_type
3606 -+ == indirect_branch_thunk_extern)
3607 -+ ? "thunk-extern" : "thunk"));
3608 - }
3609 -
3610 - if (cfun->machine->function_return_type == indirect_branch_unset)
3611 -@@ -7212,6 +7225,19 @@ ix86_set_indirect_branch_type (tree fndecl)
3612 - }
3613 - else
3614 - cfun->machine->function_return_type = ix86_function_return;
3615 -+
3616 -+ /* -mcmodel=large is not compatible with -mfunction-return=thunk
3617 -+ nor -mfunction-return=thunk-extern. */
3618 -+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3619 -+ && ((cfun->machine->function_return_type
3620 -+ == indirect_branch_thunk_extern)
3621 -+ || (cfun->machine->function_return_type
3622 -+ == indirect_branch_thunk)))
3623 -+ error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
3624 -+ "compatible",
3625 -+ ((cfun->machine->function_return_type
3626 -+ == indirect_branch_thunk_extern)
3627 -+ ? "thunk-extern" : "thunk"));
3628 - }
3629 - }
3630 -
3631 -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
3632 -index 1e572b1..6f3c344 100644
3633 ---- a/gcc/doc/invoke.texi
3634 -+++ b/gcc/doc/invoke.texi
3635 -@@ -25699,6 +25699,11 @@ to external call and return thunk provided in a separate object file.
3636 - You can control this behavior for a specific function by using the
3637 - function attribute @code{indirect_branch}. @xref{Function Attributes}.
3638 -
3639 -+Note that @option{-mcmodel=large} is incompatible with
3640 -+@option{-mindirect-branch=thunk} nor
3641 -+@option{-mindirect-branch=thunk-extern} since the thunk function may
3642 -+not be reachable in large code model.
3643 -+
3644 - @item -mfunction-return=@var{choice}
3645 - @opindex -mfunction-return
3646 - Convert function return with @var{choice}. The default is @samp{keep},
3647 -@@ -25710,6 +25715,12 @@ object file. You can control this behavior for a specific function by
3648 - using the function attribute @code{function_return}.
3649 - @xref{Function Attributes}.
3650 -
3651 -+Note that @option{-mcmodel=large} is incompatible with
3652 -+@option{-mfunction-return=thunk} nor
3653 -+@option{-mfunction-return=thunk-extern} since the thunk function may
3654 -+not be reachable in large code model.
3655 -+
3656 -+
3657 - @item -mindirect-branch-register
3658 - @opindex -mindirect-branch-register
3659 - Force indirect call and jump via register.
3660
3661 diff --git a/sys-devel/gcc/gcc-4.9.4-r100.ebuild b/sys-devel/gcc/gcc-4.9.4-r100.ebuild
3662 deleted file mode 100644
3663 index 8ebef29..0000000
3664 --- a/sys-devel/gcc/gcc-4.9.4-r100.ebuild
3665 +++ /dev/null
3666 @@ -1,66 +0,0 @@
3667 -# Copyright 1999-2016 Gentoo Foundation
3668 -# Distributed under the terms of the GNU General Public License v2
3669 -
3670 -EAPI="5"
3671 -
3672 -PATCH_VER="1.0"
3673 -UCLIBC_VER="1.0"
3674 -
3675 -# Hardened gcc 4 stuff
3676 -PIE_VER="0.6.4"
3677 -SPECS_VER="0.2.0"
3678 -SPECS_GCC_VER="4.4.3"
3679 -# arch/libc configurations known to be stable with {PIE,SSP}-by-default
3680 -PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
3681 -PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
3682 -SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
3683 -# uclibc need tls and nptl support for SSP support
3684 -# uclibc need to be >= 0.9.33
3685 -SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
3686 -PIE_MUSL_STABLE="amd64 arm ppc mips x86"
3687 -SSP_MUSL_STABLE="amd64 arm ppc mips"
3688 -#end Hardened stuff
3689 -
3690 -inherit eutils toolchain
3691 -
3692 -KEYWORDS="~amd64 ~arm ~mips ~x86"
3693 -
3694 -RDEPEND=""
3695 -DEPEND="${RDEPEND}
3696 - elibc_glibc? ( >=sys-libs/glibc-2.8 )
3697 - >=${CATEGORY}/binutils-2.20"
3698 -
3699 -if [[ ${CATEGORY} != cross-* ]] ; then
3700 - PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
3701 -fi
3702 -
3703 -src_prepare() {
3704 - if has_version '<sys-libs/glibc-2.12' ; then
3705 - ewarn "Your host glibc is too old; disabling automatic fortify."
3706 - ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
3707 - EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
3708 - fi
3709 -
3710 - toolchain_src_prepare
3711 -
3712 - if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
3713 - cd "${S}"
3714 - sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
3715 - mv libstdc\+\+-v3/config/os/gnu-linux libstdc\+\+-v3/config/os/gnu-linux.org
3716 - cp -r libstdc\+\+-v3/config/os/generic libstdc\+\+-v3/config/os/gnu-linux
3717 - cp libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver libstdc++-v3/config/os/gnu-linux/
3718 - mv libitm/config/linux/x86 libitm/config/linux/x86_glibc
3719 - cp -r libitm/config/generic libitm/config/linux/x86
3720 - epatch "${FILESDIR}"/${PN}-4.9.3-musl-linker-path.patch
3721 - epatch "${FILESDIR}"/${PN}-4.9.3-secure-plt.patch
3722 - epatch "${FILESDIR}"/${PN}-4.9.3-musl-res_state.patch
3723 - epatch "${FILESDIR}"/${PN}-4.8.3-musl-fix-libc5-assumption.patch
3724 - epatch "${FILESDIR}"/${PN}-4.8.5-posix_memalign.patch
3725 - epatch "${FILESDIR}"/${PN}-4.9.3-tree-vect-data-refs-correctness.patch
3726 - epatch "${FILESDIR}"/${PN}-4.9.3-pr68470.patch
3727 - fi
3728 -
3729 - use vanilla && return 0
3730 - #Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
3731 - [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
3732 -}
3733
3734 diff --git a/sys-devel/gcc/gcc-4.9.4-r99.ebuild b/sys-devel/gcc/gcc-4.9.4-r99.ebuild
3735 deleted file mode 100644
3736 index a65bc67..0000000
3737 --- a/sys-devel/gcc/gcc-4.9.4-r99.ebuild
3738 +++ /dev/null
3739 @@ -1,65 +0,0 @@
3740 -# Copyright 1999-2016 Gentoo Foundation
3741 -# Distributed under the terms of the GNU General Public License v2
3742 -
3743 -EAPI="5"
3744 -
3745 -PATCH_VER="1.0"
3746 -UCLIBC_VER="1.0"
3747 -
3748 -# Hardened gcc 4 stuff
3749 -PIE_VER="0.6.4"
3750 -SPECS_VER="0.2.0"
3751 -SPECS_GCC_VER="4.4.3"
3752 -# arch/libc configurations known to be stable with {PIE,SSP}-by-default
3753 -PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
3754 -PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
3755 -SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
3756 -# uclibc need tls and nptl support for SSP support
3757 -# uclibc need to be >= 0.9.33
3758 -SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
3759 -PIE_MUSL_STABLE="amd64 arm ppc mips x86"
3760 -SSP_MUSL_STABLE="amd64 arm ppc mips"
3761 -#end Hardened stuff
3762 -
3763 -inherit eutils toolchain
3764 -
3765 -KEYWORDS="amd64 arm ~mips x86"
3766 -
3767 -RDEPEND=""
3768 -DEPEND="${RDEPEND}
3769 - elibc_glibc? ( >=sys-libs/glibc-2.8 )
3770 - >=${CATEGORY}/binutils-2.20"
3771 -
3772 -if [[ ${CATEGORY} != cross-* ]] ; then
3773 - PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
3774 -fi
3775 -
3776 -src_prepare() {
3777 - if has_version '<sys-libs/glibc-2.12' ; then
3778 - ewarn "Your host glibc is too old; disabling automatic fortify."
3779 - ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
3780 - EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
3781 - fi
3782 -
3783 - toolchain_src_prepare
3784 -
3785 - if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
3786 - cd "${S}"
3787 - sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
3788 - mv libstdc\+\+-v3/config/os/gnu-linux libstdc\+\+-v3/config/os/gnu-linux.org
3789 - cp -r libstdc\+\+-v3/config/os/generic libstdc\+\+-v3/config/os/gnu-linux
3790 - cp libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver libstdc++-v3/config/os/gnu-linux/
3791 - mv libitm/config/linux/x86 libitm/config/linux/x86_glibc
3792 - cp -r libitm/config/generic libitm/config/linux/x86
3793 - epatch "${FILESDIR}"/${PN}-4.9.3-musl-linker-path.patch
3794 - epatch "${FILESDIR}"/${PN}-4.9.3-secure-plt.patch
3795 - epatch "${FILESDIR}"/${PN}-4.9.3-musl-res_state.patch
3796 - epatch "${FILESDIR}"/${PN}-4.8.3-musl-fix-libc5-assumption.patch
3797 - epatch "${FILESDIR}"/${PN}-4.8.5-posix_memalign.patch
3798 - epatch "${FILESDIR}"/${PN}-4.9.3-tree-vect-data-refs-correctness.patch
3799 - fi
3800 -
3801 - use vanilla && return 0
3802 - #Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
3803 - [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
3804 -}
3805
3806 diff --git a/sys-devel/gcc/gcc-7.2.0-r1.ebuild b/sys-devel/gcc/gcc-7.2.0-r1.ebuild
3807 deleted file mode 100644
3808 index 7dd6ca3..0000000
3809 --- a/sys-devel/gcc/gcc-7.2.0-r1.ebuild
3810 +++ /dev/null
3811 @@ -1,31 +0,0 @@
3812 -# Copyright 1999-2018 Gentoo Foundation
3813 -# Distributed under the terms of the GNU General Public License v2
3814 -
3815 -EAPI="5"
3816 -
3817 -PATCH_VER="1.1"
3818 -#UCLIBC_VER="1.0"
3819 -
3820 -inherit epatch toolchain
3821 -
3822 -KEYWORDS="~amd64 ~arm ~mips ~ppc ~x86"
3823 -
3824 -RDEPEND=""
3825 -DEPEND="${RDEPEND}
3826 - elibc_glibc? ( >=sys-libs/glibc-2.13 )
3827 - >=${CATEGORY}/binutils-2.20"
3828 -
3829 -if [[ ${CATEGORY} != cross-* ]] ; then
3830 - PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
3831 -fi
3832 -
3833 -src_prepare() {
3834 - toolchain_src_prepare
3835 -
3836 - epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
3837 -
3838 - if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
3839 - epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
3840 - epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
3841 - fi
3842 -}
3843
3844 diff --git a/sys-devel/gcc/gcc-7.2.0-r2.ebuild b/sys-devel/gcc/gcc-7.2.0-r2.ebuild
3845 deleted file mode 100644
3846 index 40df421..0000000
3847 --- a/sys-devel/gcc/gcc-7.2.0-r2.ebuild
3848 +++ /dev/null
3849 @@ -1,41 +0,0 @@
3850 -# Copyright 1999-2018 Gentoo Foundation
3851 -# Distributed under the terms of the GNU General Public License v2
3852 -
3853 -EAPI="5"
3854 -
3855 -PATCH_VER="1.1"
3856 -#UCLIBC_VER="1.0"
3857 -
3858 -inherit epatch toolchain
3859 -
3860 -# KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
3861 -
3862 -RDEPEND=""
3863 -DEPEND="${RDEPEND}
3864 - elibc_glibc? ( >=sys-libs/glibc-2.13 )
3865 - >=${CATEGORY}/binutils-2.20"
3866 -
3867 -if [[ ${CATEGORY} != cross-* ]] ; then
3868 - PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
3869 -fi
3870 -
3871 -src_prepare() {
3872 - toolchain_src_prepare
3873 -
3874 - epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
3875 -
3876 - # Meltdown/Spectre
3877 - epatch "${FILESDIR}"/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
3878 - epatch "${FILESDIR}"/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
3879 -
3880 - epatch "${FILESDIR}"/spectre-0001-mindirect-branch.patch
3881 - epatch "${FILESDIR}"/spectre-0002-mfunction-return.patch
3882 - epatch "${FILESDIR}"/spectre-0003-mindirect-branch-register.patch
3883 - epatch "${FILESDIR}"/spectre-0004-v-register-modifier.patch
3884 - epatch "${FILESDIR}"/spectre-0005-mcmodel-large.patch
3885 -
3886 - if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
3887 - epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
3888 - epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
3889 - fi
3890 -}
3891
3892 diff --git a/sys-devel/gcc/gcc-7.3.0-r1.ebuild b/sys-devel/gcc/gcc-7.3.0-r1.ebuild
3893 deleted file mode 100644
3894 index 7dd6ca3..0000000
3895 --- a/sys-devel/gcc/gcc-7.3.0-r1.ebuild
3896 +++ /dev/null
3897 @@ -1,31 +0,0 @@
3898 -# Copyright 1999-2018 Gentoo Foundation
3899 -# Distributed under the terms of the GNU General Public License v2
3900 -
3901 -EAPI="5"
3902 -
3903 -PATCH_VER="1.1"
3904 -#UCLIBC_VER="1.0"
3905 -
3906 -inherit epatch toolchain
3907 -
3908 -KEYWORDS="~amd64 ~arm ~mips ~ppc ~x86"
3909 -
3910 -RDEPEND=""
3911 -DEPEND="${RDEPEND}
3912 - elibc_glibc? ( >=sys-libs/glibc-2.13 )
3913 - >=${CATEGORY}/binutils-2.20"
3914 -
3915 -if [[ ${CATEGORY} != cross-* ]] ; then
3916 - PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
3917 -fi
3918 -
3919 -src_prepare() {
3920 - toolchain_src_prepare
3921 -
3922 - epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
3923 -
3924 - if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
3925 - epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
3926 - epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
3927 - fi
3928 -}