aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAric Belsito <lluixhi@gmail.com>2018-06-29 17:56:08 -0700
committerAric Belsito <lluixhi@gmail.com>2018-06-29 17:56:08 -0700
commit877c6d3a1bf239d117bcd3fa39dce1ae248d0e51 (patch)
tree6fd4e9d374a072d3deeb1184fa5ca0b236330d6e
parentdev-libs/appstream-glib: new package (diff)
downloadmusl-877c6d3a1bf239d117bcd3fa39dce1ae248d0e51.tar.gz
musl-877c6d3a1bf239d117bcd3fa39dce1ae248d0e51.tar.bz2
musl-877c6d3a1bf239d117bcd3fa39dce1ae248d0e51.zip
sys-devel/gcc: cleanup
-rw-r--r--sys-devel/gcc/Manifest6
-rw-r--r--sys-devel/gcc/files/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch237
-rw-r--r--sys-devel/gcc/files/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch68
-rw-r--r--sys-devel/gcc/files/gcc-4.8.3-musl-fix-libc5-assumption.patch11
-rw-r--r--sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch30
-rw-r--r--sys-devel/gcc/files/gcc-4.9.3-musl-linker-path.patch74
-rw-r--r--sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch12
-rw-r--r--sys-devel/gcc/files/gcc-4.9.3-pr68470.patch58
-rw-r--r--sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch39
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/aarch64.diff12
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/arm.diff46
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff62
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-config-musl.diff207
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff12
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/gomp-posix.diff16
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/gthread.diff16
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/kill-fixincludes.diff17
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/libstdc++-generic.diff31
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze-size_t.diff39
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze.diff31
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/mips.diff18
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/powerpc.diff108
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff18
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/unwind-dliterate.diff43
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff15
-rw-r--r--sys-devel/gcc/files/musl-gcc-patches-4.9.3/x86.diff55
-rw-r--r--sys-devel/gcc/files/spectre-0001-mindirect-branch.patch1084
-rw-r--r--sys-devel/gcc/files/spectre-0002-mfunction-return.patch447
-rw-r--r--sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch340
-rw-r--r--sys-devel/gcc/files/spectre-0004-v-register-modifier.patch128
-rw-r--r--sys-devel/gcc/files/spectre-0005-mcmodel-large.patch105
-rw-r--r--sys-devel/gcc/gcc-4.9.4-r100.ebuild66
-rw-r--r--sys-devel/gcc/gcc-4.9.4-r99.ebuild65
-rw-r--r--sys-devel/gcc/gcc-7.2.0-r1.ebuild31
-rw-r--r--sys-devel/gcc/gcc-7.2.0-r2.ebuild41
-rw-r--r--sys-devel/gcc/gcc-7.3.0-r1.ebuild31
36 files changed, 0 insertions, 3619 deletions
diff --git a/sys-devel/gcc/Manifest b/sys-devel/gcc/Manifest
index 87b1ea8..a624cc8 100644
--- a/sys-devel/gcc/Manifest
+++ b/sys-devel/gcc/Manifest
@@ -1,9 +1,5 @@
DIST ecj-4.5.jar 1470676 BLAKE2B 793c10ba09fd8040c0e1181204141aea16780c9c9088e07126e00da2b510af2ad6f58d876357d7e98cbb02d783a3be434469d5de1df134ccb8cc508e45028d80 SHA512 d4e1bf7538ace56e3d69fa91da5bbd16c272923b4de0a9d8dee23ea2b75f9f38c603de72fc4061df49285c450b63f3df211cee5270e9fffc5447445d1a9c9e4e
DIST gcc-4.4.3-specs-0.2.0.tar.bz2 2004 BLAKE2B 96f5ba2028bc6e0ef71e009857c37118a54d13d30de24d697c85e5772f9f2b7853615648cf2e4ee81d8385f6518c64588c0b56675c00f95ef39fca2a808f075e SHA512 779ecb0a064d2138b54569c8ae501975b8a6b72e5a3acbf8597619a8db77ee42ef9b0e62608d5192a15e4393e7dfc009bb50b994782236faa744b2c46b5fe517
-DIST gcc-4.9.4-patches-1.0.tar.bz2 22266 BLAKE2B 38536e8a86a8296754311633b73da0bd7dddb3a6ac65e4b5ba1dde352789e9114a1129aad11bcb988a1baadec6fdf893290c6af83bb9fad5613f35a37ebbb12e SHA512 cc2407221f858bad38b57d31f635314f91794293695e23d255685d8bec20b9db19c7dc76bbf5e8184c2ba0ccb530958b09bae4d8a402ca27cadf463f46bfb995
-DIST gcc-4.9.4-piepatches-v0.6.4.tar.bz2 14414 BLAKE2B 2eccd4f2a164fbb32d13c7fe91627a2424c0a5570fe0cac97c2bb1c95294ba3d770832da7c445f75c91791466c5139a1e13753a3a40d87ff5e44e42749adee27 SHA512 243fa272ea0e49f700a76508bab3e03bbb353bcb930581b2f87f9a47df5cd3880e29f20b71612b21190adc463849e1e6ac2a38a49c0002b562d93d436f538285
-DIST gcc-4.9.4-uclibc-patches-1.0.tar.bz2 2618 BLAKE2B bff85a4088fb94fdb7a8b0bd552be98ace3e6d145889b6f8b4a1f2db2dad14342d155890ab159b42d5b55d88dfb7c392eb7f92590084e1958f6284c561da30f1 SHA512 5a1f44caa9261f4947101379628143869b31dec67fa28605e8e1f3894d4b7120c3f68ba6deb59da7a74fa906e27ab32cd3767761837dc3dfebc37865d349d6db
-DIST gcc-4.9.4.tar.bz2 90097606 BLAKE2B 373ff939ea72d6c4a7f3ab899b852b4c919481af2cfe3291281d9354c58a270d2eba73a0f301d90840dfabf423c82b368e113df7a2cb6cc28b2a703b0b6eb585 SHA512 93abb78e16277454f41a8e9810f41f66c0fdffdc539a762ff6b67d3037f78db971378683fd2ebf707d1d51c059fad2161fe42d110c330027f40214b7db0f3efe
DIST gcc-5.4.0-patches-1.8.tar.bz2 32886 BLAKE2B 85879ba552ff21e198de568b2a1f2544d6cf542174af3ca571e41a504373bbc8912a87177a413883f194d909237eeeaf65366e6b93c2b917f803b3edd10bbff5 SHA512 10c1102a37d9d485665cca606318a1da6eec2188998d340b91a371c9defa6fae285619f9cadad2546de0b7f1068e9eaf653714462d3331db3197308799927a6b
DIST gcc-5.4.0-piepatches-v0.6.5.tar.bz2 14551 BLAKE2B 6f3de9be0990a7580785821d8c85114a1907571c06bdf3a15ad91258f7c9e8bb6a4d2ddb8615f33bedf0ad036d215507e004fc095f788e40c824ae0ab3ffbb05 SHA512 4890f0713d261982ab81a20f93c5f65193aa1dfa171e3f9e5867f0b80ec7c1e76c5a997b1a4e6f47f8ce36af54ac91125c5bff8bf6d971b7d77c65a57a40a3c0
DIST gcc-5.4.0-uclibc-patches-1.0.tar.bz2 3731 BLAKE2B fa436d1c1d9c150714092132f816740f8218dfeb4f9a6a8c830ea54d211a020f209e6fd1fcc313b2560b82c7855120053d346af72b7c12c88a7a948379dd2356 SHA512 009f34197e79c5e8c6497a0db01ac45cc657e92e56a663b4f3281661d108b2a129cd977fab5f0064f225d6812ae91e82bab22a2b10ae02c486881eeed85ec7a3
@@ -11,8 +7,6 @@ DIST gcc-5.4.0.tar.bz2 95661481 BLAKE2B bf882acfa28cc1064cddd21e25332fff6bc65505
DIST gcc-6.4.0-patches-1.3.tar.bz2 13617 BLAKE2B 6bfb1d70397e6ca4359e5d190e36003c18c7a03a9be4f923461dcff11307601e6b3502a2e289585b53baeb919008d83c29ad24078f814aed9b331140e4687419 SHA512 91be7c8db0004cdd150fec0f8daa709374753d2f524c58087dcf45b6696dbd609972297e866f971fba1aa679464cf96a384dd111e104183c0939ab69add017b2
DIST gcc-6.4.0-uclibc-patches-1.0.tar.bz2 1586 BLAKE2B 21f97a9e1c349b3d52def092a03e5a90533521da9af586be7ee527594f2d65745491ff8758d88c99a7ac215bde7ebf4e47a0a36cfcd7e66f70e0bebf2dadd922 SHA512 266dbe2bb53d892a24cd752d5c6833ea33f8df8b11b0471700ee53865243cd41f412f9bea8a369b474c9cd1435faff2e03902c7cb5638dd3ddcaa665aa2ec522
DIST gcc-6.4.0.tar.xz 76156220 BLAKE2B 2018c338b28ea644cdd1b327cb0dfe7ee9aa2010357c93f7e71969f587c58d3fdfa2bb4c82a309490c48bc86924400022fa93f41dc6c4345878d1bc1d8204265 SHA512 02c60e54527c7adf584798d5251f8a0b80c93d5deafce82501b2c28e6692e0bd783927bbfc4bc527a863c0cccc025150a34740a9e29badb02d4b48e56a8aba90
-DIST gcc-7.2.0-patches-1.1.tar.bz2 9246 BLAKE2B f6eec8459e5ac1f177d9a417c59616ad53e4ba6da8744cf55922d3a401717bd5bfdf79296a1c0b856cfa03349e73b8034ab6024b83d3f5ef909534811ba470f2 SHA512 d08b31d1279cc4c6ba46b2dca6ebed4e5c8e4997f0859acab86c974209ce4aacd0df09632e70c3fb8ee7108ecb8208c8b8605e66a7e8d2568e45644bfeee4fbe
-DIST gcc-7.2.0.tar.xz 62312628 BLAKE2B 35e4b732f1a4515fc1a9d4424797177112847588e600dc5531bc9bf72305619d4100e8fd9d945920245e704fc9ac5bc5e3dbd20be6c3af49e689fc5bd1eca10f SHA512 f853cd6530b4055d8d8289da74687cb4c6d5f363598d386332d31852b581bac76c3adb7d61889edec3b779f63d8646f0122840f12965ce4a4389ba535dbbb6e1
DIST gcc-7.3.0-patches-1.1.tar.bz2 7439 BLAKE2B b6eff6f96cf4daf7b8debc767dc5ee1924a27be95c0a9a5d5ba957978f224c0907570e1492398865c4fa27d3b8f7c2f0fea2da813bf6b4ebb0fa66f9ccca9c46 SHA512 864a433c8f153a216c1028c553ffc3c84c474498c637ca6978e86fbb2ce4c07291c2561aabc2caa4953c012b8e18c277383ca153d56e13006967680119f9bcfa
DIST gcc-7.3.0-patches-1.4.tar.bz2 8238 BLAKE2B 72a5dcb046558c8f5c3a75040fe24ce1106c43af7510d6febf667b4377cb9caea5ebe9e1287af90e4ebfffa3f3f22ca85f533acf57c2e2d896f92adc1659b9f5 SHA512 24ed0d82240426efb111bbf48913b96fdc824ae3aa5a653298a726ebe64a40791f484229bbab9cc58f73d658e0b4b83ccd13081cfbea6e1673ef1d076cca3b33
DIST gcc-7.3.0.tar.xz 62462388 BLAKE2B dc8f132b21bd0543c3d9dd17557038aafe65675aa73c540954234a3c972b4c31c939149bd50183d072ab6c8d16919e19daeaaffd619ce2ccd62dbdf9a5bb3302 SHA512 ad41a7e4584e40e92cdf860bc0288500fbaf5dfb7e8c3fcabe9eba809c87bcfa85b46c19c19921b0cdf6d05483faede8287bb9ea120c0d1559449a70e602c8d4
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
deleted file mode 100644
index d85ed2c..0000000
--- a/sys-devel/gcc/files/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
+++ /dev/null
@@ -1,237 +0,0 @@
-From: "H.J. Lu" <hjl.tools@gmail.com>
-To: gcc-patches@gcc.gnu.org
-Subject: [1/3] GCC 7: i386: Move struct ix86_frame to machine_function
-Date: Sun, 14 Jan 2018 07:02:35 -0800
-
-Make ix86_frame available to i386 code generation. This is needed to
-backport the patch set of -mindirect-branch= to mitigate variant #2 of
-the speculative execution vulnerabilities on x86 processors identified
-by CVE-2017-5715, aka Spectre.
-
- Backport from mainline
- * config/i386/i386.c (ix86_frame): Moved to ...
- * config/i386/i386.h (ix86_frame): Here.
- (machine_function): Add frame.
- * config/i386/i386.c (ix86_compute_frame_layout): Repace the
- frame argument with &cfun->machine->frame.
- (ix86_can_use_return_insn_p): Don't pass &frame to
- ix86_compute_frame_layout. Copy frame from cfun->machine->frame.
- (ix86_can_eliminate): Likewise.
- (ix86_expand_prologue): Likewise.
- (ix86_expand_epilogue): Likewise.
- (ix86_expand_split_stack_prologue): Likewise.
----
- gcc/config/i386/i386.c | 68 ++++++++++----------------------------------------
- gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++-
- 2 files changed, 65 insertions(+), 56 deletions(-)
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 8a3782c0298..813337242d8 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -2444,53 +2444,6 @@ struct GTY(()) stack_local_entry {
- struct stack_local_entry *next;
- };
-
--/* Structure describing stack frame layout.
-- Stack grows downward:
--
-- [arguments]
-- <- ARG_POINTER
-- saved pc
--
-- saved static chain if ix86_static_chain_on_stack
--
-- saved frame pointer if frame_pointer_needed
-- <- HARD_FRAME_POINTER
-- [saved regs]
-- <- regs_save_offset
-- [padding0]
--
-- [saved SSE regs]
-- <- sse_regs_save_offset
-- [padding1] |
-- | <- FRAME_POINTER
-- [va_arg registers] |
-- |
-- [frame] |
-- |
-- [padding2] | = to_allocate
-- <- STACK_POINTER
-- */
--struct ix86_frame
--{
-- int nsseregs;
-- int nregs;
-- int va_arg_size;
-- int red_zone_size;
-- int outgoing_arguments_size;
--
-- /* The offsets relative to ARG_POINTER. */
-- HOST_WIDE_INT frame_pointer_offset;
-- HOST_WIDE_INT hard_frame_pointer_offset;
-- HOST_WIDE_INT stack_pointer_offset;
-- HOST_WIDE_INT hfp_save_offset;
-- HOST_WIDE_INT reg_save_offset;
-- HOST_WIDE_INT sse_reg_save_offset;
--
-- /* When save_regs_using_mov is set, emit prologue using
-- move instead of push instructions. */
-- bool save_regs_using_mov;
--};
--
- /* Which cpu are we scheduling for. */
- enum attr_cpu ix86_schedule;
-
-@@ -2582,7 +2535,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode,
- const_tree);
- static rtx ix86_static_chain (const_tree, bool);
- static int ix86_function_regparm (const_tree, const_tree);
--static void ix86_compute_frame_layout (struct ix86_frame *);
-+static void ix86_compute_frame_layout (void);
- static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode,
- rtx, rtx, int);
- static void ix86_add_new_builtins (HOST_WIDE_INT, HOST_WIDE_INT);
-@@ -11903,7 +11856,8 @@ ix86_can_use_return_insn_p (void)
- if (crtl->args.pops_args && crtl->args.size >= 32768)
- return 0;
-
-- ix86_compute_frame_layout (&frame);
-+ ix86_compute_frame_layout ();
-+ frame = cfun->machine->frame;
- return (frame.stack_pointer_offset == UNITS_PER_WORD
- && (frame.nregs + frame.nsseregs) == 0);
- }
-@@ -12389,8 +12343,8 @@ ix86_can_eliminate (const int from, const int to)
- HOST_WIDE_INT
- ix86_initial_elimination_offset (int from, int to)
- {
-- struct ix86_frame frame;
-- ix86_compute_frame_layout (&frame);
-+ ix86_compute_frame_layout ();
-+ struct ix86_frame frame = cfun->machine->frame;
-
- if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
- return frame.hard_frame_pointer_offset;
-@@ -12429,8 +12383,9 @@ ix86_builtin_setjmp_frame_value (void)
- /* Fill structure ix86_frame about frame of currently computed function. */
-
- static void
--ix86_compute_frame_layout (struct ix86_frame *frame)
-+ix86_compute_frame_layout (void)
- {
-+ struct ix86_frame *frame = &cfun->machine->frame;
- unsigned HOST_WIDE_INT stack_alignment_needed;
- HOST_WIDE_INT offset;
- unsigned HOST_WIDE_INT preferred_alignment;
-@@ -13737,7 +13692,8 @@ ix86_expand_prologue (void)
- m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET;
- m->fs.sp_valid = true;
-
-- ix86_compute_frame_layout (&frame);
-+ ix86_compute_frame_layout ();
-+ frame = m->frame;
-
- if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
- {
-@@ -14405,7 +14361,8 @@ ix86_expand_epilogue (int style)
- bool using_drap;
-
- ix86_finalize_stack_realign_flags ();
-- ix86_compute_frame_layout (&frame);
-+ ix86_compute_frame_layout ();
-+ frame = m->frame;
-
- m->fs.sp_valid = (!frame_pointer_needed
- || (crtl->sp_is_unchanging
-@@ -14915,7 +14872,8 @@ ix86_expand_split_stack_prologue (void)
- gcc_assert (flag_split_stack && reload_completed);
-
- ix86_finalize_stack_realign_flags ();
-- ix86_compute_frame_layout (&frame);
-+ ix86_compute_frame_layout ();
-+ frame = cfun->machine->frame;
- allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
-
- /* This is the label we will branch to if we have enough stack
-diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
-index 9c776dc5172..f9b91286a01 100644
---- a/gcc/config/i386/i386.h
-+++ b/gcc/config/i386/i386.h
-@@ -2451,9 +2451,56 @@ enum avx_u128_state
-
- #define FASTCALL_PREFIX '@'
-
-+#ifndef USED_FOR_TARGET
-+/* Structure describing stack frame layout.
-+ Stack grows downward:
-+
-+ [arguments]
-+ <- ARG_POINTER
-+ saved pc
-+
-+ saved static chain if ix86_static_chain_on_stack
-+
-+ saved frame pointer if frame_pointer_needed
-+ <- HARD_FRAME_POINTER
-+ [saved regs]
-+ <- regs_save_offset
-+ [padding0]
-+
-+ [saved SSE regs]
-+ <- sse_regs_save_offset
-+ [padding1] |
-+ | <- FRAME_POINTER
-+ [va_arg registers] |
-+ |
-+ [frame] |
-+ |
-+ [padding2] | = to_allocate
-+ <- STACK_POINTER
-+ */
-+struct GTY(()) ix86_frame
-+{
-+ int nsseregs;
-+ int nregs;
-+ int va_arg_size;
-+ int red_zone_size;
-+ int outgoing_arguments_size;
-+
-+ /* The offsets relative to ARG_POINTER. */
-+ HOST_WIDE_INT frame_pointer_offset;
-+ HOST_WIDE_INT hard_frame_pointer_offset;
-+ HOST_WIDE_INT stack_pointer_offset;
-+ HOST_WIDE_INT hfp_save_offset;
-+ HOST_WIDE_INT reg_save_offset;
-+ HOST_WIDE_INT sse_reg_save_offset;
-+
-+ /* When save_regs_using_mov is set, emit prologue using
-+ move instead of push instructions. */
-+ bool save_regs_using_mov;
-+};
-+
- /* Machine specific frame tracking during prologue/epilogue generation. */
-
--#ifndef USED_FOR_TARGET
- struct GTY(()) machine_frame_state
- {
- /* This pair tracks the currently active CFA as reg+offset. When reg
-@@ -2512,6 +2559,9 @@ struct GTY(()) machine_function {
- int varargs_fpr_size;
- int optimize_mode_switching[MAX_386_ENTITIES];
-
-+ /* Cached initial frame layout for the current function. */
-+ struct ix86_frame frame;
-+
- /* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE
- has been computed for. */
- int use_fast_prologue_epilogue_nregs;
-@@ -2594,6 +2644,7 @@ struct GTY(()) machine_function {
- #define ix86_current_function_calls_tls_descriptor \
- (ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG))
- #define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack)
-+#define ix86_red_zone_size (cfun->machine->frame.red_zone_size)
-
- /* Control behavior of x86_file_start. */
- #define X86_FILE_START_VERSION_DIRECTIVE false
-
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
deleted file mode 100644
index a086d03..0000000
--- a/sys-devel/gcc/files/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From: "H.J. Lu" <hjl.tools@gmail.com>
-To: gcc-patches@gcc.gnu.org
-Subject: [2/3] GCC 7: i386: Use reference of struct ix86_frame to avoid copy
-Date: Sun, 14 Jan 2018 07:02:36 -0800
-
-When there is no need to make a copy of ix86_frame, we can use reference
-of struct ix86_frame to avoid copy.
-
-Tested on x86-64.
-
- Backport from mainline
- * config/i386/i386.c (ix86_can_use_return_insn_p): Use reference
- of struct ix86_frame.
- (ix86_initial_elimination_offset): Likewise.
- (ix86_expand_split_stack_prologue): Likewise.
----
- gcc/config/i386/i386.c | 9 +++------
- 1 file changed, 3 insertions(+), 6 deletions(-)
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 813337242d8..397ef7cac26 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -11843,8 +11843,6 @@ symbolic_reference_mentioned_p (rtx op)
- bool
- ix86_can_use_return_insn_p (void)
- {
-- struct ix86_frame frame;
--
- /* Don't use `ret' instruction in interrupt handler. */
- if (! reload_completed
- || frame_pointer_needed
-@@ -11857,7 +11855,7 @@ ix86_can_use_return_insn_p (void)
- return 0;
-
- ix86_compute_frame_layout ();
-- frame = cfun->machine->frame;
-+ struct ix86_frame &frame = cfun->machine->frame;
- return (frame.stack_pointer_offset == UNITS_PER_WORD
- && (frame.nregs + frame.nsseregs) == 0);
- }
-@@ -12344,7 +12342,7 @@ HOST_WIDE_INT
- ix86_initial_elimination_offset (int from, int to)
- {
- ix86_compute_frame_layout ();
-- struct ix86_frame frame = cfun->machine->frame;
-+ struct ix86_frame &frame = cfun->machine->frame;
-
- if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
- return frame.hard_frame_pointer_offset;
-@@ -14860,7 +14858,6 @@ static GTY(()) rtx split_stack_fn_large;
- void
- ix86_expand_split_stack_prologue (void)
- {
-- struct ix86_frame frame;
- HOST_WIDE_INT allocate;
- unsigned HOST_WIDE_INT args_size;
- rtx_code_label *label;
-@@ -14873,7 +14870,7 @@ ix86_expand_split_stack_prologue (void)
-
- ix86_finalize_stack_realign_flags ();
- ix86_compute_frame_layout ();
-- frame = cfun->machine->frame;
-+ struct ix86_frame &frame = cfun->machine->frame;
- allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET;
-
- /* This is the label we will branch to if we have enough stack
-
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
deleted file mode 100644
index 65bc45e..0000000
--- a/sys-devel/gcc/files/gcc-4.8.3-musl-fix-libc5-assumption.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- /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
-+++ gcc-4.8.3.new/boehm-gc/os_dep.c 2014-10-24 18:25:39.963379871 +0000
-@@ -41,7 +41,7 @@
- # else /* not 2 <= __GLIBC__ */
- /* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
- /* one. Check LINUX_VERSION_CODE to see which we should reference. */
--# include <asm/sigcontext.h>
-+//# include <asm/sigcontext.h>
- # endif /* 2 <= __GLIBC__ */
- # endif
- # endif
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
deleted file mode 100644
index 4a5df48..0000000
--- a/sys-devel/gcc/files/gcc-4.8.5-posix_memalign.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
-index 901001b..321fcd3 100644
---- a/gcc/config/i386/pmm_malloc.h
-+++ b/gcc/config/i386/pmm_malloc.h
-@@ -27,12 +27,13 @@
- #include <stdlib.h>
-
- /* We can't depend on <stdlib.h> since the prototype of posix_memalign
-- may not be visible. */
-+ may not be visible and we can't pollute the namespace either. */
- #ifndef __cplusplus
--extern int posix_memalign (void **, size_t, size_t);
-+extern int __gcc_posix_memalign (void **, size_t, size_t)
- #else
--extern "C" int posix_memalign (void **, size_t, size_t) throw ();
-+extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
- #endif
-+__asm__("posix_memalign");
-
- static __inline void *
- _mm_malloc (size_t size, size_t alignment)
-@@ -42,7 +43,7 @@ _mm_malloc (size_t size, size_t alignment)
- return malloc (size);
- if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
- alignment = sizeof (void *);
-- if (posix_memalign (&ptr, alignment, size) == 0)
-+ if (__gcc_posix_memalign (&ptr, alignment, size) == 0)
- return ptr;
- else
- return NULL;
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
deleted file mode 100644
index 2fc076a..0000000
--- a/sys-devel/gcc/files/gcc-4.9.3-musl-linker-path.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff -Naur gcc-4.9.3.orig/gcc/config/arm/linux-eabi.h gcc-4.9.3/gcc/config/arm/linux-eabi.h
---- gcc-4.9.3.orig/gcc/config/arm/linux-eabi.h 2014-01-02 22:23:26.000000000 +0000
-+++ gcc-4.9.3/gcc/config/arm/linux-eabi.h 2015-10-02 19:12:32.583700214 +0000
-@@ -68,8 +68,8 @@
- GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
-
- #undef GLIBC_DYNAMIC_LINKER
--#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
--#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
-+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-musl-arm.so.1"
-+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-musl-armhf.so.1"
- #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
-
- #define GLIBC_DYNAMIC_LINKER \
-diff -Naur gcc-4.9.3.orig/gcc/config/i386/linux64.h gcc-4.9.3/gcc/config/i386/linux64.h
---- gcc-4.9.3.orig/gcc/config/i386/linux64.h 2014-01-02 22:23:26.000000000 +0000
-+++ gcc-4.9.3/gcc/config/i386/linux64.h 2015-10-02 19:12:32.583700214 +0000
-@@ -27,6 +27,6 @@
- #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
- #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
-
--#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
--#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
-+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
-+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
- #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
-diff -Naur gcc-4.9.3.orig/gcc/config/mips/linux.h gcc-4.9.3/gcc/config/mips/linux.h
---- gcc-4.9.3.orig/gcc/config/mips/linux.h 2014-01-02 22:23:26.000000000 +0000
-+++ gcc-4.9.3/gcc/config/mips/linux.h 2015-10-02 19:12:32.584700214 +0000
-@@ -17,8 +17,12 @@
- along with GCC; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
--#define GLIBC_DYNAMIC_LINKER \
-- "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
-+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
-+#define GLIBC_DYNAMIC_LINKER_E "%{EB:;:el}"
-+#else
-+#define GLIBC_DYNAMIC_LINKER_E "%{EL:el}"
-+#endif
-+#define GLIBC_DYNAMIC_LINKER "/lib/ld-musl-mips" GLIBC_DYNAMIC_LINKER_E ".so.1"
-
- #undef UCLIBC_DYNAMIC_LINKER
- #define UCLIBC_DYNAMIC_LINKER \
-diff -Naur gcc-4.9.3.orig/gcc/config/rs6000/linux64.h gcc-4.9.3/gcc/config/rs6000/linux64.h
---- gcc-4.9.3.orig/gcc/config/rs6000/linux64.h 2015-03-09 23:19:19.000000000 +0000
-+++ gcc-4.9.3/gcc/config/rs6000/linux64.h 2015-10-02 19:12:32.584700214 +0000
-@@ -363,12 +363,8 @@
- #undef LINK_OS_DEFAULT_SPEC
- #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
-
--#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
--#ifdef LINUX64_DEFAULT_ABI_ELFv2
--#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/lib64/ld64.so.1;:/lib64/ld64.so.2}"
--#else
--#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/lib64/ld64.so.2;:/lib64/ld64.so.1}"
--#endif
-+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
-+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
- #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
- #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
- #if DEFAULT_LIBC == LIBC_UCLIBC
-diff -Naur gcc-4.9.3.orig/gcc/config/rs6000/sysv4.h gcc-4.9.3/gcc/config/rs6000/sysv4.h
---- gcc-4.9.3.orig/gcc/config/rs6000/sysv4.h 2014-07-24 17:25:19.000000000 +0000
-+++ gcc-4.9.3/gcc/config/rs6000/sysv4.h 2015-10-02 19:12:32.584700214 +0000
-@@ -761,7 +761,7 @@
-
- #define LINK_START_LINUX_SPEC ""
-
--#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
-+#define GLIBC_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
- #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
- #if DEFAULT_LIBC == LIBC_UCLIBC
- #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
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
deleted file mode 100644
index 363020d..0000000
--- a/sys-devel/gcc/files/gcc-4.9.3-musl-res_state.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur gcc-4.9.3.orig/libsanitizer/tsan/tsan_platform_linux.cc gcc-4.9.3/libsanitizer/tsan/tsan_platform_linux.cc
---- gcc-4.9.3.orig/libsanitizer/tsan/tsan_platform_linux.cc 2013-12-05 09:18:38.000000000 +0000
-+++ gcc-4.9.3/libsanitizer/tsan/tsan_platform_linux.cc 2015-10-02 19:19:15.765680892 +0000
-@@ -351,7 +351,7 @@
- // closes within glibc. The code is a pure hack.
- int ExtractResolvFDs(void *state, int *fds, int nfd) {
- int cnt = 0;
-- __res_state *statp = (__res_state*)state;
-+ res_state statp = (res_state)state;
- for (int i = 0; i < MAXNS && cnt < nfd; i++) {
- if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
- fds[cnt++] = statp->_u._ext.nssocks[i];
diff --git a/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch b/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch
deleted file mode 100644
index f1a7464..0000000
--- a/sys-devel/gcc/files/gcc-4.9.3-pr68470.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-diff --git a/gcc-4.9.3.orig/gcc/ipa-split.c b/gcc-4.9.3/gcc/ipa-split.c
-index 0d1495d..688c954 100644
---- a/gcc-4.9.3.orig/gcc/ipa-split.c
-+++ b/gcc-4.9.3/gcc/ipa-split.c
-@@ -1122,7 +1122,6 @@ split_function (struct split_point *split_point)
- edge e;
- edge_iterator ei;
- tree retval = NULL, real_retval = NULL;
-- bool split_part_return_p = false;
- gimple last_stmt = NULL;
- unsigned int i;
- tree arg, ddef;
-@@ -1162,12 +1161,28 @@ split_function (struct split_point *split_point)
- args_to_pass.safe_push (arg);
- }
-
-- /* See if the split function will return. */
-+ /* See if the split function or the main part will return. */
-+ bool main_part_return_p = false;
-+ bool split_part_return_p = false;
- FOR_EACH_EDGE (e, ei, return_bb->preds)
-- if (bitmap_bit_p (split_point->split_bbs, e->src->index))
-- break;
-- if (e)
-- split_part_return_p = true;
-+ {
-+ if (bitmap_bit_p (split_point->split_bbs, e->src->index))
-+ split_part_return_p = true;
-+ else
-+ main_part_return_p = true;
-+ }
-+ /* The main part also returns if we we split on a fallthru edge
-+ and the split part returns. */
-+ if (split_part_return_p)
-+ FOR_EACH_EDGE (e, ei, split_point->entry_bb->preds)
-+ {
-+ if (! bitmap_bit_p (split_point->split_bbs, e->src->index)
-+ && single_succ_p (e->src))
-+ {
-+ main_part_return_p = true;
-+ break;
-+ }
-+ }
-
- /* Add return block to what will become the split function.
- We do not return; no return block is needed. */
-@@ -1212,6 +1227,11 @@ split_function (struct split_point *split_point)
- else
- bitmap_set_bit (split_point->split_bbs, return_bb->index);
-
-+ /* If the main part doesn't return pretend the return block wasn't
-+ found for all of the following. */
-+ if (! main_part_return_p)
-+ return_bb = EXIT_BLOCK_PTR_FOR_FN (cfun);
-+
- /* If RETURN_BB has virtual operand PHIs, they must be removed and the
- virtual operand marked for renaming as we change the CFG in a way that
- tree-inline is not able to compensate for.
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
deleted file mode 100644
index bc52cec..0000000
--- a/sys-devel/gcc/files/gcc-4.9.3-secure-plt.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h
-index b463463..77edf2a 100644
---- a/gcc/config/rs6000/secureplt.h
-+++ b/gcc/config/rs6000/secureplt.h
-@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
- #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
-+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
-diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
-index 7b2f9bd..c77bf5c 100644
---- a/gcc/config/rs6000/sysv4.h
-+++ b/gcc/config/rs6000/sysv4.h
-@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
- #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
- #define CC1_SECURE_PLT_DEFAULT_SPEC ""
- #endif
-+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
-+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
-+#endif
-
- /* Pass -G xxx to the compiler. */
- #undef CC1_SPEC
-@@ -574,6 +577,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
- %{R*} \
- %(link_shlib) \
- %{!T*: %(link_start) } \
-+%{!static: %(link_secure_plt_default)} \
- %(link_target) \
- %(link_os)"
-
-@@ -889,6 +893,7 @@ ncrtn.o%s"
- { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
- { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
- { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
-+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
- { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
- { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
- { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
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
deleted file mode 100644
index 90eb4fa..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/aarch64.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -r 7c6d89fb1832 gcc/config/aarch64/aarch64-linux.h
---- a/gcc/config/aarch64/aarch64-linux.h Sun Jul 26 15:32:28 2015 -0400
-+++ b/gcc/config/aarch64/aarch64-linux.h Sun Jul 26 15:32:30 2015 -0400
-@@ -23,6 +23,8 @@
-
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}.so.1"
-
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
-+
- #define CPP_SPEC "%{pthread:-D_REENTRANT}"
-
- #define LINUX_TARGET_LINK_SPEC "%{h*} \
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
deleted file mode 100644
index 777e0f6..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/arm.diff
+++ /dev/null
@@ -1,46 +0,0 @@
-# HG changeset patch
-# Parent 92d83561106d17ca896328fcb4ec36cd4e2e9e16
-Support for arm-linux-musl.
-
-diff -r 92d83561106d gcc/config/arm/linux-eabi.h
---- a/gcc/config/arm/linux-eabi.h Sun Jul 26 15:32:23 2015 -0400
-+++ b/gcc/config/arm/linux-eabi.h Sun Jul 26 15:32:25 2015 -0400
-@@ -77,6 +77,23 @@
- %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
- %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
-
-+/* For ARM musl currently supports four dynamic linkers:
-+ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
-+ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
-+ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
-+ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
-+ musl does not support the legacy OABI mode.
-+ All the dynamic linkers live in /lib.
-+ We default to soft-float, EL. */
-+#undef MUSL_DYNAMIC_LINKER
-+#if TARGET_BIG_ENDIAN_DEFAULT
-+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
-+#else
-+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
-+#endif
-+#define MUSL_DYNAMIC_LINKER \
-+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
-+
- /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
- use the GNU/Linux version, not the generic BPABI version. */
- #undef LINK_SPEC
-diff -r 92d83561106d libitm/config/arm/hwcap.cc
---- a/libitm/config/arm/hwcap.cc Sun Jul 26 15:32:23 2015 -0400
-+++ b/libitm/config/arm/hwcap.cc Sun Jul 26 15:32:25 2015 -0400
-@@ -40,7 +40,11 @@
-
- #ifdef __linux__
- #include <unistd.h>
-+#ifdef __GLIBC__
- #include <sys/fcntl.h>
-+#else
-+#include <fcntl.h>
-+#endif
- #include <elf.h>
-
- static void __attribute__((constructor))
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
deleted file mode 100644
index dba0077..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-autoconf-musl.diff
+++ /dev/null
@@ -1,62 +0,0 @@
-diff -r 3baeaed6c155 gcc/configure
---- a/gcc/configure Sun Jul 26 15:32:15 2015 -0400
-+++ b/gcc/configure Sun Jul 26 15:32:17 2015 -0400
-@@ -27449,6 +27449,9 @@
- else
- gcc_cv_libc_provides_ssp=no
- case "$target" in
-+ *-*-musl*)
-+ # All versions of musl provide stack protector
-+ gcc_cv_libc_provides_ssp=yes;;
- *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
- # glibc 2.4 and later provides __stack_chk_fail and
- # either __stack_chk_guard, or TLS access to stack guard canary.
-@@ -27481,6 +27484,7 @@
- # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
- # simply assert that glibc does provide this, which is true for all
- # realistically usable GNU/Hurd configurations.
-+ # All supported versions of musl provide it as well
- gcc_cv_libc_provides_ssp=yes;;
- *-*-darwin* | *-*-freebsd*)
- ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
-@@ -27570,6 +27574,9 @@
- gcc_cv_target_dl_iterate_phdr=no
- fi
- ;;
-+ *-linux-musl*)
-+ gcc_cv_target_dl_iterate_phdr=yes
-+ ;;
- esac
-
- if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
-diff -r 3baeaed6c155 gcc/configure.ac
---- a/gcc/configure.ac Sun Jul 26 15:32:15 2015 -0400
-+++ b/gcc/configure.ac Sun Jul 26 15:32:17 2015 -0400
-@@ -5076,6 +5076,9 @@
- gcc_cv_libc_provides_ssp,
- [gcc_cv_libc_provides_ssp=no
- case "$target" in
-+ *-*-musl*)
-+ # All versions of musl provide stack protector
-+ gcc_cv_libc_provides_ssp=yes;;
- *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
- # glibc 2.4 and later provides __stack_chk_fail and
- # either __stack_chk_guard, or TLS access to stack guard canary.
-@@ -5102,6 +5105,7 @@
- # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
- # simply assert that glibc does provide this, which is true for all
- # realistically usable GNU/Hurd configurations.
-+ # All supported versions of musl provide it as well
- gcc_cv_libc_provides_ssp=yes;;
- *-*-darwin* | *-*-freebsd*)
- AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
-@@ -5168,6 +5172,9 @@
- gcc_cv_target_dl_iterate_phdr=no
- fi
- ;;
-+ *-linux-musl*)
-+ gcc_cv_target_dl_iterate_phdr=yes
-+ ;;
- esac
- GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
- if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
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
deleted file mode 100644
index e635573..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-config-musl.diff
+++ /dev/null
@@ -1,207 +0,0 @@
-# HG changeset patch
-# Parent fef9a6ed009159f294d8524a0bc1dda731990754
-Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
-
-diff -r fef9a6ed0091 gcc/config.gcc
---- a/gcc/config.gcc Sun Jul 26 15:32:09 2015 -0400
-+++ b/gcc/config.gcc Sun Jul 26 15:32:11 2015 -0400
-@@ -594,7 +594,7 @@
- esac
-
- # Common C libraries.
--tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
-+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
-
- # 32-bit x86 processors supported by --with-arch=. Each processor
- # MUST be separated by exactly one space.
-@@ -719,6 +719,9 @@
- *-*-*uclibc*)
- tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
- ;;
-+ *-*-*musl*)
-+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
-+ ;;
- *)
- tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
- ;;
-diff -r fef9a6ed0091 gcc/config/linux.h
---- a/gcc/config/linux.h Sun Jul 26 15:32:09 2015 -0400
-+++ b/gcc/config/linux.h Sun Jul 26 15:32:11 2015 -0400
-@@ -32,10 +32,12 @@
- #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
- #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
- #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
- #else
- #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
- #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
- #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
- #endif
-
- #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
-@@ -53,18 +55,21 @@
- uClibc or Bionic is the default C library and whether
- -muclibc or -mglibc or -mbionic has been passed to change the default. */
-
--#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
-- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
-+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
-+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
-
- #if DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
- #elif DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
- #elif DEFAULT_LIBC == LIBC_BIONIC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif /* DEFAULT_LIBC */
-@@ -84,21 +89,92 @@
-
- #define GNU_USER_DYNAMIC_LINKER \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
-- BIONIC_DYNAMIC_LINKER)
-+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
- #define GNU_USER_DYNAMIC_LINKER32 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
-- BIONIC_DYNAMIC_LINKER32)
-+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
- #define GNU_USER_DYNAMIC_LINKER64 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
-- BIONIC_DYNAMIC_LINKER64)
-+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
- #define GNU_USER_DYNAMIC_LINKERX32 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
-- BIONIC_DYNAMIC_LINKERX32)
-+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
-
- /* Whether we have Bionic libc runtime */
- #undef TARGET_HAS_BIONIC
- #define TARGET_HAS_BIONIC (OPTION_BIONIC)
-
-+/* musl avoids problematic includes by rearranging the include directories.
-+ * Unfortunately, this is mostly duplicated from cppdefault.c */
-+#if DEFAULT_LIBC == LIBC_MUSL
-+#define INCLUDE_DEFAULTS_MUSL_GPP \
-+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
-+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
-+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
-+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
-+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
-+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
-+
-+#ifdef LOCAL_INCLUDE_DIR
-+#define INCLUDE_DEFAULTS_MUSL_LOCAL \
-+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
-+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
-+#else
-+#define INCLUDE_DEFAULTS_MUSL_LOCAL
-+#endif
-+
-+#ifdef PREFIX_INCLUDE_DIR
-+#define INCLUDE_DEFAULTS_MUSL_PREFIX \
-+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
-+#else
-+#define INCLUDE_DEFAULTS_MUSL_PREFIX
-+#endif
-+
-+#ifdef CROSS_INCLUDE_DIR
-+#define INCLUDE_DEFAULTS_MUSL_CROSS \
-+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
-+#else
-+#define INCLUDE_DEFAULTS_MUSL_CROSS
-+#endif
-+
-+#ifdef TOOL_INCLUDE_DIR
-+#define INCLUDE_DEFAULTS_MUSL_TOOL \
-+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
-+#else
-+#define INCLUDE_DEFAULTS_MUSL_TOOL
-+#endif
-+
-+#ifdef NATIVE_SYSTEM_HEADER_DIR
-+#define INCLUDE_DEFAULTS_MUSL_NATIVE \
-+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
-+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
-+#else
-+#define INCLUDE_DEFAULTS_MUSL_NATIVE
-+#endif
-+
-+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
-+# undef INCLUDE_DEFAULTS_MUSL_LOCAL
-+# define INCLUDE_DEFAULTS_MUSL_LOCAL
-+# undef INCLUDE_DEFAULTS_MUSL_NATIVE
-+# define INCLUDE_DEFAULTS_MUSL_NATIVE
-+#else
-+# undef INCLUDE_DEFAULTS_MUSL_CROSS
-+# define INCLUDE_DEFAULTS_MUSL_CROSS
-+#endif
-+
-+#undef INCLUDE_DEFAULTS
-+#define INCLUDE_DEFAULTS \
-+ { \
-+ INCLUDE_DEFAULTS_MUSL_GPP \
-+ INCLUDE_DEFAULTS_MUSL_PREFIX \
-+ INCLUDE_DEFAULTS_MUSL_CROSS \
-+ INCLUDE_DEFAULTS_MUSL_TOOL \
-+ INCLUDE_DEFAULTS_MUSL_NATIVE \
-+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
-+ { 0, 0, 0, 0, 0, 0 } \
-+ }
-+#endif
-+
- #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
- /* This is a *uclinux* target. We don't define below macros to normal linux
- versions, because doing so would require *uclinux* targets to include
-diff -r fef9a6ed0091 gcc/config/linux.opt
---- a/gcc/config/linux.opt Sun Jul 26 15:32:09 2015 -0400
-+++ b/gcc/config/linux.opt Sun Jul 26 15:32:11 2015 -0400
-@@ -30,3 +30,7 @@
- muclibc
- Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
- Use uClibc C library
-+
-+mmusl
-+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
-+Use musl C library
-diff -r fef9a6ed0091 gcc/ginclude/stddef.h
---- a/gcc/ginclude/stddef.h Sun Jul 26 15:32:09 2015 -0400
-+++ b/gcc/ginclude/stddef.h Sun Jul 26 15:32:11 2015 -0400
-@@ -181,6 +181,7 @@
- #ifndef _GCC_SIZE_T
- #ifndef _SIZET_
- #ifndef __size_t
-+#ifndef __DEFINED_size_t /* musl */
- #define __size_t__ /* BeOS */
- #define __SIZE_T__ /* Cray Unicos/Mk */
- #define _SIZE_T
-@@ -197,6 +198,7 @@
- #define ___int_size_t_h
- #define _GCC_SIZE_T
- #define _SIZET_
-+#define __DEFINED_size_t /* musl */
- #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
- || defined(__FreeBSD_kernel__)
- /* __size_t is a typedef on FreeBSD 5, must not trash it. */
-@@ -214,6 +216,7 @@
- typedef long ssize_t;
- #endif /* __BEOS__ */
- #endif /* !(defined (__GNUG__) && defined (size_t)) */
-+#endif /* __DEFINED_size_t */
- #endif /* __size_t */
- #endif /* _SIZET_ */
- #endif /* _GCC_SIZE_T */
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
deleted file mode 100644
index 7846623..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gcc-ssp.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -r 581c4dd64733 gcc/gcc.c
---- a/gcc/gcc.c Sun Jul 26 15:32:17 2015 -0400
-+++ b/gcc/gcc.c Sun Jul 26 15:32:19 2015 -0400
-@@ -670,7 +670,7 @@
-
- #ifndef LINK_SSP_SPEC
- #ifdef TARGET_LIBC_PROVIDES_SSP
--#define LINK_SSP_SPEC "%{fstack-protector:}"
-+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared}"
- #else
- #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
- #endif
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
deleted file mode 100644
index 7b80fdf..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gomp-posix.diff
+++ /dev/null
@@ -1,16 +0,0 @@
-# HG changeset patch
-# Parent 47dcb1f7b3a9c1b5d6b9d56303e7603fbe5a51f9
-A fix for libgomp to correctly request a POSIX version for time support.
-
-diff -r 47dcb1f7b3a9 libgomp/config/posix/time.c
---- a/libgomp/config/posix/time.c Sun Jul 26 15:32:11 2015 -0400
-+++ b/libgomp/config/posix/time.c Sun Jul 26 15:32:13 2015 -0400
-@@ -28,6 +28,8 @@
- The following implementation uses the most simple POSIX routines.
- If present, POSIX 4 clocks should be used instead. */
-
-+#define _POSIX_C_SOURCE 199309L /* for clocks */
-+
- #include "libgomp.h"
- #include <unistd.h>
- #if TIME_WITH_SYS_TIME
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
deleted file mode 100644
index af74e50..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/gthread.diff
+++ /dev/null
@@ -1,16 +0,0 @@
-Do not use weak references on any targets for gthread. Necessary on musl, safe elsewhere.
-
-diff -r d2b373a6ad39 libgcc/gthr.h
---- a/libgcc/gthr.h Thu Jan 29 18:59:33 2015 -0500
-+++ b/libgcc/gthr.h Thu Jan 29 19:00:03 2015 -0500
-@@ -136,10 +136,8 @@
- /* The pe-coff weak support isn't fully compatible to ELF's weak.
- For static libraries it might would work, but as we need to deal
- with shared versions too, we disable it for mingw-targets. */
--#ifdef __MINGW32__
- #undef GTHREAD_USE_WEAK
- #define GTHREAD_USE_WEAK 0
--#endif
-
- #ifndef GTHREAD_USE_WEAK
- #define GTHREAD_USE_WEAK 1
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
deleted file mode 100644
index b8f8d0c..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/kill-fixincludes.diff
+++ /dev/null
@@ -1,17 +0,0 @@
-# HG changeset patch
-# Parent 9f2f4e02fced4d4810910db6cced26ed0d47c23f
-Get rid of ever-broken fixincludes on musl.
-
-diff -r 9f2f4e02fced fixincludes/mkfixinc.sh
---- a/fixincludes/mkfixinc.sh Sun Jul 26 15:32:19 2015 -0400
-+++ b/fixincludes/mkfixinc.sh Sun Jul 26 15:32:21 2015 -0400
-@@ -19,7 +19,8 @@
- powerpc-*-eabi* | \
- powerpc-*-rtems* | \
- powerpcle-*-eabisim* | \
-- powerpcle-*-eabi* )
-+ powerpcle-*-eabi* | \
-+ *-musl* )
- # IF there is no include fixing,
- # THEN create a no-op fixer and exit
- (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
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
deleted file mode 100644
index de7acff..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/libstdc++-generic.diff
+++ /dev/null
@@ -1,31 +0,0 @@
-# HG changeset patch
-# Parent 889b7d97216603795ba8c5f4da8e616bef8feb9d
-Use the generic implementation of libstdc++ primitives when we're on musl, not the glibc one.
-
-diff -r 889b7d972166 libstdc++-v3/configure.host
---- a/libstdc++-v3/configure.host Sun Jul 26 15:30:11 2015 -0400
-+++ b/libstdc++-v3/configure.host Sun Jul 26 15:32:09 2015 -0400
-@@ -266,6 +266,13 @@
- os_include_dir="os/bsd/freebsd"
- ;;
- gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
-+ # check for musl by target
-+ case "${host_os}" in
-+ *-musl*)
-+ os_include_dir="os/generic"
-+ ;;
-+ *)
-+
- if [ "$uclibc" = "yes" ]; then
- os_include_dir="os/uclibc"
- elif [ "$bionic" = "yes" ]; then
-@@ -274,6 +281,9 @@
- os_include_dir="os/gnu-linux"
- fi
- ;;
-+
-+ esac
-+ ;;
- hpux*)
- os_include_dir="os/hpux"
- ;;
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
deleted file mode 100644
index 9ddc092..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze-size_t.diff
+++ /dev/null
@@ -1,39 +0,0 @@
-From 478ee0c03a08e2ef9371fd88d516738936943e78 Mon Sep 17 00:00:00 2001
-From: David Holsgrove <david.holsgrove@xilinx.com>
-Date: Fri, 28 Sep 2012 16:32:03 +1000
-Subject: [PATCH 06/11] [Patch, microblaze]: Add SIZE_TYPE and PTRDIFF_TYPE to
- microblaze.h
-
-Fixes warnings like;
-
-warning: format '%zX' expects argument of type 'size_t',
-but argument 3 has type 'unsigned int' [-Wformat]
-
-Changelog
-
-2013-03-18 David Holsgrove <david.holsgrove@xilinx.com>
-
- * gcc/config/microblaze/microblaze.h: Define SIZE_TYPE
- and PTRDIFF_TYPE.
-
-Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
----
- gcc/config/microblaze/microblaze.h | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff -r 97f8346ce240 gcc/config/microblaze/microblaze.h
---- a/gcc/config/microblaze/microblaze.h Sun Jul 26 15:32:32 2015 -0400
-+++ b/gcc/config/microblaze/microblaze.h Sun Jul 26 15:32:34 2015 -0400
-@@ -218,6 +218,12 @@
- #undef PTRDIFF_TYPE
- #define PTRDIFF_TYPE "int"
-
-+#undef SIZE_TYPE
-+#define SIZE_TYPE "unsigned int"
-+
-+#undef PTRDIFF_TYPE
-+#define PTRDIFF_TYPE "int"
-+
- #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
- ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
- && (ALIGN) < BITS_PER_WORD \
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
deleted file mode 100644
index ac5a87f..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/microblaze.diff
+++ /dev/null
@@ -1,31 +0,0 @@
-# HG changeset patch
-# Parent d548cc2d1cfea3241205efc347caec8ad78c21d4
-Microblaze support (again).
-
-diff -r d548cc2d1cfe gcc/config/microblaze/linux.h
---- a/gcc/config/microblaze/linux.h Sun Jul 26 15:32:30 2015 -0400
-+++ b/gcc/config/microblaze/linux.h Sun Jul 26 15:32:32 2015 -0400
-@@ -28,7 +28,22 @@
- #undef TLS_NEEDS_GOT
- #define TLS_NEEDS_GOT 1
-
--#define DYNAMIC_LINKER "/lib/ld.so.1"
-+#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
-+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
-+#else
-+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
-+#endif
-+
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
-+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
-+
-+#if DEFAULT_LIBC == LIBC_MUSL
-+#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
-+#else
-+#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
-+#endif
-+
-+
- #undef SUBTARGET_EXTRA_SPECS
- #define SUBTARGET_EXTRA_SPECS \
- { "dynamic_linker", DYNAMIC_LINKER }
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
deleted file mode 100644
index 9ccc516..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/mips.diff
+++ /dev/null
@@ -1,18 +0,0 @@
-# HG changeset patch
-# Parent 270d6afd029dd396b69553e1d96f35d2ebdd2f99
-Support for mips-linux-musl.
-
-diff -r 270d6afd029d gcc/config/mips/linux.h
---- a/gcc/config/mips/linux.h Sun Jul 26 15:32:25 2015 -0400
-+++ b/gcc/config/mips/linux.h Sun Jul 26 15:32:26 2015 -0400
-@@ -23,3 +23,10 @@
- #undef UCLIBC_DYNAMIC_LINKER
- #define UCLIBC_DYNAMIC_LINKER \
- "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
-+
-+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
-+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
-+#else
-+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
-+#endif
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
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
deleted file mode 100644
index 92276e2..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/powerpc.diff
+++ /dev/null
@@ -1,108 +0,0 @@
-# HG changeset patch
-# Parent 3974ad9269f7e4c5605e0bb38db7418a69e6ee95
-Support for powerpc-linux-musl.
-
-diff -r 3974ad9269f7 gcc/config.gcc
---- a/gcc/config.gcc Sun Jul 26 15:32:26 2015 -0400
-+++ b/gcc/config.gcc Sun Jul 26 15:32:28 2015 -0400
-@@ -2344,6 +2344,10 @@
- powerpc*-*-linux*paired*)
- tm_file="${tm_file} rs6000/750cl.h" ;;
- esac
-+ case ${target} in
-+ *-linux*-musl*)
-+ enable_secureplt=yes ;;
-+ esac
- if test x${enable_secureplt} = xyes; then
- tm_file="rs6000/secureplt.h ${tm_file}"
- fi
-diff -r 3974ad9269f7 gcc/config/rs6000/linux64.h
---- a/gcc/config/rs6000/linux64.h Sun Jul 26 15:32:26 2015 -0400
-+++ b/gcc/config/rs6000/linux64.h Sun Jul 26 15:32:28 2015 -0400
-@@ -371,17 +371,21 @@
- #endif
- #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
- #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
-+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
-+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
- #if DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
- #elif DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif
- #define GNU_USER_DYNAMIC_LINKER32 \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
- #define GNU_USER_DYNAMIC_LINKER64 \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
-
- #undef DEFAULT_ASM_ENDIAN
- #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
-diff -r 3974ad9269f7 gcc/config/rs6000/secureplt.h
---- a/gcc/config/rs6000/secureplt.h Sun Jul 26 15:32:26 2015 -0400
-+++ b/gcc/config/rs6000/secureplt.h Sun Jul 26 15:32:28 2015 -0400
-@@ -18,3 +18,4 @@
- <http://www.gnu.org/licenses/>. */
-
- #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
-+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
-diff -r 3974ad9269f7 gcc/config/rs6000/sysv4.h
---- a/gcc/config/rs6000/sysv4.h Sun Jul 26 15:32:26 2015 -0400
-+++ b/gcc/config/rs6000/sysv4.h Sun Jul 26 15:32:28 2015 -0400
-@@ -537,6 +537,9 @@
- #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
- #define CC1_SECURE_PLT_DEFAULT_SPEC ""
- #endif
-+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
-+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
-+#endif
-
- /* Pass -G xxx to the compiler. */
- #define CC1_SPEC "%{G*} %(cc1_cpu)" \
-@@ -585,7 +588,8 @@
-
- /* Override the default target of the linker. */
- #define LINK_TARGET_SPEC \
-- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
-+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
-+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
-
- /* Any specific OS flags. */
- #define LINK_OS_SPEC "\
-@@ -763,15 +767,18 @@
-
- #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
- #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
- #if DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
- #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif
- #define GNU_USER_DYNAMIC_LINKER \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
-
- #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
- %{rdynamic:-export-dynamic} \
-@@ -894,6 +901,7 @@
- { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
- { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
- { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
-+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
- { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
- { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
- { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
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
deleted file mode 100644
index f7be443..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/sh.diff
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -r c5b39ce7672b gcc/config/sh/linux.h
---- a/gcc/config/sh/linux.h Fri Sep 28 16:32:03 2012 +1000
-+++ b/gcc/config/sh/linux.h Sun Jul 26 15:32:36 2015 -0400
-@@ -43,7 +43,14 @@
-
- #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
-+#if TARGET_BIG_ENDIAN_DEFAULT /* BE */
-+#define MUSL_DYNAMIC_LINKER_E "eb"
-+#else
-+#define MUSL_DYNAMIC_LINKER_E
-+#endif
-+
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
-
- #undef SUBTARGET_LINK_EMUL_SUFFIX
- #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
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
deleted file mode 100644
index 2add290..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/unwind-dliterate.diff
+++ /dev/null
@@ -1,43 +0,0 @@
-diff -r ddc4b4034e51 libgcc/unwind-dw2-fde-dip.c
---- a/libgcc/unwind-dw2-fde-dip.c Sun Jul 26 15:32:13 2015 -0400
-+++ b/libgcc/unwind-dw2-fde-dip.c Sun Jul 26 15:32:15 2015 -0400
-@@ -46,33 +46,13 @@
- #include "unwind-compat.h"
- #include "gthr.h"
-
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
-- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
-- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
-+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
- # define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
-- && defined(__BIONIC__)
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
-- && defined(__FreeBSD__) && __FreeBSD__ >= 7
--# define ElfW __ElfN
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
-- && defined(__OpenBSD__)
--# define ElfW(type) Elf_##type
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
-- && defined(TARGET_DL_ITERATE_PHDR) \
-- && defined(__sun__) && defined(__svr4__)
--# define USE_PT_GNU_EH_FRAME
-+# ifdef __OpenBSD__
-+# define ElfW(type) Elf_##type
-+# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
-+# define ElfW __ElfN
-+# endif
- #endif
-
- #if defined(USE_PT_GNU_EH_FRAME)
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
deleted file mode 100644
index 16df34a..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/vis_hide.diff
+++ /dev/null
@@ -1,15 +0,0 @@
-Fix hidden visibility of libgcc.a symbols when building gcc stage 2 with
- --disable-shared, as per musl ml:
-http://www.openwall.com/lists/musl/2014/01/12/4
-
-diff -Naur gcc-4.7.3.orig/libgcc/Makefile.in gcc-4.7.3/libgcc/Makefile.in
---- gcc-4.7.3.orig/libgcc/Makefile.in 2012-12-04 14:09:59.000000000 -0500
-+++ gcc-4.7.3/libgcc/Makefile.in 2014-02-27 08:33:31.537611370 -0500
-@@ -388,7 +388,7 @@
- else
- # Not enable_shared.
- iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
--vis_hide =
-+vis_hide = @vis_hide@
- gen-hide-list = echo > \$@
- endif
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
deleted file mode 100644
index f62f27e..0000000
--- a/sys-devel/gcc/files/musl-gcc-patches-4.9.3/x86.diff
+++ /dev/null
@@ -1,55 +0,0 @@
-# HG changeset patch
-# Parent ab9383ed51ae0c261e0c860fc6b953eb57976eef
-Support for i386-linux-musl and x86_64-linux-musl.
-
-diff -r ab9383ed51ae gcc/config/i386/linux.h
---- a/gcc/config/i386/linux.h Sun Jul 26 15:32:21 2015 -0400
-+++ b/gcc/config/i386/linux.h Sun Jul 26 15:32:23 2015 -0400
-@@ -21,3 +21,4 @@
-
- #define GNU_USER_LINK_EMULATION "elf_i386"
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
-diff -r ab9383ed51ae gcc/config/i386/linux64.h
---- a/gcc/config/i386/linux64.h Sun Jul 26 15:32:21 2015 -0400
-+++ b/gcc/config/i386/linux64.h Sun Jul 26 15:32:23 2015 -0400
-@@ -30,3 +30,7 @@
- #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
- #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
- #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
-+
-+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
-+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
-+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
-diff -r ab9383ed51ae libitm/config/linux/x86/tls.h
---- a/libitm/config/linux/x86/tls.h Sun Jul 26 15:32:21 2015 -0400
-+++ b/libitm/config/linux/x86/tls.h Sun Jul 26 15:32:23 2015 -0400
-@@ -25,16 +25,19 @@
- #ifndef LIBITM_X86_TLS_H
- #define LIBITM_X86_TLS_H 1
-
--#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
-+#if defined(__GLIBC_PREREQ)
-+#if __GLIBC_PREREQ(2, 10)
- /* Use slots in the TCB head rather than __thread lookups.
- GLIBC has reserved words 10 through 13 for TM. */
- #define HAVE_ARCH_GTM_THREAD 1
- #define HAVE_ARCH_GTM_THREAD_DISP 1
- #endif
-+#endif
-
- #include "config/generic/tls.h"
-
--#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
-+#if defined(__GLIBC_PREREQ)
-+#if __GLIBC_PREREQ(2, 10)
- namespace GTM HIDDEN {
-
- #ifdef __x86_64__
-@@ -101,5 +104,6 @@
-
- } // namespace GTM
- #endif /* >= GLIBC 2.10 */
-+#endif
-
- #endif // LIBITM_X86_TLS_H
diff --git a/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch b/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch
deleted file mode 100644
index c0267fa..0000000
--- a/sys-devel/gcc/files/spectre-0001-mindirect-branch.patch
+++ /dev/null
@@ -1,1084 +0,0 @@
-From c6b72be421ded17e0c156070ba6e90aa6c335ed6 Mon Sep 17 00:00:00 2001
-From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
-Date: Tue, 16 Jan 2018 10:59:42 +0000
-Subject: [PATCH] x86: Add -mindirect-branch=
-
-Add -mindirect-branch= option to convert indirect call and jump to call
-and return thunks. The default is 'keep', which keeps indirect call and
-jump unmodified. 'thunk' converts indirect call and jump to call and
-return thunk. 'thunk-inline' converts indirect call and jump to inlined
-call and return thunk. 'thunk-extern' converts indirect call and jump to
-external call and return thunk provided in a separate object file. You
-can control this behavior for a specific function by using the function
-attribute indirect_branch.
-
-2 kinds of thunks are geneated. Memory thunk where the function address
-is at the top of the stack:
-
-__x86_indirect_thunk:
- call L2
-L1:
- pause
- lfence
- jmp L1
-L2:
- lea 8(%rsp), %rsp|lea 4(%esp), %esp
- ret
-
-Indirect jmp via memory, "jmp mem", is converted to
-
- push memory
- jmp __x86_indirect_thunk
-
-Indirect call via memory, "call mem", is converted to
-
- jmp L2
-L1:
- push [mem]
- jmp __x86_indirect_thunk
-L2:
- call L1
-
-Register thunk where the function address is in a register, reg:
-
-__x86_indirect_thunk_reg:
- call L2
-L1:
- pause
- lfence
- jmp L1
-L2:
- movq %reg, (%rsp)|movl %reg, (%esp)
- ret
-
-where reg is one of (r|e)ax, (r|e)dx, (r|e)cx, (r|e)bx, (r|e)si, (r|e)di,
-(r|e)bp, r8, r9, r10, r11, r12, r13, r14 and r15.
-
-Indirect jmp via register, "jmp reg", is converted to
-
- jmp __x86_indirect_thunk_reg
-
-Indirect call via register, "call reg", is converted to
-
- call __x86_indirect_thunk_reg
-
-gcc/
-
- Backport from mainline
- * config/i386/i386-opts.h (indirect_branch): New.
- * config/i386/i386-protos.h (ix86_output_indirect_jmp): Likewise.
- * config/i386/i386.c (ix86_using_red_zone): Disallow red-zone
- with local indirect jump when converting indirect call and jump.
- (ix86_set_indirect_branch_type): New.
- (ix86_set_current_function): Call ix86_set_indirect_branch_type.
- (indirectlabelno): New.
- (indirect_thunk_needed): Likewise.
- (indirect_thunk_bnd_needed): Likewise.
- (indirect_thunks_used): Likewise.
- (indirect_thunks_bnd_used): Likewise.
- (INDIRECT_LABEL): Likewise.
- (indirect_thunk_name): Likewise.
- (output_indirect_thunk): Likewise.
- (output_indirect_thunk_function): Likewise.
- (ix86_output_indirect_branch_via_reg): Likewise.
- (ix86_output_indirect_branch_via_push): Likewise.
- (ix86_output_indirect_branch): Likewise.
- (ix86_output_indirect_jmp): Likewise.
- (ix86_code_end): Call output_indirect_thunk_function if needed.
- (ix86_output_call_insn): Call ix86_output_indirect_branch if
- needed.
- (ix86_handle_fndecl_attribute): Handle indirect_branch.
- (ix86_attribute_table): Add indirect_branch.
- * config/i386/i386.h (machine_function): Add indirect_branch_type
- and has_local_indirect_jump.
- * config/i386/i386.md (indirect_jump): Set has_local_indirect_jump
- to true.
- (tablejump): Likewise.
- (*indirect_jump): Use ix86_output_indirect_jmp.
- (*tablejump_1): Likewise.
- (simple_return_indirect_internal): Likewise.
- * config/i386/i386.opt (mindirect-branch=): New option.
- (indirect_branch): New.
- (keep): Likewise.
- (thunk): Likewise.
- (thunk-inline): Likewise.
- (thunk-extern): Likewise.
- * doc/extend.texi: Document indirect_branch function attribute.
- * doc/invoke.texi: Document -mindirect-branch= option.
-
-git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256732 138bc75d-0d04-0410-961f-82ee72b054a4
----
- gcc/config/i386/i386-opts.h | 13 +
- gcc/config/i386/i386-protos.h | 1 +
- gcc/config/i386/i386.c | 648 ++++++++++++++++++++-
- gcc/config/i386/i386.h | 7 +
- gcc/config/i386/i386.md | 26 +-
- gcc/config/i386/i386.opt | 20 +
- gcc/doc/extend.texi | 10 +
- gcc/doc/invoke.texi | 14 +-
- 43 files changed, 1575 insertions(+), 19 deletions(-)
-
-diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
-index 542cd0f..efcdc3b 100644
---- a/gcc/config/i386/i386-opts.h
-+++ b/gcc/config/i386/i386-opts.h
-@@ -99,4 +99,17 @@ enum stack_protector_guard {
- SSP_GLOBAL /* global canary */
- };
-
-+/* This is used to mitigate variant #2 of the speculative execution
-+ vulnerabilities on x86 processors identified by CVE-2017-5715, aka
-+ Spectre. They convert indirect branches and function returns to
-+ call and return thunks to avoid speculative execution via indirect
-+ call, jmp and ret. */
-+enum indirect_branch {
-+ indirect_branch_unset = 0,
-+ indirect_branch_keep,
-+ indirect_branch_thunk,
-+ indirect_branch_thunk_inline,
-+ indirect_branch_thunk_extern
-+};
-+
- #endif
-diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
-index d2cccf1..bcdd987 100644
---- a/gcc/config/i386/i386-protos.h
-+++ b/gcc/config/i386/i386-protos.h
-@@ -313,6 +313,7 @@ extern enum attr_cpu ix86_schedule;
- #endif
-
- extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
-+extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
- extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
- enum machine_mode mode);
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 1786640..7e779c1 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -4212,12 +4212,23 @@ make_pass_stv (gcc::context *ctxt)
- return new pass_stv (ctxt);
- }
-
--/* Return true if a red-zone is in use. */
-+/* Return true if a red-zone is in use. We can't use red-zone when
-+ there are local indirect jumps, like "indirect_jump" or "tablejump",
-+ which jumps to another place in the function, since "call" in the
-+ indirect thunk pushes the return address onto stack, destroying
-+ red-zone.
-+
-+ TODO: If we can reserve the first 2 WORDs, for PUSH and, another
-+ for CALL, in red-zone, we can allow local indirect jumps with
-+ indirect thunk. */
-
- bool
- ix86_using_red_zone (void)
- {
-- return TARGET_RED_ZONE && !TARGET_64BIT_MS_ABI;
-+ return (TARGET_RED_ZONE
-+ && !TARGET_64BIT_MS_ABI
-+ && (!cfun->machine->has_local_indirect_jump
-+ || cfun->machine->indirect_branch_type == indirect_branch_keep));
- }
-
- /* Return a string that documents the current -m options. The caller is
-@@ -7148,6 +7159,37 @@ ix86_set_func_type (tree fndecl)
- }
- }
-
-+/* Set the indirect_branch_type field from the function FNDECL. */
-+
-+static void
-+ix86_set_indirect_branch_type (tree fndecl)
-+{
-+ if (cfun->machine->indirect_branch_type == indirect_branch_unset)
-+ {
-+ tree attr = lookup_attribute ("indirect_branch",
-+ DECL_ATTRIBUTES (fndecl));
-+ if (attr != NULL)
-+ {
-+ tree args = TREE_VALUE (attr);
-+ if (args == NULL)
-+ gcc_unreachable ();
-+ tree cst = TREE_VALUE (args);
-+ if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
-+ cfun->machine->indirect_branch_type = indirect_branch_keep;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
-+ cfun->machine->indirect_branch_type = indirect_branch_thunk;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
-+ cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
-+ cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
-+ else
-+ gcc_unreachable ();
-+ }
-+ else
-+ cfun->machine->indirect_branch_type = ix86_indirect_branch;
-+ }
-+}
-+
- /* Establish appropriate back-end context for processing the function
- FNDECL. The argument might be NULL to indicate processing at top
- level, outside of any function scope. */
-@@ -7163,7 +7205,10 @@ ix86_set_current_function (tree fndecl)
- one is extern inline and one isn't. Call ix86_set_func_type
- to set the func_type field. */
- if (fndecl != NULL_TREE)
-- ix86_set_func_type (fndecl);
-+ {
-+ ix86_set_func_type (fndecl);
-+ ix86_set_indirect_branch_type (fndecl);
-+ }
- return;
- }
-
-@@ -7183,6 +7228,7 @@ ix86_set_current_function (tree fndecl)
- }
-
- ix86_set_func_type (fndecl);
-+ ix86_set_indirect_branch_type (fndecl);
-
- tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
- if (new_tree == NULL_TREE)
-@@ -11930,6 +11976,220 @@ ix86_setup_frame_addresses (void)
- # endif
- #endif
-
-+/* Label count for call and return thunks. It is used to make unique
-+ labels in call and return thunks. */
-+static int indirectlabelno;
-+
-+/* True if call and return thunk functions are needed. */
-+static bool indirect_thunk_needed = false;
-+/* True if call and return thunk functions with the BND prefix are
-+ needed. */
-+static bool indirect_thunk_bnd_needed = false;
-+
-+/* Bit masks of integer registers, which contain branch target, used
-+ by call and return thunks functions. */
-+static int indirect_thunks_used;
-+/* Bit masks of integer registers, which contain branch target, used
-+ by call and return thunks functions with the BND prefix. */
-+static int indirect_thunks_bnd_used;
-+
-+#ifndef INDIRECT_LABEL
-+# define INDIRECT_LABEL "LIND"
-+#endif
-+
-+/* Fills in the label name that should be used for the indirect thunk. */
-+
-+static void
-+indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
-+{
-+ if (USE_HIDDEN_LINKONCE)
-+ {
-+ const char *bnd = need_bnd_p ? "_bnd" : "";
-+ if (regno >= 0)
-+ {
-+ const char *reg_prefix;
-+ if (LEGACY_INT_REGNO_P (regno))
-+ reg_prefix = TARGET_64BIT ? "r" : "e";
-+ else
-+ reg_prefix = "";
-+ sprintf (name, "__x86_indirect_thunk%s_%s%s",
-+ bnd, reg_prefix, reg_names[regno]);
-+ }
-+ else
-+ sprintf (name, "__x86_indirect_thunk%s", bnd);
-+ }
-+ else
-+ {
-+ if (regno >= 0)
-+ {
-+ if (need_bnd_p)
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno);
-+ else
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LITR", regno);
-+ }
-+ else
-+ {
-+ if (need_bnd_p)
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
-+ else
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
-+ }
-+ }
-+}
-+
-+/* Output a call and return thunk for indirect branch. If BND_P is
-+ true, the BND prefix is needed. If REGNO != -1, the function
-+ address is in REGNO and the call and return thunk looks like:
-+
-+ call L2
-+ L1:
-+ pause
-+ jmp L1
-+ L2:
-+ mov %REG, (%sp)
-+ ret
-+
-+ Otherwise, the function address is on the top of stack and the
-+ call and return thunk looks like:
-+
-+ call L2
-+ L1:
-+ pause
-+ jmp L1
-+ L2:
-+ lea WORD_SIZE(%sp), %sp
-+ ret
-+ */
-+
-+static void
-+output_indirect_thunk (bool need_bnd_p, int regno)
-+{
-+ char indirectlabel1[32];
-+ char indirectlabel2[32];
-+
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1, INDIRECT_LABEL,
-+ indirectlabelno++);
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2, INDIRECT_LABEL,
-+ indirectlabelno++);
-+
-+ /* Call */
-+ if (need_bnd_p)
-+ fputs ("\tbnd call\t", asm_out_file);
-+ else
-+ fputs ("\tcall\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel2);
-+ fputc ('\n', asm_out_file);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
-+
-+ /* Pause + lfence. */
-+ fprintf (asm_out_file, "\tpause\n\tlfence\n");
-+
-+ /* Jump. */
-+ fputs ("\tjmp\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel1);
-+ fputc ('\n', asm_out_file);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
-+
-+ if (regno >= 0)
-+ {
-+ /* MOV. */
-+ rtx xops[2];
-+ xops[0] = gen_rtx_MEM (word_mode, stack_pointer_rtx);
-+ xops[1] = gen_rtx_REG (word_mode, regno);
-+ output_asm_insn ("mov\t{%1, %0|%0, %1}", xops);
-+ }
-+ else
-+ {
-+ /* LEA. */
-+ rtx xops[2];
-+ xops[0] = stack_pointer_rtx;
-+ xops[1] = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
-+ output_asm_insn ("lea\t{%E1, %0|%0, %E1}", xops);
-+ }
-+
-+ if (need_bnd_p)
-+ fputs ("\tbnd ret\n", asm_out_file);
-+ else
-+ fputs ("\tret\n", asm_out_file);
-+}
-+
-+/* Output a funtion with a call and return thunk for indirect branch.
-+ If BND_P is true, the BND prefix is needed. If REGNO != -1, the
-+ function address is in REGNO. Otherwise, the function address is
-+ on the top of stack. */
-+
-+static void
-+output_indirect_thunk_function (bool need_bnd_p, int regno)
-+{
-+ char name[32];
-+ tree decl;
-+
-+ /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
-+ indirect_thunk_name (name, regno, need_bnd_p);
-+ decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
-+ get_identifier (name),
-+ build_function_type_list (void_type_node, NULL_TREE));
-+ DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL,
-+ NULL_TREE, void_type_node);
-+ TREE_PUBLIC (decl) = 1;
-+ TREE_STATIC (decl) = 1;
-+ DECL_IGNORED_P (decl) = 1;
-+
-+#if TARGET_MACHO
-+ if (TARGET_MACHO)
-+ {
-+ switch_to_section (darwin_sections[picbase_thunk_section]);
-+ fputs ("\t.weak_definition\t", asm_out_file);
-+ assemble_name (asm_out_file, name);
-+ fputs ("\n\t.private_extern\t", asm_out_file);
-+ assemble_name (asm_out_file, name);
-+ putc ('\n', asm_out_file);
-+ ASM_OUTPUT_LABEL (asm_out_file, name);
-+ DECL_WEAK (decl) = 1;
-+ }
-+ else
-+#endif
-+ if (USE_HIDDEN_LINKONCE)
-+ {
-+ cgraph_node::create (decl)->set_comdat_group (DECL_ASSEMBLER_NAME (decl));
-+
-+ targetm.asm_out.unique_section (decl, 0);
-+ switch_to_section (get_named_section (decl, NULL, 0));
-+
-+ targetm.asm_out.globalize_label (asm_out_file, name);
-+ fputs ("\t.hidden\t", asm_out_file);
-+ assemble_name (asm_out_file, name);
-+ putc ('\n', asm_out_file);
-+ ASM_DECLARE_FUNCTION_NAME (asm_out_file, name, decl);
-+ }
-+ else
-+ {
-+ switch_to_section (text_section);
-+ ASM_OUTPUT_LABEL (asm_out_file, name);
-+ }
-+
-+ DECL_INITIAL (decl) = make_node (BLOCK);
-+ current_function_decl = decl;
-+ allocate_struct_function (decl, false);
-+ init_function_start (decl);
-+ /* We're about to hide the function body from callees of final_* by
-+ emitting it directly; tell them we're a thunk, if they care. */
-+ cfun->is_thunk = true;
-+ first_function_block_is_cold = false;
-+ /* Make sure unwind info is emitted for the thunk if needed. */
-+ final_start_function (emit_barrier (), asm_out_file, 1);
-+
-+ output_indirect_thunk (need_bnd_p, regno);
-+
-+ final_end_function ();
-+ init_insn_lengths ();
-+ free_after_compilation (cfun);
-+ set_cfun (NULL);
-+ current_function_decl = NULL;
-+}
-+
- static int pic_labels_used;
-
- /* Fills in the label name that should be used for a pc thunk for
-@@ -11956,11 +12216,32 @@ ix86_code_end (void)
- rtx xops[2];
- int regno;
-
-+ if (indirect_thunk_needed)
-+ output_indirect_thunk_function (false, -1);
-+ if (indirect_thunk_bnd_needed)
-+ output_indirect_thunk_function (true, -1);
-+
-+ for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
-+ {
-+ int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
-+ if ((indirect_thunks_used & (1 << i)))
-+ output_indirect_thunk_function (false, regno);
-+
-+ if ((indirect_thunks_bnd_used & (1 << i)))
-+ output_indirect_thunk_function (true, regno);
-+ }
-+
- for (regno = AX_REG; regno <= SP_REG; regno++)
- {
- char name[32];
- tree decl;
-
-+ if ((indirect_thunks_used & (1 << regno)))
-+ output_indirect_thunk_function (false, regno);
-+
-+ if ((indirect_thunks_bnd_used & (1 << regno)))
-+ output_indirect_thunk_function (true, regno);
-+
- if (!(pic_labels_used & (1 << regno)))
- continue;
-
-@@ -28461,12 +28742,292 @@ ix86_nopic_noplt_attribute_p (rtx call_op)
- return false;
- }
-
-+/* Output indirect branch via a call and return thunk. CALL_OP is a
-+ register which contains the branch target. XASM is the assembly
-+ template for CALL_OP. Branch is a tail call if SIBCALL_P is true.
-+ A normal call is converted to:
-+
-+ call __x86_indirect_thunk_reg
-+
-+ and a tail call is converted to:
-+
-+ jmp __x86_indirect_thunk_reg
-+ */
-+
-+static void
-+ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
-+{
-+ char thunk_name_buf[32];
-+ char *thunk_name;
-+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
-+ int regno = REGNO (call_op);
-+
-+ if (cfun->machine->indirect_branch_type
-+ != indirect_branch_thunk_inline)
-+ {
-+ if (cfun->machine->indirect_branch_type == indirect_branch_thunk)
-+ {
-+ int i = regno;
-+ if (i >= FIRST_REX_INT_REG)
-+ i -= (FIRST_REX_INT_REG - LAST_INT_REG - 1);
-+ if (need_bnd_p)
-+ indirect_thunks_bnd_used |= 1 << i;
-+ else
-+ indirect_thunks_used |= 1 << i;
-+ }
-+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
-+ thunk_name = thunk_name_buf;
-+ }
-+ else
-+ thunk_name = NULL;
-+
-+ if (sibcall_p)
-+ {
-+ if (thunk_name != NULL)
-+ {
-+ if (need_bnd_p)
-+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
-+ else
-+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
-+ }
-+ else
-+ output_indirect_thunk (need_bnd_p, regno);
-+ }
-+ else
-+ {
-+ if (thunk_name != NULL)
-+ {
-+ if (need_bnd_p)
-+ fprintf (asm_out_file, "\tbnd call\t%s\n", thunk_name);
-+ else
-+ fprintf (asm_out_file, "\tcall\t%s\n", thunk_name);
-+ return;
-+ }
-+
-+ char indirectlabel1[32];
-+ char indirectlabel2[32];
-+
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1,
-+ INDIRECT_LABEL,
-+ indirectlabelno++);
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2,
-+ INDIRECT_LABEL,
-+ indirectlabelno++);
-+
-+ /* Jump. */
-+ if (need_bnd_p)
-+ fputs ("\tbnd jmp\t", asm_out_file);
-+ else
-+ fputs ("\tjmp\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel2);
-+ fputc ('\n', asm_out_file);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
-+
-+ if (thunk_name != NULL)
-+ {
-+ if (need_bnd_p)
-+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
-+ else
-+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
-+ }
-+ else
-+ output_indirect_thunk (need_bnd_p, regno);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
-+
-+ /* Call. */
-+ if (need_bnd_p)
-+ fputs ("\tbnd call\t", asm_out_file);
-+ else
-+ fputs ("\tcall\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel1);
-+ fputc ('\n', asm_out_file);
-+ }
-+}
-+
-+/* Output indirect branch via a call and return thunk. CALL_OP is
-+ the branch target. XASM is the assembly template for CALL_OP.
-+ Branch is a tail call if SIBCALL_P is true. A normal call is
-+ converted to:
-+
-+ jmp L2
-+ L1:
-+ push CALL_OP
-+ jmp __x86_indirect_thunk
-+ L2:
-+ call L1
-+
-+ and a tail call is converted to:
-+
-+ push CALL_OP
-+ jmp __x86_indirect_thunk
-+ */
-+
-+static void
-+ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm,
-+ bool sibcall_p)
-+{
-+ char thunk_name_buf[32];
-+ char *thunk_name;
-+ char push_buf[64];
-+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
-+ int regno = -1;
-+
-+ if (cfun->machine->indirect_branch_type
-+ != indirect_branch_thunk_inline)
-+ {
-+ if (cfun->machine->indirect_branch_type == indirect_branch_thunk)
-+ {
-+ if (need_bnd_p)
-+ indirect_thunk_bnd_needed = true;
-+ else
-+ indirect_thunk_needed = true;
-+ }
-+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
-+ thunk_name = thunk_name_buf;
-+ }
-+ else
-+ thunk_name = NULL;
-+
-+ snprintf (push_buf, sizeof (push_buf), "push{%c}\t%s",
-+ TARGET_64BIT ? 'q' : 'l', xasm);
-+
-+ if (sibcall_p)
-+ {
-+ output_asm_insn (push_buf, &call_op);
-+ if (thunk_name != NULL)
-+ {
-+ if (need_bnd_p)
-+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
-+ else
-+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
-+ }
-+ else
-+ output_indirect_thunk (need_bnd_p, regno);
-+ }
-+ else
-+ {
-+ char indirectlabel1[32];
-+ char indirectlabel2[32];
-+
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel1,
-+ INDIRECT_LABEL,
-+ indirectlabelno++);
-+ ASM_GENERATE_INTERNAL_LABEL (indirectlabel2,
-+ INDIRECT_LABEL,
-+ indirectlabelno++);
-+
-+ /* Jump. */
-+ if (need_bnd_p)
-+ fputs ("\tbnd jmp\t", asm_out_file);
-+ else
-+ fputs ("\tjmp\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel2);
-+ fputc ('\n', asm_out_file);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1);
-+
-+ /* An external function may be called via GOT, instead of PLT. */
-+ if (MEM_P (call_op))
-+ {
-+ struct ix86_address parts;
-+ rtx addr = XEXP (call_op, 0);
-+ if (ix86_decompose_address (addr, &parts)
-+ && parts.base == stack_pointer_rtx)
-+ {
-+ /* Since call will adjust stack by -UNITS_PER_WORD,
-+ we must convert "disp(stack, index, scale)" to
-+ "disp+UNITS_PER_WORD(stack, index, scale)". */
-+ if (parts.index)
-+ {
-+ addr = gen_rtx_MULT (Pmode, parts.index,
-+ GEN_INT (parts.scale));
-+ addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-+ addr);
-+ }
-+ else
-+ addr = stack_pointer_rtx;
-+
-+ rtx disp;
-+ if (parts.disp != NULL_RTX)
-+ disp = plus_constant (Pmode, parts.disp,
-+ UNITS_PER_WORD);
-+ else
-+ disp = GEN_INT (UNITS_PER_WORD);
-+
-+ addr = gen_rtx_PLUS (Pmode, addr, disp);
-+ call_op = gen_rtx_MEM (GET_MODE (call_op), addr);
-+ }
-+ }
-+
-+ output_asm_insn (push_buf, &call_op);
-+
-+ if (thunk_name != NULL)
-+ {
-+ if (need_bnd_p)
-+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
-+ else
-+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
-+ }
-+ else
-+ output_indirect_thunk (need_bnd_p, regno);
-+
-+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2);
-+
-+ /* Call. */
-+ if (need_bnd_p)
-+ fputs ("\tbnd call\t", asm_out_file);
-+ else
-+ fputs ("\tcall\t", asm_out_file);
-+ assemble_name_raw (asm_out_file, indirectlabel1);
-+ fputc ('\n', asm_out_file);
-+ }
-+}
-+
-+/* Output indirect branch via a call and return thunk. CALL_OP is
-+ the branch target. XASM is the assembly template for CALL_OP.
-+ Branch is a tail call if SIBCALL_P is true. */
-+
-+static void
-+ix86_output_indirect_branch (rtx call_op, const char *xasm,
-+ bool sibcall_p)
-+{
-+ if (REG_P (call_op))
-+ ix86_output_indirect_branch_via_reg (call_op, sibcall_p);
-+ else
-+ ix86_output_indirect_branch_via_push (call_op, xasm, sibcall_p);
-+}
-+/* Output indirect jump. CALL_OP is the jump target. Jump is a
-+ function return if RET_P is true. */
-+
-+const char *
-+ix86_output_indirect_jmp (rtx call_op, bool ret_p)
-+{
-+ if (cfun->machine->indirect_branch_type != indirect_branch_keep)
-+ {
-+ /* We can't have red-zone if this isn't a function return since
-+ "call" in the indirect thunk pushes the return address onto
-+ stack, destroying red-zone. */
-+ if (!ret_p && ix86_red_zone_size != 0)
-+ gcc_unreachable ();
-+
-+ ix86_output_indirect_branch (call_op, "%0", true);
-+ return "";
-+ }
-+ else
-+ return "%!jmp\t%A0";
-+}
-+
- /* Output the assembly for a call instruction. */
-
- const char *
- ix86_output_call_insn (rtx_insn *insn, rtx call_op)
- {
- bool direct_p = constant_call_address_operand (call_op, VOIDmode);
-+ bool output_indirect_p
-+ = (!TARGET_SEH
-+ && cfun->machine->indirect_branch_type != indirect_branch_keep);
- bool seh_nop_p = false;
- const char *xasm;
-
-@@ -28476,10 +29037,21 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
- {
- if (ix86_nopic_noplt_attribute_p (call_op))
- {
-+ direct_p = false;
- if (TARGET_64BIT)
-- xasm = "%!jmp\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ {
-+ if (output_indirect_p)
-+ xasm = "{%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ else
-+ xasm = "%!jmp\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ }
- else
-- xasm = "%!jmp\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ {
-+ if (output_indirect_p)
-+ xasm = "{%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ else
-+ xasm = "%!jmp\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ }
- }
- else
- xasm = "%!jmp\t%P0";
-@@ -28489,9 +29061,17 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
- else if (TARGET_SEH)
- xasm = "%!rex.W jmp\t%A0";
- else
-- xasm = "%!jmp\t%A0";
-+ {
-+ if (output_indirect_p)
-+ xasm = "%0";
-+ else
-+ xasm = "%!jmp\t%A0";
-+ }
-
-- output_asm_insn (xasm, &call_op);
-+ if (output_indirect_p && !direct_p)
-+ ix86_output_indirect_branch (call_op, xasm, true);
-+ else
-+ output_asm_insn (xasm, &call_op);
- return "";
- }
-
-@@ -28529,18 +29109,37 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
- {
- if (ix86_nopic_noplt_attribute_p (call_op))
- {
-+ direct_p = false;
- if (TARGET_64BIT)
-- xasm = "%!call\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ {
-+ if (output_indirect_p)
-+ xasm = "{%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ else
-+ xasm = "%!call\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}";
-+ }
- else
-- xasm = "%!call\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ {
-+ if (output_indirect_p)
-+ xasm = "{%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ else
-+ xasm = "%!call\t{*%p0@GOT|[DWORD PTR %p0@GOT]}";
-+ }
- }
- else
- xasm = "%!call\t%P0";
- }
- else
-- xasm = "%!call\t%A0";
-+ {
-+ if (output_indirect_p)
-+ xasm = "%0";
-+ else
-+ xasm = "%!call\t%A0";
-+ }
-
-- output_asm_insn (xasm, &call_op);
-+ if (output_indirect_p && !direct_p)
-+ ix86_output_indirect_branch (call_op, xasm, false);
-+ else
-+ output_asm_insn (xasm, &call_op);
-
- if (seh_nop_p)
- return "nop";
-@@ -41459,7 +42058,7 @@ ix86_handle_struct_attribute (tree *node, tree name, tree, int,
- }
-
- static tree
--ix86_handle_fndecl_attribute (tree *node, tree name, tree, int,
-+ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
- bool *no_add_attrs)
- {
- if (TREE_CODE (*node) != FUNCTION_DECL)
-@@ -41468,6 +42067,29 @@ ix86_handle_fndecl_attribute (tree *node, tree name, tree, int,
- name);
- *no_add_attrs = true;
- }
-+
-+ if (is_attribute_p ("indirect_branch", name))
-+ {
-+ tree cst = TREE_VALUE (args);
-+ if (TREE_CODE (cst) != STRING_CST)
-+ {
-+ warning (OPT_Wattributes,
-+ "%qE attribute requires a string constant argument",
-+ name);
-+ *no_add_attrs = true;
-+ }
-+ else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
-+ {
-+ warning (OPT_Wattributes,
-+ "argument to %qE attribute is not "
-+ "(keep|thunk|thunk-inline|thunk-extern)", name);
-+ *no_add_attrs = true;
-+ }
-+ }
-+
- return NULL_TREE;
- }
-
-@@ -45776,6 +46398,8 @@ static const struct attribute_spec ix86_attribute_table[] =
- ix86_handle_interrupt_attribute, false },
- { "no_caller_saved_registers", 0, 0, false, true, true,
- ix86_handle_no_caller_saved_registers_attribute, false },
-+ { "indirect_branch", 1, 1, true, false, false,
-+ ix86_handle_fndecl_attribute, false },
-
- /* End element. */
- { NULL, 0, 0, false, false, false, NULL, false }
-diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
-index 11727e5..d8370ae 100644
---- a/gcc/config/i386/i386.h
-+++ b/gcc/config/i386/i386.h
-@@ -2609,6 +2609,13 @@ struct GTY(()) machine_function {
- /* Function type. */
- ENUM_BITFIELD(function_type) func_type : 2;
-
-+ /* How to generate indirec branch. */
-+ ENUM_BITFIELD(indirect_branch) indirect_branch_type : 3;
-+
-+ /* If true, the current function has local indirect jumps, like
-+ "indirect_jump" or "tablejump". */
-+ BOOL_BITFIELD has_local_indirect_jump : 1;
-+
- /* If true, the current function is a function specified with
- the "interrupt" or "no_caller_saved_registers" attribute. */
- BOOL_BITFIELD no_caller_saved_registers : 1;
-diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
-index dbe88f4..cd2e73c 100644
---- a/gcc/config/i386/i386.md
-+++ b/gcc/config/i386/i386.md
-@@ -11627,13 +11627,18 @@
- {
- if (TARGET_X32)
- operands[0] = convert_memory_address (word_mode, operands[0]);
-+ cfun->machine->has_local_indirect_jump = true;
- })
-
- (define_insn "*indirect_jump"
- [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))]
- ""
-- "%!jmp\t%A0"
-- [(set_attr "type" "ibr")
-+ "* return ix86_output_indirect_jmp (operands[0], false);"
-+ [(set (attr "type")
-+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
-+ != indirect_branch_keep)")
-+ (const_string "multi")
-+ (const_string "ibr")))
- (set_attr "length_immediate" "0")
- (set_attr "maybe_prefix_bnd" "1")])
-
-@@ -11676,14 +11681,19 @@
-
- if (TARGET_X32)
- operands[0] = convert_memory_address (word_mode, operands[0]);
-+ cfun->machine->has_local_indirect_jump = true;
- })
-
- (define_insn "*tablejump_1"
- [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))
- (use (label_ref (match_operand 1)))]
- ""
-- "%!jmp\t%A0"
-- [(set_attr "type" "ibr")
-+ "* return ix86_output_indirect_jmp (operands[0], false);"
-+ [(set (attr "type")
-+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
-+ != indirect_branch_keep)")
-+ (const_string "multi")
-+ (const_string "ibr")))
- (set_attr "length_immediate" "0")
- (set_attr "maybe_prefix_bnd" "1")])
-
-@@ -12354,8 +12364,12 @@
- [(simple_return)
- (use (match_operand:SI 0 "register_operand" "r"))]
- "reload_completed"
-- "%!jmp\t%A0"
-- [(set_attr "type" "ibr")
-+ "* return ix86_output_indirect_jmp (operands[0], true);"
-+ [(set (attr "type")
-+ (if_then_else (match_test "(cfun->machine->indirect_branch_type
-+ != indirect_branch_keep)")
-+ (const_string "multi")
-+ (const_string "ibr")))
- (set_attr "length_immediate" "0")
- (set_attr "maybe_prefix_bnd" "1")])
-
-diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
-index 9384e29..c076d9c 100644
---- a/gcc/config/i386/i386.opt
-+++ b/gcc/config/i386/i386.opt
-@@ -927,3 +927,23 @@ Attempt to avoid generating instruction sequences containing ret bytes.
- mgeneral-regs-only
- Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Var(ix86_target_flags) Save
- Generate code which uses only the general registers.
-+
-+mindirect-branch=
-+Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_indirect_branch) Init(indirect_branch_keep)
-+Convert indirect call and jump to call and return thunks.
-+
-+Enum
-+Name(indirect_branch) Type(enum indirect_branch)
-+Known indirect branch choices (for use with the -mindirect-branch= option):
-+
-+EnumValue
-+Enum(indirect_branch) String(keep) Value(indirect_branch_keep)
-+
-+EnumValue
-+Enum(indirect_branch) String(thunk) Value(indirect_branch_thunk)
-+
-+EnumValue
-+Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
-+
-+EnumValue
-+Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
-diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
-index ba309d0..935381d 100644
---- a/gcc/doc/extend.texi
-+++ b/gcc/doc/extend.texi
-@@ -5540,6 +5540,16 @@ Specify which floating-point unit to use. You must specify the
- @code{target("fpmath=sse,387")} option as
- @code{target("fpmath=sse+387")} because the comma would separate
- different options.
-+
-+@item indirect_branch("@var{choice}")
-+@cindex @code{indirect_branch} function attribute, x86
-+On x86 targets, the @code{indirect_branch} attribute causes the compiler
-+to convert indirect call and jump with @var{choice}. @samp{keep}
-+keeps indirect call and jump unmodified. @samp{thunk} converts indirect
-+call and jump to call and return thunk. @samp{thunk-inline} converts
-+indirect call and jump to inlined call and return thunk.
-+@samp{thunk-extern} converts indirect call and jump to external call
-+and return thunk provided in a separate object file.
- @end table
-
- On the x86, the inliner does not inline a
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index 7311c10..4979c8c 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -1210,7 +1210,8 @@ See RS/6000 and PowerPC Options.
- -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
- -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
- -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
---mmitigate-rop -mgeneral-regs-only}
-+-mmitigate-rop -mgeneral-regs-only @gol
-+-mindirect-branch=@var{choice}}
-
- @emph{x86 Windows Options}
- @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
-@@ -25686,6 +25687,17 @@ Generate code that uses only the general-purpose registers. This
- prevents the compiler from using floating-point, vector, mask and bound
- registers.
-
-+@item -mindirect-branch=@var{choice}
-+@opindex -mindirect-branch
-+Convert indirect call and jump with @var{choice}. The default is
-+@samp{keep}, which keeps indirect call and jump unmodified.
-+@samp{thunk} converts indirect call and jump to call and return thunk.
-+@samp{thunk-inline} converts indirect call and jump to inlined call
-+and return thunk. @samp{thunk-extern} converts indirect call and jump
-+to external call and return thunk provided in a separate object file.
-+You can control this behavior for a specific function by using the
-+function attribute @code{indirect_branch}. @xref{Function Attributes}.
-+
- @end table
-
- These @samp{-m} switches are supported in addition to the above
diff --git a/sys-devel/gcc/files/spectre-0002-mfunction-return.patch b/sys-devel/gcc/files/spectre-0002-mfunction-return.patch
deleted file mode 100644
index 391e89d..0000000
--- a/sys-devel/gcc/files/spectre-0002-mfunction-return.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-From 357311dd400f7f72d2132f2f94161ece39bf08c6 Mon Sep 17 00:00:00 2001
-From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
-Date: Tue, 16 Jan 2018 11:10:44 +0000
-Subject: [PATCH] x86: Add -mfunction-return=
-
-Add -mfunction-return= option to convert function return to call and
-return thunks. The default is 'keep', which keeps function return
-unmodified. 'thunk' converts function return to call and return thunk.
-'thunk-inline' converts function return to inlined call and return thunk.
-'thunk-extern' converts function return to external call and return
-thunk provided in a separate object file. You can control this behavior
-for a specific function by using the function attribute function_return.
-
-Function return thunk is the same as memory thunk for -mindirect-branch=
-where the return address is at the top of the stack:
-
-__x86_return_thunk:
- call L2
-L1:
- pause
- lfence
- jmp L1
-L2:
- lea 8(%rsp), %rsp|lea 4(%esp), %esp
- ret
-
-and function return becomes
-
- jmp __x86_return_thunk
-
-gcc/
-
- Backport from mainline
- 2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/i386-protos.h (ix86_output_function_return): New.
- * config/i386/i386.c (ix86_set_indirect_branch_type): Also
- set function_return_type.
- (indirect_thunk_name): Add ret_p to indicate thunk for function
- return.
- (output_indirect_thunk_function): Pass false to
- indirect_thunk_name.
- (ix86_output_indirect_branch_via_reg): Likewise.
- (ix86_output_indirect_branch_via_push): Likewise.
- (output_indirect_thunk_function): Create alias for function
- return thunk if regno < 0.
- (ix86_output_function_return): New function.
- (ix86_handle_fndecl_attribute): Handle function_return.
- (ix86_attribute_table): Add function_return.
- * config/i386/i386.h (machine_function): Add
- function_return_type.
- * config/i386/i386.md (simple_return_internal): Use
- ix86_output_function_return.
- (simple_return_internal_long): Likewise.
- * config/i386/i386.opt (mfunction-return=): New option.
- (indirect_branch): Mention -mfunction-return=.
- * doc/extend.texi: Document function_return function attribute.
- * doc/invoke.texi: Document -mfunction-return= option.
-
-i386: Don't use ASM_OUTPUT_DEF for TARGET_MACHO
-
-ASM_OUTPUT_DEF isn't defined for TARGET_MACHO. Use ASM_OUTPUT_LABEL to
-generate the __x86_return_thunk label, instead of the set directive.
-Update testcase to remove the __x86_return_thunk label check. Since
--fno-pic is ignored on Darwin, update testcases to sscan or "push"
-only on Linux.
-
-gcc/
-
- Backport from mainline
- 2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
-
- PR target/83839
- * config/i386/i386.c (output_indirect_thunk_function): Use
- ASM_OUTPUT_LABEL, instead of ASM_OUTPUT_DEF, for TARGET_MACHO
- for __x86.return_thunk.
-
-
-git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256734 138bc75d-0d04-0410-961f-82ee72b054a4
----
- gcc/config/i386/i386-protos.h | 1 +
- gcc/config/i386/i386.c | 152 +++++++++++++++++++--
- gcc/config/i386/i386.h | 3 +
- gcc/config/i386/i386.md | 9 +-
- gcc/config/i386/i386.opt | 6 +-
- gcc/doc/extend.texi | 9 ++
- gcc/doc/invoke.texi | 13 +-
- 58 files changed, 641 insertions(+), 74 deletions(-)
-
-diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
-index bcdd987..42eece3 100644
---- a/gcc/config/i386/i386-protos.h
-+++ b/gcc/config/i386/i386-protos.h
-@@ -314,6 +314,7 @@ extern enum attr_cpu ix86_schedule;
-
- extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
- extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
-+extern const char * ix86_output_function_return (bool long_p);
- extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
- enum machine_mode mode);
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 7e779c1..8fb8902 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -7188,6 +7188,31 @@ ix86_set_indirect_branch_type (tree fndecl)
- else
- cfun->machine->indirect_branch_type = ix86_indirect_branch;
- }
-+
-+ if (cfun->machine->function_return_type == indirect_branch_unset)
-+ {
-+ tree attr = lookup_attribute ("function_return",
-+ DECL_ATTRIBUTES (fndecl));
-+ if (attr != NULL)
-+ {
-+ tree args = TREE_VALUE (attr);
-+ if (args == NULL)
-+ gcc_unreachable ();
-+ tree cst = TREE_VALUE (args);
-+ if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
-+ cfun->machine->function_return_type = indirect_branch_keep;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
-+ cfun->machine->function_return_type = indirect_branch_thunk;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
-+ cfun->machine->function_return_type = indirect_branch_thunk_inline;
-+ else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
-+ cfun->machine->function_return_type = indirect_branch_thunk_extern;
-+ else
-+ gcc_unreachable ();
-+ }
-+ else
-+ cfun->machine->function_return_type = ix86_function_return;
-+ }
- }
-
- /* Establish appropriate back-end context for processing the function
-@@ -12000,8 +12025,12 @@ static int indirect_thunks_bnd_used;
- /* Fills in the label name that should be used for the indirect thunk. */
-
- static void
--indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
-+indirect_thunk_name (char name[32], int regno, bool need_bnd_p,
-+ bool ret_p)
- {
-+ if (regno >= 0 && ret_p)
-+ gcc_unreachable ();
-+
- if (USE_HIDDEN_LINKONCE)
- {
- const char *bnd = need_bnd_p ? "_bnd" : "";
-@@ -12016,7 +12045,10 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
- bnd, reg_prefix, reg_names[regno]);
- }
- else
-- sprintf (name, "__x86_indirect_thunk%s", bnd);
-+ {
-+ const char *ret = ret_p ? "return" : "indirect";
-+ sprintf (name, "__x86_%s_thunk%s", ret, bnd);
-+ }
- }
- else
- {
-@@ -12029,10 +12061,20 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p)
- }
- else
- {
-- if (need_bnd_p)
-- ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
-+ if (ret_p)
-+ {
-+ if (need_bnd_p)
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LRTB", 0);
-+ else
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LRT", 0);
-+ }
- else
-- ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
-+ {
-+ if (need_bnd_p)
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LITB", 0);
-+ else
-+ ASM_GENERATE_INTERNAL_LABEL (name, "LIT", 0);
-+ }
- }
- }
- }
-@@ -12127,7 +12169,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
- tree decl;
-
- /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */
-- indirect_thunk_name (name, regno, need_bnd_p);
-+ indirect_thunk_name (name, regno, need_bnd_p, false);
- decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
- get_identifier (name),
- build_function_type_list (void_type_node, NULL_TREE));
-@@ -12170,6 +12212,36 @@ output_indirect_thunk_function (bool need_bnd_p, int regno)
- ASM_OUTPUT_LABEL (asm_out_file, name);
- }
-
-+ if (regno < 0)
-+ {
-+ /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */
-+ char alias[32];
-+
-+ indirect_thunk_name (alias, regno, need_bnd_p, true);
-+#if TARGET_MACHO
-+ if (TARGET_MACHO)
-+ {
-+ fputs ("\t.weak_definition\t", asm_out_file);
-+ assemble_name (asm_out_file, alias);
-+ fputs ("\n\t.private_extern\t", asm_out_file);
-+ assemble_name (asm_out_file, alias);
-+ putc ('\n', asm_out_file);
-+ ASM_OUTPUT_LABEL (asm_out_file, alias);
-+ }
-+#else
-+ ASM_OUTPUT_DEF (asm_out_file, alias, name);
-+ if (USE_HIDDEN_LINKONCE)
-+ {
-+ fputs ("\t.globl\t", asm_out_file);
-+ assemble_name (asm_out_file, alias);
-+ putc ('\n', asm_out_file);
-+ fputs ("\t.hidden\t", asm_out_file);
-+ assemble_name (asm_out_file, alias);
-+ putc ('\n', asm_out_file);
-+ }
-+#endif
-+ }
-+
- DECL_INITIAL (decl) = make_node (BLOCK);
- current_function_decl = decl;
- allocate_struct_function (decl, false);
-@@ -28775,7 +28847,7 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
- else
- indirect_thunks_used |= 1 << i;
- }
-- indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
-+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p, false);
- thunk_name = thunk_name_buf;
- }
- else
-@@ -28884,7 +28956,7 @@ ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm,
- else
- indirect_thunk_needed = true;
- }
-- indirect_thunk_name (thunk_name_buf, regno, need_bnd_p);
-+ indirect_thunk_name (thunk_name_buf, regno, need_bnd_p, false);
- thunk_name = thunk_name_buf;
- }
- else
-@@ -29019,6 +29091,46 @@ ix86_output_indirect_jmp (rtx call_op, bool ret_p)
- return "%!jmp\t%A0";
- }
-
-+/* Output function return. CALL_OP is the jump target. Add a REP
-+ prefix to RET if LONG_P is true and function return is kept. */
-+
-+const char *
-+ix86_output_function_return (bool long_p)
-+{
-+ if (cfun->machine->function_return_type != indirect_branch_keep)
-+ {
-+ char thunk_name[32];
-+ bool need_bnd_p = ix86_bnd_prefixed_insn_p (current_output_insn);
-+
-+ if (cfun->machine->function_return_type
-+ != indirect_branch_thunk_inline)
-+ {
-+ bool need_thunk = (cfun->machine->function_return_type
-+ == indirect_branch_thunk);
-+ indirect_thunk_name (thunk_name, -1, need_bnd_p, true);
-+ if (need_bnd_p)
-+ {
-+ indirect_thunk_bnd_needed |= need_thunk;
-+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name);
-+ }
-+ else
-+ {
-+ indirect_thunk_needed |= need_thunk;
-+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
-+ }
-+ }
-+ else
-+ output_indirect_thunk (need_bnd_p, -1);
-+
-+ return "";
-+ }
-+
-+ if (!long_p || ix86_bnd_prefixed_insn_p (current_output_insn))
-+ return "%!ret";
-+
-+ return "rep%; ret";
-+}
-+
- /* Output the assembly for a call instruction. */
-
- const char *
-@@ -42090,6 +42202,28 @@ ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
- }
- }
-
-+ if (is_attribute_p ("function_return", name))
-+ {
-+ tree cst = TREE_VALUE (args);
-+ if (TREE_CODE (cst) != STRING_CST)
-+ {
-+ warning (OPT_Wattributes,
-+ "%qE attribute requires a string constant argument",
-+ name);
-+ *no_add_attrs = true;
-+ }
-+ else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
-+ && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
-+ {
-+ warning (OPT_Wattributes,
-+ "argument to %qE attribute is not "
-+ "(keep|thunk|thunk-inline|thunk-extern)", name);
-+ *no_add_attrs = true;
-+ }
-+ }
-+
- return NULL_TREE;
- }
-
-@@ -46400,6 +46534,8 @@ static const struct attribute_spec ix86_attribute_table[] =
- ix86_handle_no_caller_saved_registers_attribute, false },
- { "indirect_branch", 1, 1, true, false, false,
- ix86_handle_fndecl_attribute, false },
-+ { "function_return", 1, 1, true, false, false,
-+ ix86_handle_fndecl_attribute, false },
-
- /* End element. */
- { NULL, 0, 0, false, false, false, NULL, false }
-diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
-index d8370ae..e7da790 100644
---- a/gcc/config/i386/i386.h
-+++ b/gcc/config/i386/i386.h
-@@ -2616,6 +2616,9 @@ struct GTY(()) machine_function {
- "indirect_jump" or "tablejump". */
- BOOL_BITFIELD has_local_indirect_jump : 1;
-
-+ /* How to generate function return. */
-+ ENUM_BITFIELD(indirect_branch) function_return_type : 3;
-+
- /* If true, the current function is a function specified with
- the "interrupt" or "no_caller_saved_registers" attribute. */
- BOOL_BITFIELD no_caller_saved_registers : 1;
-diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
-index cd2e73c..d112bdb 100644
---- a/gcc/config/i386/i386.md
-+++ b/gcc/config/i386/i386.md
-@@ -12315,7 +12315,7 @@
- (define_insn "simple_return_internal"
- [(simple_return)]
- "reload_completed"
-- "%!ret"
-+ "* return ix86_output_function_return (false);"
- [(set_attr "length" "1")
- (set_attr "atom_unit" "jeu")
- (set_attr "length_immediate" "0")
-@@ -12337,12 +12337,7 @@
- [(simple_return)
- (unspec [(const_int 0)] UNSPEC_REP)]
- "reload_completed"
--{
-- if (ix86_bnd_prefixed_insn_p (insn))
-- return "%!ret";
--
-- return "rep%; ret";
--}
-+ "* return ix86_output_function_return (true);"
- [(set_attr "length" "2")
- (set_attr "atom_unit" "jeu")
- (set_attr "length_immediate" "0")
-diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
-index c076d9c..b07388d 100644
---- a/gcc/config/i386/i386.opt
-+++ b/gcc/config/i386/i386.opt
-@@ -932,9 +932,13 @@ mindirect-branch=
- Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_indirect_branch) Init(indirect_branch_keep)
- Convert indirect call and jump to call and return thunks.
-
-+mfunction-return=
-+Target Report RejectNegative Joined Enum(indirect_branch) Var(ix86_function_return) Init(indirect_branch_keep)
-+Convert function return to call and return thunk.
-+
- Enum
- Name(indirect_branch) Type(enum indirect_branch)
--Known indirect branch choices (for use with the -mindirect-branch= option):
-+Known indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):
-
- EnumValue
- Enum(indirect_branch) String(keep) Value(indirect_branch_keep)
-diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
-index 935381d..46e0a36 100644
---- a/gcc/doc/extend.texi
-+++ b/gcc/doc/extend.texi
-@@ -5550,6 +5550,15 @@ call and jump to call and return thunk. @samp{thunk-inline} converts
- indirect call and jump to inlined call and return thunk.
- @samp{thunk-extern} converts indirect call and jump to external call
- and return thunk provided in a separate object file.
-+
-+@item function_return("@var{choice}")
-+@cindex @code{function_return} function attribute, x86
-+On x86 targets, the @code{function_return} attribute causes the compiler
-+to convert function return with @var{choice}. @samp{keep} keeps function
-+return unmodified. @samp{thunk} converts function return to call and
-+return thunk. @samp{thunk-inline} converts function return to inlined
-+call and return thunk. @samp{thunk-extern} converts function return to
-+external call and return thunk provided in a separate object file.
- @end table
-
- On the x86, the inliner does not inline a
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index 4979c8c..f3eb54b 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -1211,7 +1211,7 @@ See RS/6000 and PowerPC Options.
- -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
- -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
- -mmitigate-rop -mgeneral-regs-only @gol
---mindirect-branch=@var{choice}}
-+-mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
-
- @emph{x86 Windows Options}
- @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
-@@ -25698,6 +25698,17 @@ to external call and return thunk provided in a separate object file.
- You can control this behavior for a specific function by using the
- function attribute @code{indirect_branch}. @xref{Function Attributes}.
-
-+@item -mfunction-return=@var{choice}
-+@opindex -mfunction-return
-+Convert function return with @var{choice}. The default is @samp{keep},
-+which keeps function return unmodified. @samp{thunk} converts function
-+return to call and return thunk. @samp{thunk-inline} converts function
-+return to inlined call and return thunk. @samp{thunk-extern} converts
-+function return to external call and return thunk provided in a separate
-+object file. You can control this behavior for a specific function by
-+using the function attribute @code{function_return}.
-+@xref{Function Attributes}.
-+
- @end table
-
- These @samp{-m} switches are supported in addition to the above
diff --git a/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch b/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch
deleted file mode 100644
index 2e5e779..0000000
--- a/sys-devel/gcc/files/spectre-0003-mindirect-branch-register.patch
+++ /dev/null
@@ -1,340 +0,0 @@
-From 86118fbdbafe6af54b2da467e1073c49e1742116 Mon Sep 17 00:00:00 2001
-From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
-Date: Tue, 16 Jan 2018 11:17:49 +0000
-Subject: [PATCH] x86: Add -mindirect-branch-register
-
-Add -mindirect-branch-register to force indirect branch via register.
-This is implemented by disabling patterns of indirect branch via memory,
-similar to TARGET_X32.
-
--mindirect-branch= and -mfunction-return= tests are updated with
--mno-indirect-branch-register to avoid false test failures when
--mindirect-branch-register is added to RUNTESTFLAGS for "make check".
-
-gcc/
-
- Backport from mainline
- 2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/constraints.md (Bs): Disallow memory operand for
- -mindirect-branch-register.
- (Bw): Likewise.
- * config/i386/predicates.md (indirect_branch_operand): Likewise.
- (GOT_memory_operand): Likewise.
- (call_insn_operand): Likewise.
- (sibcall_insn_operand): Likewise.
- (GOT32_symbol_operand): Likewise.
- * config/i386/i386.md (indirect_jump): Call convert_memory_address
- for -mindirect-branch-register.
- (tablejump): Likewise.
- (*sibcall_memory): Likewise.
- (*sibcall_value_memory): Likewise.
- Disallow peepholes of indirect call and jump via memory for
- -mindirect-branch-register.
- (*call_pop): Replace m with Bw.
- (*call_value_pop): Likewise.
- (*sibcall_pop_memory): Replace m with Bs.
- * config/i386/i386.opt (mindirect-branch-register): New option.
- * doc/invoke.texi: Document -mindirect-branch-register option.
-
-i386: Rename to ix86_indirect_branch_register
-
-Rename the variable for -mindirect-branch-register to
-ix86_indirect_branch_register to match the command-line option name.
-
- Backport from mainline
- 2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/constraints.md (Bs): Replace
- ix86_indirect_branch_thunk_register with
- ix86_indirect_branch_register.
- (Bw): Likewise.
- * config/i386/i386.md (indirect_jump): Likewise.
- (tablejump): Likewise.
- (*sibcall_memory): Likewise.
- (*sibcall_value_memory): Likewise.
- Peepholes of indirect call and jump via memory: Likewise.
- * config/i386/i386.opt: Likewise.
- * config/i386/predicates.md (indirect_branch_operand): Likewise.
- (GOT_memory_operand): Likewise.
- (call_insn_operand): Likewise.
- (sibcall_insn_operand): Likewise.
- (GOT32_symbol_operand): Likewise.
-
-x86: Rewrite ix86_indirect_branch_register logic
-
-Rewrite ix86_indirect_branch_register logic with
-
-(and (not (match_test "ix86_indirect_branch_register"))
- (original condition before r256662))
-
- Backport from mainline
- 2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/predicates.md (constant_call_address_operand):
- Rewrite ix86_indirect_branch_register logic.
- (sibcall_insn_operand): Likewise.
-
-Don't check ix86_indirect_branch_register for GOT operand
-
-Since GOT_memory_operand and GOT32_symbol_operand are simple pattern
-matches, don't check ix86_indirect_branch_register here. If needed,
--mindirect-branch= will convert indirect branch via GOT slot to a call
-and return thunk.
-
- Backport from mainline
- 2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/constraints.md (Bs): Update
- ix86_indirect_branch_register check. Don't check
- ix86_indirect_branch_register with GOT_memory_operand.
- (Bw): Likewise.
- * config/i386/predicates.md (GOT_memory_operand): Don't check
- ix86_indirect_branch_register here.
- (GOT32_symbol_operand): Likewise.
-
-i386: Rewrite indirect_branch_operand logic
-
- Backport from mainline
- 2018-01-15 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/predicates.md (indirect_branch_operand): Rewrite
- ix86_indirect_branch_register logic.
-
-
-git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256735 138bc75d-0d04-0410-961f-82ee72b054a4
----
- gcc/config/i386/constraints.md | 6 +-
- gcc/config/i386/i386.md | 34 +++++++----
- gcc/config/i386/i386.opt | 4 ++
- gcc/config/i386/predicates.md | 21 ++++---
- gcc/doc/invoke.texi | 7 ++-
- 49 files changed, 266 insertions(+), 63 deletions(-)
-
-diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
-index 38d604f..a0a632a 100644
---- a/gcc/config/i386/constraints.md
-+++ b/gcc/config/i386/constraints.md
-@@ -198,14 +198,16 @@
-
- (define_constraint "Bs"
- "@internal Sibcall memory operand."
-- (ior (and (not (match_test "TARGET_X32"))
-+ (ior (and (not (match_test "ix86_indirect_branch_register"))
-+ (not (match_test "TARGET_X32"))
- (match_operand 0 "sibcall_memory_operand"))
- (and (match_test "TARGET_X32 && Pmode == DImode")
- (match_operand 0 "GOT_memory_operand"))))
-
- (define_constraint "Bw"
- "@internal Call memory operand."
-- (ior (and (not (match_test "TARGET_X32"))
-+ (ior (and (not (match_test "ix86_indirect_branch_register"))
-+ (not (match_test "TARGET_X32"))
- (match_operand 0 "memory_operand"))
- (and (match_test "TARGET_X32 && Pmode == DImode")
- (match_operand 0 "GOT_memory_operand"))))
-diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
-index d112bdb..d074c2f 100644
---- a/gcc/config/i386/i386.md
-+++ b/gcc/config/i386/i386.md
-@@ -11625,7 +11625,7 @@
- [(set (pc) (match_operand 0 "indirect_branch_operand"))]
- ""
- {
-- if (TARGET_X32)
-+ if (TARGET_X32 || ix86_indirect_branch_register)
- operands[0] = convert_memory_address (word_mode, operands[0]);
- cfun->machine->has_local_indirect_jump = true;
- })
-@@ -11679,7 +11679,7 @@
- OPTAB_DIRECT);
- }
-
-- if (TARGET_X32)
-+ if (TARGET_X32 || ix86_indirect_branch_register)
- operands[0] = convert_memory_address (word_mode, operands[0]);
- cfun->machine->has_local_indirect_jump = true;
- })
-@@ -11871,7 +11871,7 @@
- [(call (mem:QI (match_operand:W 0 "memory_operand" "m"))
- (match_operand 1))
- (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
-- "!TARGET_X32"
-+ "!TARGET_X32 && !ix86_indirect_branch_register"
- "* return ix86_output_call_insn (insn, operands[0]);"
- [(set_attr "type" "call")])
-
-@@ -11880,7 +11880,9 @@
- (match_operand:W 1 "memory_operand"))
- (call (mem:QI (match_dup 0))
- (match_operand 3))]
-- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
-+ "!TARGET_X32
-+ && !ix86_indirect_branch_register
-+ && SIBLING_CALL_P (peep2_next_insn (1))
- && !reg_mentioned_p (operands[0],
- CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
- [(parallel [(call (mem:QI (match_dup 1))
-@@ -11893,7 +11895,9 @@
- (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
- (call (mem:QI (match_dup 0))
- (match_operand 3))]
-- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
-+ "!TARGET_X32
-+ && !ix86_indirect_branch_register
-+ && SIBLING_CALL_P (peep2_next_insn (2))
- && !reg_mentioned_p (operands[0],
- CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
- [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
-@@ -11915,7 +11919,7 @@
- })
-
- (define_insn "*call_pop"
-- [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lmBz"))
-+ [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lBwBz"))
- (match_operand 1))
- (set (reg:SI SP_REG)
- (plus:SI (reg:SI SP_REG)
-@@ -11935,7 +11939,7 @@
- [(set_attr "type" "call")])
-
- (define_insn "*sibcall_pop_memory"
-- [(call (mem:QI (match_operand:SI 0 "memory_operand" "m"))
-+ [(call (mem:QI (match_operand:SI 0 "memory_operand" "Bs"))
- (match_operand 1))
- (set (reg:SI SP_REG)
- (plus:SI (reg:SI SP_REG)
-@@ -11989,7 +11993,9 @@
- [(set (match_operand:W 0 "register_operand")
- (match_operand:W 1 "memory_operand"))
- (set (pc) (match_dup 0))]
-- "!TARGET_X32 && peep2_reg_dead_p (2, operands[0])"
-+ "!TARGET_X32
-+ && !ix86_indirect_branch_register
-+ && peep2_reg_dead_p (2, operands[0])"
- [(set (pc) (match_dup 1))])
-
- ;; Call subroutine, returning value in operand 0
-@@ -12070,7 +12076,7 @@
- (call (mem:QI (match_operand:W 1 "memory_operand" "m"))
- (match_operand 2)))
- (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
-- "!TARGET_X32"
-+ "!TARGET_X32 && !ix86_indirect_branch_register"
- "* return ix86_output_call_insn (insn, operands[1]);"
- [(set_attr "type" "callv")])
-
-@@ -12080,7 +12086,9 @@
- (set (match_operand 2)
- (call (mem:QI (match_dup 0))
- (match_operand 3)))]
-- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
-+ "!TARGET_X32
-+ && !ix86_indirect_branch_register
-+ && SIBLING_CALL_P (peep2_next_insn (1))
- && !reg_mentioned_p (operands[0],
- CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
- [(parallel [(set (match_dup 2)
-@@ -12095,7 +12103,9 @@
- (set (match_operand 2)
- (call (mem:QI (match_dup 0))
- (match_operand 3)))]
-- "!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
-+ "!TARGET_X32
-+ && !ix86_indirect_branch_register
-+ && SIBLING_CALL_P (peep2_next_insn (2))
- && !reg_mentioned_p (operands[0],
- CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
- [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
-@@ -12120,7 +12130,7 @@
-
- (define_insn "*call_value_pop"
- [(set (match_operand 0)
-- (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lmBz"))
-+ (call (mem:QI (match_operand:SI 1 "call_insn_operand" "lBwBz"))
- (match_operand 2)))
- (set (reg:SI SP_REG)
- (plus:SI (reg:SI SP_REG)
-diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
-index b07388d..b90da9f 100644
---- a/gcc/config/i386/i386.opt
-+++ b/gcc/config/i386/i386.opt
-@@ -951,3 +951,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
-
- EnumValue
- Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
-+
-+mindirect-branch-register
-+Target Report Var(ix86_indirect_branch_register) Init(0)
-+Force indirect call and jump via register.
-diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
-index 2fc2c60..e4da309 100644
---- a/gcc/config/i386/predicates.md
-+++ b/gcc/config/i386/predicates.md
-@@ -635,7 +635,8 @@
- ;; Test for a valid operand for indirect branch.
- (define_predicate "indirect_branch_operand"
- (ior (match_operand 0 "register_operand")
-- (and (not (match_test "TARGET_X32"))
-+ (and (not (match_test "ix86_indirect_branch_register"))
-+ (not (match_test "TARGET_X32"))
- (match_operand 0 "memory_operand"))))
-
- ;; Return true if OP is a memory operands that can be used in sibcalls.
-@@ -678,20 +679,22 @@
- (ior (match_test "constant_call_address_operand
- (op, mode == VOIDmode ? mode : Pmode)")
- (match_operand 0 "call_register_no_elim_operand")
-- (ior (and (not (match_test "TARGET_X32"))
-- (match_operand 0 "memory_operand"))
-- (and (match_test "TARGET_X32 && Pmode == DImode")
-- (match_operand 0 "GOT_memory_operand")))))
-+ (and (not (match_test "ix86_indirect_branch_register"))
-+ (ior (and (not (match_test "TARGET_X32"))
-+ (match_operand 0 "memory_operand"))
-+ (and (match_test "TARGET_X32 && Pmode == DImode")
-+ (match_operand 0 "GOT_memory_operand"))))))
-
- ;; Similarly, but for tail calls, in which we cannot allow memory references.
- (define_special_predicate "sibcall_insn_operand"
- (ior (match_test "constant_call_address_operand
- (op, mode == VOIDmode ? mode : Pmode)")
- (match_operand 0 "register_no_elim_operand")
-- (ior (and (not (match_test "TARGET_X32"))
-- (match_operand 0 "sibcall_memory_operand"))
-- (and (match_test "TARGET_X32 && Pmode == DImode")
-- (match_operand 0 "GOT_memory_operand")))))
-+ (and (not (match_test "ix86_indirect_branch_register"))
-+ (ior (and (not (match_test "TARGET_X32"))
-+ (match_operand 0 "sibcall_memory_operand"))
-+ (and (match_test "TARGET_X32 && Pmode == DImode")
-+ (match_operand 0 "GOT_memory_operand"))))))
-
- ;; Return true if OP is a 32-bit GOT symbol operand.
- (define_predicate "GOT32_symbol_operand"
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index f3eb54b..1e572b1 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -1211,7 +1211,8 @@ See RS/6000 and PowerPC Options.
- -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
- -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
- -mmitigate-rop -mgeneral-regs-only @gol
---mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
-+-mindirect-branch=@var{choice} -mfunction-return==@var{choice} @gol
-+-mindirect-branch-register}
-
- @emph{x86 Windows Options}
- @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
-@@ -25709,6 +25710,10 @@ object file. You can control this behavior for a specific function by
- using the function attribute @code{function_return}.
- @xref{Function Attributes}.
-
-+@item -mindirect-branch-register
-+@opindex -mindirect-branch-register
-+Force indirect call and jump via register.
-+
- @end table
-
- These @samp{-m} switches are supported in addition to the above
diff --git a/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch b/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch
deleted file mode 100644
index afbccca..0000000
--- a/sys-devel/gcc/files/spectre-0004-v-register-modifier.patch
+++ /dev/null
@@ -1,128 +0,0 @@
-From: "H dot J dot Lu" <hjl dot tools at gmail dot com>
-To: gcc-patches at gcc dot gnu dot org
-Subject: [PATCH 4/4] x86: Add 'V' register operand modifier
-Date: Fri, 12 Jan 2018 05:15:49 -0800
-
-Add 'V', a special modifier which prints the name of the full integer
-register without '%'. For
-
-extern void (*func_p) (void);
-
-void
-foo (void)
-{
- asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
-}
-
-it generates:
-
-foo:
- movq func_p(%rip), %rax
- call __x86_indirect_thunk_rax
- ret
-
-gcc/
-
- * config/i386/i386.c (print_reg): Print the name of the full
- integer register without '%'.
- (ix86_print_operand): Handle 'V'.
- * doc/extend.texi: Document 'V' modifier.
-
-gcc/testsuite/
-
- * gcc.target/i386/indirect-thunk-register-4.c: New test.
----
- gcc/config/i386/i386.c | 13 ++++++++++++-
- gcc/doc/extend.texi | 3 +++
- gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c | 13 +++++++++++++
- 3 files changed, 28 insertions(+), 1 deletion(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 9ffcb69d6d7..e69135d7191 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -17617,6 +17617,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
- If CODE is 'h', pretend the reg is the 'high' byte register.
- If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
- If CODE is 'd', duplicate the operand for AVX instruction.
-+ If CODE is 'V', print naked full integer register name without %.
- */
-
- void
-@@ -17627,7 +17628,7 @@ print_reg (rtx x, int code, FILE *file)
- unsigned int regno;
- bool duplicated;
-
-- if (ASSEMBLER_DIALECT == ASM_ATT)
-+ if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
- putc ('%', file);
-
- if (x == pc_rtx)
-@@ -17679,6 +17680,14 @@ print_reg (rtx x, int code, FILE *file)
- return;
- }
-
-+ if (code == 'V')
-+ {
-+ if (GENERAL_REGNO_P (regno))
-+ msize = GET_MODE_SIZE (word_mode);
-+ else
-+ error ("'V' modifier on non-integer register");
-+ }
-+
- duplicated = code == 'd' && TARGET_AVX;
-
- switch (msize)
-@@ -17798,6 +17807,7 @@ print_reg (rtx x, int code, FILE *file)
- & -- print some in-use local-dynamic symbol name.
- H -- print a memory address offset by 8; used for sse high-parts
- Y -- print condition for XOP pcom* instruction.
-+ V -- print naked full integer register name without %.
- + -- print a branch hint as 'cs' or 'ds' prefix
- ; -- print a semicolon (after prefixes due to bug in older gas).
- ~ -- print "i" if TARGET_AVX2, "f" otherwise.
-@@ -18021,6 +18031,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
- case 'X':
- case 'P':
- case 'p':
-+ case 'V':
- break;
-
- case 's':
-diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
-index f120b2a1429..dce808f1eab 100644
---- a/gcc/doc/extend.texi
-+++ b/gcc/doc/extend.texi
-@@ -9292,6 +9292,9 @@ The table below shows the list of supported modifiers and their effects.
- @tab @code{2}
- @end multitable
-
-+@code{V} is a special modifier which prints the name of the full integer
-+register without @code{%}.
-+
- @anchor{x86floatingpointasmoperands}
- @subsubsection x86 Floating-Point @code{asm} Operands
-
-diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
-new file mode 100644
-index 00000000000..f0cd9b75be8
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
-@@ -0,0 +1,13 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
-+
-+extern void (*func_p) (void);
-+
-+void
-+foo (void)
-+{
-+ asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
-+}
-+
-+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
-+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */
---
-2.14.3
-
diff --git a/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch b/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch
deleted file mode 100644
index 25574d4..0000000
--- a/sys-devel/gcc/files/spectre-0005-mcmodel-large.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-From 5d1c53c6fd593de2360c1a2ae44ebf5fa3c5263b Mon Sep 17 00:00:00 2001
-From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
-Date: Tue, 16 Jan 2018 11:22:01 +0000
-Subject: [PATCH] x86: Disallow -mindirect-branch=/-mfunction-return= with
- -mcmodel=large
-
-Since the thunk function may not be reachable in large code model,
--mcmodel=large is incompatible with -mindirect-branch=thunk,
--mindirect-branch=thunk-extern, -mfunction-return=thunk and
--mfunction-return=thunk-extern. Issue an error when they are used with
--mcmodel=large.
-
-gcc/
-
- Backport from mainline
- 2018-01-14 H.J. Lu <hongjiu.lu@intel.com>
-
- * config/i386/i386.c (ix86_set_indirect_branch_type): Disallow
- -mcmodel=large with -mindirect-branch=thunk,
- -mindirect-branch=thunk-extern, -mfunction-return=thunk and
- -mfunction-return=thunk-extern.
- * doc/invoke.texi: Document -mcmodel=large is incompatible with
- -mindirect-branch=thunk, -mindirect-branch=thunk-extern,
- -mfunction-return=thunk and -mfunction-return=thunk-extern.
-
-
-git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256737 138bc75d-0d04-0410-961f-82ee72b054a4
----
- gcc/config/i386/i386.c | 26 ++++++++++++++++++++++
- gcc/doc/invoke.texi | 11 +++++++++
- 15 files changed, 156 insertions(+)
-
-diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
-index 1bbdd0c..e758387 100644
---- a/gcc/config/i386/i386.c
-+++ b/gcc/config/i386/i386.c
-@@ -7187,6 +7187,19 @@ ix86_set_indirect_branch_type (tree fndecl)
- }
- else
- cfun->machine->indirect_branch_type = ix86_indirect_branch;
-+
-+ /* -mcmodel=large is not compatible with -mindirect-branch=thunk
-+ nor -mindirect-branch=thunk-extern. */
-+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
-+ && ((cfun->machine->indirect_branch_type
-+ == indirect_branch_thunk_extern)
-+ || (cfun->machine->indirect_branch_type
-+ == indirect_branch_thunk)))
-+ error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
-+ "compatible",
-+ ((cfun->machine->indirect_branch_type
-+ == indirect_branch_thunk_extern)
-+ ? "thunk-extern" : "thunk"));
- }
-
- if (cfun->machine->function_return_type == indirect_branch_unset)
-@@ -7212,6 +7225,19 @@ ix86_set_indirect_branch_type (tree fndecl)
- }
- else
- cfun->machine->function_return_type = ix86_function_return;
-+
-+ /* -mcmodel=large is not compatible with -mfunction-return=thunk
-+ nor -mfunction-return=thunk-extern. */
-+ if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
-+ && ((cfun->machine->function_return_type
-+ == indirect_branch_thunk_extern)
-+ || (cfun->machine->function_return_type
-+ == indirect_branch_thunk)))
-+ error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
-+ "compatible",
-+ ((cfun->machine->function_return_type
-+ == indirect_branch_thunk_extern)
-+ ? "thunk-extern" : "thunk"));
- }
- }
-
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index 1e572b1..6f3c344 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -25699,6 +25699,11 @@ to external call and return thunk provided in a separate object file.
- You can control this behavior for a specific function by using the
- function attribute @code{indirect_branch}. @xref{Function Attributes}.
-
-+Note that @option{-mcmodel=large} is incompatible with
-+@option{-mindirect-branch=thunk} nor
-+@option{-mindirect-branch=thunk-extern} since the thunk function may
-+not be reachable in large code model.
-+
- @item -mfunction-return=@var{choice}
- @opindex -mfunction-return
- Convert function return with @var{choice}. The default is @samp{keep},
-@@ -25710,6 +25715,12 @@ object file. You can control this behavior for a specific function by
- using the function attribute @code{function_return}.
- @xref{Function Attributes}.
-
-+Note that @option{-mcmodel=large} is incompatible with
-+@option{-mfunction-return=thunk} nor
-+@option{-mfunction-return=thunk-extern} since the thunk function may
-+not be reachable in large code model.
-+
-+
- @item -mindirect-branch-register
- @opindex -mindirect-branch-register
- Force indirect call and jump via register.
diff --git a/sys-devel/gcc/gcc-4.9.4-r100.ebuild b/sys-devel/gcc/gcc-4.9.4-r100.ebuild
deleted file mode 100644
index 8ebef29..0000000
--- a/sys-devel/gcc/gcc-4.9.4-r100.ebuild
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PATCH_VER="1.0"
-UCLIBC_VER="1.0"
-
-# Hardened gcc 4 stuff
-PIE_VER="0.6.4"
-SPECS_VER="0.2.0"
-SPECS_GCC_VER="4.4.3"
-# arch/libc configurations known to be stable with {PIE,SSP}-by-default
-PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
-PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
-SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
-# uclibc need tls and nptl support for SSP support
-# uclibc need to be >= 0.9.33
-SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
-PIE_MUSL_STABLE="amd64 arm ppc mips x86"
-SSP_MUSL_STABLE="amd64 arm ppc mips"
-#end Hardened stuff
-
-inherit eutils toolchain
-
-KEYWORDS="~amd64 ~arm ~mips ~x86"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
- elibc_glibc? ( >=sys-libs/glibc-2.8 )
- >=${CATEGORY}/binutils-2.20"
-
-if [[ ${CATEGORY} != cross-* ]] ; then
- PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
-fi
-
-src_prepare() {
- if has_version '<sys-libs/glibc-2.12' ; then
- ewarn "Your host glibc is too old; disabling automatic fortify."
- ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
- EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
- fi
-
- toolchain_src_prepare
-
- if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
- cd "${S}"
- sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
- mv libstdc\+\+-v3/config/os/gnu-linux libstdc\+\+-v3/config/os/gnu-linux.org
- cp -r libstdc\+\+-v3/config/os/generic libstdc\+\+-v3/config/os/gnu-linux
- cp libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver libstdc++-v3/config/os/gnu-linux/
- mv libitm/config/linux/x86 libitm/config/linux/x86_glibc
- cp -r libitm/config/generic libitm/config/linux/x86
- epatch "${FILESDIR}"/${PN}-4.9.3-musl-linker-path.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-secure-plt.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-musl-res_state.patch
- epatch "${FILESDIR}"/${PN}-4.8.3-musl-fix-libc5-assumption.patch
- epatch "${FILESDIR}"/${PN}-4.8.5-posix_memalign.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-tree-vect-data-refs-correctness.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-pr68470.patch
- fi
-
- use vanilla && return 0
- #Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
- [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
-}
diff --git a/sys-devel/gcc/gcc-4.9.4-r99.ebuild b/sys-devel/gcc/gcc-4.9.4-r99.ebuild
deleted file mode 100644
index a65bc67..0000000
--- a/sys-devel/gcc/gcc-4.9.4-r99.ebuild
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PATCH_VER="1.0"
-UCLIBC_VER="1.0"
-
-# Hardened gcc 4 stuff
-PIE_VER="0.6.4"
-SPECS_VER="0.2.0"
-SPECS_GCC_VER="4.4.3"
-# arch/libc configurations known to be stable with {PIE,SSP}-by-default
-PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
-PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
-SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
-# uclibc need tls and nptl support for SSP support
-# uclibc need to be >= 0.9.33
-SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
-PIE_MUSL_STABLE="amd64 arm ppc mips x86"
-SSP_MUSL_STABLE="amd64 arm ppc mips"
-#end Hardened stuff
-
-inherit eutils toolchain
-
-KEYWORDS="amd64 arm ~mips x86"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
- elibc_glibc? ( >=sys-libs/glibc-2.8 )
- >=${CATEGORY}/binutils-2.20"
-
-if [[ ${CATEGORY} != cross-* ]] ; then
- PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
-fi
-
-src_prepare() {
- if has_version '<sys-libs/glibc-2.12' ; then
- ewarn "Your host glibc is too old; disabling automatic fortify."
- ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
- EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
- fi
-
- toolchain_src_prepare
-
- if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
- cd "${S}"
- sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
- mv libstdc\+\+-v3/config/os/gnu-linux libstdc\+\+-v3/config/os/gnu-linux.org
- cp -r libstdc\+\+-v3/config/os/generic libstdc\+\+-v3/config/os/gnu-linux
- cp libstdc++-v3/config/os/gnu-linux.org/arm-eabi-extra.ver libstdc++-v3/config/os/gnu-linux/
- mv libitm/config/linux/x86 libitm/config/linux/x86_glibc
- cp -r libitm/config/generic libitm/config/linux/x86
- epatch "${FILESDIR}"/${PN}-4.9.3-musl-linker-path.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-secure-plt.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-musl-res_state.patch
- epatch "${FILESDIR}"/${PN}-4.8.3-musl-fix-libc5-assumption.patch
- epatch "${FILESDIR}"/${PN}-4.8.5-posix_memalign.patch
- epatch "${FILESDIR}"/${PN}-4.9.3-tree-vect-data-refs-correctness.patch
- fi
-
- use vanilla && return 0
- #Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
- [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
-}
diff --git a/sys-devel/gcc/gcc-7.2.0-r1.ebuild b/sys-devel/gcc/gcc-7.2.0-r1.ebuild
deleted file mode 100644
index 7dd6ca3..0000000
--- a/sys-devel/gcc/gcc-7.2.0-r1.ebuild
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PATCH_VER="1.1"
-#UCLIBC_VER="1.0"
-
-inherit epatch toolchain
-
-KEYWORDS="~amd64 ~arm ~mips ~ppc ~x86"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
- elibc_glibc? ( >=sys-libs/glibc-2.13 )
- >=${CATEGORY}/binutils-2.20"
-
-if [[ ${CATEGORY} != cross-* ]] ; then
- PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
-fi
-
-src_prepare() {
- toolchain_src_prepare
-
- epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
-
- if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
- epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
- epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
- fi
-}
diff --git a/sys-devel/gcc/gcc-7.2.0-r2.ebuild b/sys-devel/gcc/gcc-7.2.0-r2.ebuild
deleted file mode 100644
index 40df421..0000000
--- a/sys-devel/gcc/gcc-7.2.0-r2.ebuild
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PATCH_VER="1.1"
-#UCLIBC_VER="1.0"
-
-inherit epatch toolchain
-
-# KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
- elibc_glibc? ( >=sys-libs/glibc-2.13 )
- >=${CATEGORY}/binutils-2.20"
-
-if [[ ${CATEGORY} != cross-* ]] ; then
- PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
-fi
-
-src_prepare() {
- toolchain_src_prepare
-
- epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
-
- # Meltdown/Spectre
- epatch "${FILESDIR}"/0001-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
- epatch "${FILESDIR}"/0002-gcc-7.2.0-move-struct-ix86_frame-to-machine-function.patch
-
- epatch "${FILESDIR}"/spectre-0001-mindirect-branch.patch
- epatch "${FILESDIR}"/spectre-0002-mfunction-return.patch
- epatch "${FILESDIR}"/spectre-0003-mindirect-branch-register.patch
- epatch "${FILESDIR}"/spectre-0004-v-register-modifier.patch
- epatch "${FILESDIR}"/spectre-0005-mcmodel-large.patch
-
- if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
- epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
- epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
- fi
-}
diff --git a/sys-devel/gcc/gcc-7.3.0-r1.ebuild b/sys-devel/gcc/gcc-7.3.0-r1.ebuild
deleted file mode 100644
index 7dd6ca3..0000000
--- a/sys-devel/gcc/gcc-7.3.0-r1.ebuild
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PATCH_VER="1.1"
-#UCLIBC_VER="1.0"
-
-inherit epatch toolchain
-
-KEYWORDS="~amd64 ~arm ~mips ~ppc ~x86"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
- elibc_glibc? ( >=sys-libs/glibc-2.13 )
- >=${CATEGORY}/binutils-2.20"
-
-if [[ ${CATEGORY} != cross-* ]] ; then
- PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.13 )"
-fi
-
-src_prepare() {
- toolchain_src_prepare
-
- epatch "${FILESDIR}"/gcc-7.2.0-pr69728.patch
-
- if use elibc_musl || [[ ${CATEGORY} = cross-*-musl* ]]; then
- epatch "${FILESDIR}"/6.3.0/cpu_indicator.patch
- epatch "${FILESDIR}"/7.1.0/posix_memalign.patch
- fi
-}