From a1879bd58982c8ed4b39e08e17942462027ef447 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 26 Sep 2018 07:13:06 +0000 Subject: main/gcc: upgrade to 8.2.0 --- ...ove-struct-ix86_frame-to-machine_function.patch | 241 --- ...ference-of-struct-ix86_frame-to-avoid-cop.patch | 69 - main/gcc/0002-posix_memalign.patch | 42 + main/gcc/0003-gcc-poison-system-directories.patch | 194 ++ ...nst-reference-of-struct-ix86_frame-to-avo.patch | 126 -- main/gcc/0004-x86-Add-mindirect-branch.patch | 2149 -------------------- main/gcc/0005-x86-Add-mfunction-return.patch | 1565 -------------- .../0006-x86-Add-mindirect-branch-register.patch | 941 --------- .../0007-x86-Add-V-register-operand-modifier.patch | 134 -- main/gcc/0008-s390x-muslldso.patch | 26 + ...w-mindirect-branch-mfunction-return-with-.patch | 299 --- ...VALID_REGNUM-in-indirect-thunk-processing.patch | 121 -- ...INVALID_REGNUM-as-invalid-register-number.patch | 41 - main/gcc/0010-ldbl128-config.patch | 76 + ...date-mfunction-return-for-return-with-pop.patch | 456 ----- ...-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch | 1003 --------- main/gcc/0012-static-pie.patch | 138 ++ ...-generate-alias-for-function-return-thunk.patch | 225 -- main/gcc/001_all_default-ssp-strong.patch | 215 -- main/gcc/005_all_default-as-needed.patch | 157 +- .../gcc/011_all_default-warn-format-security.patch | 43 +- main/gcc/012_all_default-warn-trampolines.patch | 18 +- main/gcc/013_all_default-ssp-fix.patch | 38 + .../067_all_gcc-poison-system-directories.patch | 194 -- main/gcc/201-cilkrts.patch | 59 - main/gcc/203-libgcc_s.patch | 7 +- main/gcc/204-linux_libc_has_function.patch | 25 - main/gcc/207-static-pie.patch | 40 - ...00-main-gcc-add-musl-s390x-dynamic-linker.patch | 32 - main/gcc/310-build-gcj-s390x.patch | 28 - main/gcc/APKBUILD | 178 +- main/gcc/ada-aarch64-multiarch.patch | 16 - main/gcc/ada-fixes.patch | 35 - main/gcc/ada-mips64.patch | 224 -- main/gcc/ada-musl.patch | 126 +- main/gcc/boehm-gc-musl.patch | 62 - main/gcc/fix-gcj-iconv-musl.patch | 120 -- main/gcc/fix-gcj-musl.patch | 49 - main/gcc/fix-gcj-stdgnu14-link.patch | 35 - main/gcc/fix-linux-header-use-in-libgcc.patch | 44 - main/gcc/fix-rs6000-pie.patch | 59 - main/gcc/gcc-4.8-build-args.patch | 41 - main/gcc/gcc-as-needed-gold.patch | 58 + main/gcc/gcc-as-needed-push-pop.patch | 43 + 44 files changed, 848 insertions(+), 8944 deletions(-) delete mode 100644 main/gcc/0001-i386-Move-struct-ix86_frame-to-machine_function.patch delete mode 100644 main/gcc/0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch create mode 100644 main/gcc/0002-posix_memalign.patch create mode 100644 main/gcc/0003-gcc-poison-system-directories.patch delete mode 100644 main/gcc/0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch delete mode 100644 main/gcc/0004-x86-Add-mindirect-branch.patch delete mode 100644 main/gcc/0005-x86-Add-mfunction-return.patch delete mode 100644 main/gcc/0006-x86-Add-mindirect-branch-register.patch delete mode 100644 main/gcc/0007-x86-Add-V-register-operand-modifier.patch create mode 100644 main/gcc/0008-s390x-muslldso.patch delete mode 100644 main/gcc/0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch delete mode 100644 main/gcc/0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch delete mode 100644 main/gcc/0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch create mode 100644 main/gcc/0010-ldbl128-config.patch delete mode 100644 main/gcc/0011-i386-Update-mfunction-return-for-return-with-pop.patch delete mode 100644 main/gcc/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch create mode 100644 main/gcc/0012-static-pie.patch delete mode 100644 main/gcc/0013-i386-Don-t-generate-alias-for-function-return-thunk.patch delete mode 100644 main/gcc/001_all_default-ssp-strong.patch create mode 100644 main/gcc/013_all_default-ssp-fix.patch delete mode 100644 main/gcc/067_all_gcc-poison-system-directories.patch delete mode 100644 main/gcc/201-cilkrts.patch delete mode 100644 main/gcc/204-linux_libc_has_function.patch delete mode 100644 main/gcc/207-static-pie.patch delete mode 100644 main/gcc/300-main-gcc-add-musl-s390x-dynamic-linker.patch delete mode 100644 main/gcc/310-build-gcj-s390x.patch delete mode 100644 main/gcc/ada-aarch64-multiarch.patch delete mode 100644 main/gcc/ada-fixes.patch delete mode 100644 main/gcc/ada-mips64.patch delete mode 100644 main/gcc/boehm-gc-musl.patch delete mode 100644 main/gcc/fix-gcj-iconv-musl.patch delete mode 100644 main/gcc/fix-gcj-musl.patch delete mode 100644 main/gcc/fix-gcj-stdgnu14-link.patch delete mode 100644 main/gcc/fix-linux-header-use-in-libgcc.patch delete mode 100644 main/gcc/fix-rs6000-pie.patch delete mode 100644 main/gcc/gcc-4.8-build-args.patch create mode 100644 main/gcc/gcc-as-needed-gold.patch create mode 100644 main/gcc/gcc-as-needed-push-pop.patch (limited to 'main') diff --git a/main/gcc/0001-i386-Move-struct-ix86_frame-to-machine_function.patch b/main/gcc/0001-i386-Move-struct-ix86_frame-to-machine_function.patch deleted file mode 100644 index ecec2bad66..0000000000 --- a/main/gcc/0001-i386-Move-struct-ix86_frame-to-machine_function.patch +++ /dev/null @@ -1,241 +0,0 @@ -From b1d2df5090abc9202a7bf2d224ac90de22908d21 Mon Sep 17 00:00:00 2001 -From: hjl -Date: Mon, 15 Jan 2018 11:27:24 +0000 -Subject: [PATCH 01/13] i386: Move struct ix86_frame to machine_function - -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 - 2017-06-01 Bernd Edlinger - - * 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 8b5faac5129..a1ff32b648b 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -2434,53 +2434,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; - -@@ -2572,7 +2525,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); -@@ -10944,7 +10897,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); - } -@@ -11355,8 +11309,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; -@@ -11395,8 +11349,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; -@@ -12702,7 +12657,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)) - { -@@ -13379,7 +13335,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 -@@ -13876,7 +13833,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 8113f83c7fd..54144166172 100644 ---- a/gcc/config/i386/i386.h -+++ b/gcc/config/i386/i386.h -@@ -2427,9 +2427,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 -@@ -2475,6 +2522,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; -@@ -2554,6 +2604,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 --- -2.16.3 - diff --git a/main/gcc/0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch b/main/gcc/0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch deleted file mode 100644 index 79219e8582..0000000000 --- a/main/gcc/0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch +++ /dev/null @@ -1,69 +0,0 @@ -From b1fc91cda7c15264116f3dde6944ead149123653 Mon Sep 17 00:00:00 2001 -From: hjl -Date: Mon, 15 Jan 2018 11:28:44 +0000 -Subject: [PATCH 02/13] i386: Use reference of struct ix86_frame to avoid copy - -When there is no need to make a copy of ix86_frame, we can use reference -of struct ix86_frame to avoid copy. - - Backport from mainline - 2017-11-06 H.J. Lu - - * 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 | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index a1ff32b648b..13ebf107e90 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -10887,7 +10887,6 @@ symbolic_reference_mentioned_p (rtx op) - bool - ix86_can_use_return_insn_p (void) - { -- struct ix86_frame frame; - - if (! reload_completed || frame_pointer_needed) - return 0; -@@ -10898,7 +10897,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); - } -@@ -11310,7 +11309,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; -@@ -13821,7 +13820,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; -@@ -13834,7 +13832,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 --- -2.16.3 - diff --git a/main/gcc/0002-posix_memalign.patch b/main/gcc/0002-posix_memalign.patch new file mode 100644 index 0000000000..874f49b9b0 --- /dev/null +++ b/main/gcc/0002-posix_memalign.patch @@ -0,0 +1,42 @@ +From 65eb86f3e110998d30489df009d44b4bc1043adc Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Fri, 26 Jan 2018 20:32:50 +0000 +Subject: [PATCH 02/12] posix_memalign + +--- + gcc/config/i386/pmm_malloc.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h +index ffbb7f82cf5..b0b890d2403 100644 +--- a/gcc/config/i386/pmm_malloc.h ++++ b/gcc/config/i386/pmm_malloc.h +@@ -27,12 +27,13 @@ + #include + + /* We can't depend on 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 _mm_posix_memalign (void **, size_t, size_t) + #else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); ++extern "C" int _mm_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 (_mm_posix_memalign (&__ptr, __alignment, __size) == 0) + return __ptr; + else + return NULL; +-- +2.17.1 + diff --git a/main/gcc/0003-gcc-poison-system-directories.patch b/main/gcc/0003-gcc-poison-system-directories.patch new file mode 100644 index 0000000000..05138976c3 --- /dev/null +++ b/main/gcc/0003-gcc-poison-system-directories.patch @@ -0,0 +1,194 @@ +From 48c670d2678e0323d88eb72205e039f393cabe05 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 29 Mar 2013 08:59:00 +0400 +Subject: [PATCH 03/39] gcc: poison-system-directories + +Signed-off-by: Khem Raj + +Upstream-Status: Inappropriate [distribution: codesourcery] +--- + gcc/common.opt | 4 ++++ + gcc/config.in | 6 ++++++ + gcc/configure | 16 ++++++++++++++++ + gcc/configure.ac | 10 ++++++++++ + gcc/doc/invoke.texi | 9 +++++++++ + gcc/gcc.c | 2 ++ + gcc/incpath.c | 19 +++++++++++++++++++ + 7 files changed, 66 insertions(+) + +diff --git a/gcc/common.opt b/gcc/common.opt +index d6ef85928f3..7b29efe3882 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -679,6 +679,10 @@ Wreturn-local-addr + Common Var(warn_return_local_addr) Init(1) Warning + Warn about returning a pointer/reference to a local or temporary variable. + ++Wpoison-system-directories ++Common Var(flag_poison_system_directories) Init(1) Warning ++Warn for -I and -L options using system directories if cross compiling ++ + Wshadow + Common Var(warn_shadow) Warning + Warn when one variable shadows another. Same as -Wshadow=global. +diff --git a/gcc/config.in b/gcc/config.in +index 5bccb408016..1c784a8276b 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -194,6 +194,12 @@ + #endif + + ++/* Define to warn for use of native system header directories */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_POISON_SYSTEM_DIRECTORIES ++#endif ++ ++ + /* Define if you want all operations on RTL (the basic data structure of the + optimizer and back end) to be checked for dynamic type safety at runtime. + This is quite expensive. */ +diff --git a/gcc/configure b/gcc/configure +index 5c345ce0fd7..cafd05fd150 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -953,6 +953,7 @@ with_system_zlib + enable_maintainer_mode + enable_link_mutex + enable_version_specific_runtime_libs ++enable_poison_system_directories + enable_plugin + enable_host_shared + enable_libquadmath_support +@@ -1696,6 +1697,8 @@ Optional Features: + --enable-version-specific-runtime-libs + specify that runtime libraries should be installed + in a compiler-specific directory ++ --enable-poison-system-directories ++ warn for use of native system header directories + --enable-plugin enable plugin support + --enable-host-shared build host code as shared libraries + --disable-libquadmath-support +@@ -29715,6 +29718,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : + fi + + ++# Check whether --enable-poison-system-directories was given. ++if test "${enable_poison_system_directories+set}" = set; then : ++ enableval=$enable_poison_system_directories; ++else ++ enable_poison_system_directories=no ++fi ++ ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ ++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++ ++fi ++ + # Substitute configuration variables + + +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 65dbf1f2f80..dd5b38195ce 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -6341,6 +6341,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, + [specify that runtime libraries should be + installed in a compiler-specific directory])]) + ++AC_ARG_ENABLE([poison-system-directories], ++ AS_HELP_STRING([--enable-poison-system-directories], ++ [warn for use of native system header directories]),, ++ [enable_poison_system_directories=no]) ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], ++ [1], ++ [Define to warn for use of native system header directories]) ++fi ++ + # Substitute configuration variables + AC_SUBST(subdirs) + AC_SUBST(srcdir) +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 255149fcfb8..cb71b60fe3c 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -303,6 +303,7 @@ Objective-C and Objective-C++ Dialects}. + -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded @gol + -Wparentheses -Wno-pedantic-ms-format @gol + -Wplacement-new -Wplacement-new=@var{n} @gol ++-Wno-poison-system-directories @gol + -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol + -Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol + -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol +@@ -5712,6 +5713,14 @@ made up of data only and thus requires no special treatment. But, for + most targets, it is made up of code and thus requires the stack to be + made executable in order for the program to work properly. + ++@item -Wno-poison-system-directories ++@opindex Wno-poison-system-directories ++Do not warn for @option{-I} or @option{-L} options using system ++directories such as @file{/usr/include} when cross compiling. This ++option is intended for use in chroot environments when such ++directories contain the correct headers and libraries for the target ++system rather than the host. ++ + @item -Wfloat-equal + @opindex Wfloat-equal + @opindex Wno-float-equal +diff --git a/gcc/gcc.c b/gcc/gcc.c +index a716f708259..02b3cd39fc2 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1037,6 +1037,8 @@ proper position among the other output files. */ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ ++ %{Wno-poison-system-directories:--no-poison-system-directories} \ ++ %{Werror=poison-system-directories:--error-poison-system-directories} \ + %{static|no-pie|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ +diff --git a/gcc/incpath.c b/gcc/incpath.c +index b11c6a57939..e3b7a21966f 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -26,6 +26,7 @@ + #include "intl.h" + #include "incpath.h" + #include "cppdefault.h" ++#include "diagnostic-core.h" + + /* Microsoft Windows does not natively support inodes. + VMS has non-numeric inodes. */ +@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) + } + fprintf (stderr, _("End of search list.\n")); + } ++ ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES ++ if (flag_poison_system_directories) ++ { ++ struct cpp_dir *p; ++ ++ for (p = heads[INC_QUOTE]; p; p = p->next) ++ { ++ if ((!strncmp (p->name, "/usr/include", 12)) ++ || (!strncmp (p->name, "/usr/local/include", 18)) ++ || (!strncmp (p->name, "/usr/X11R6/include", 18)) ++ || (!strncmp (p->name, "/sw/include", 11)) ++ || (!strncmp (p->name, "/opt/include", 12))) ++ warning (OPT_Wpoison_system_directories, ++ "include location \"%s\" is unsafe for " ++ "cross-compilation", ++ p->name); ++ } ++ } ++#endif + } + + /* Use given -I paths for #include "..." but not #include <...>, and +-- +2.17.0 + diff --git a/main/gcc/0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch b/main/gcc/0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch deleted file mode 100644 index 2f293946ff..0000000000 --- a/main/gcc/0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch +++ /dev/null @@ -1,126 +0,0 @@ -From 3e39c0a8053b3e960cf4c3aea3c814e7dc97cfd6 Mon Sep 17 00:00:00 2001 -From: hjl -Date: Sat, 27 Jan 2018 13:10:24 +0000 -Subject: [PATCH 03/13] i386: Use const reference of struct ix86_frame to avoid - copy - -We can use const reference of struct ix86_frame to avoid making a local -copy of ix86_frame. ix86_expand_epilogue makes a local copy of struct -ix86_frame and uses the reg_save_offset field as a local variable. This -patch uses a separate local variable for reg_save_offset. - -Tested on x86-64 with ada. - - Backport from mainline - PR target/83905 - * config/i386/i386.c (ix86_expand_prologue): Use cost reference - of struct ix86_frame. - (ix86_expand_epilogue): Likewise. Add a local variable for - the reg_save_offset field in struct ix86_frame. - -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257123 138bc75d-0d04-0410-961f-82ee72b054a4 ---- - gcc/config/i386/i386.c | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index 13ebf107e90..6c98f7581e2 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -12633,7 +12633,6 @@ ix86_expand_prologue (void) - { - struct machine_function *m = cfun->machine; - rtx insn, t; -- struct ix86_frame frame; - HOST_WIDE_INT allocate; - bool int_registers_saved; - bool sse_registers_saved; -@@ -12657,7 +12656,7 @@ ix86_expand_prologue (void) - m->fs.sp_valid = true; - - ix86_compute_frame_layout (); -- frame = m->frame; -+ const struct ix86_frame &frame = cfun->machine->frame; - - if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl)) - { -@@ -13329,13 +13328,12 @@ ix86_expand_epilogue (int style) - { - struct machine_function *m = cfun->machine; - struct machine_frame_state frame_state_save = m->fs; -- struct ix86_frame frame; - bool restore_regs_via_mov; - bool using_drap; - - ix86_finalize_stack_realign_flags (); - ix86_compute_frame_layout (); -- frame = m->frame; -+ const struct ix86_frame &frame = cfun->machine->frame; - - m->fs.sp_valid = (!frame_pointer_needed - || (crtl->sp_is_unchanging -@@ -13377,11 +13375,13 @@ ix86_expand_epilogue (int style) - + UNITS_PER_WORD); - } - -+ HOST_WIDE_INT reg_save_offset = frame.reg_save_offset; -+ - /* Special care must be taken for the normal return case of a function - using eh_return: the eax and edx registers are marked as saved, but - not restored along this path. Adjust the save location to match. */ - if (crtl->calls_eh_return && style != 2) -- frame.reg_save_offset -= 2 * UNITS_PER_WORD; -+ reg_save_offset -= 2 * UNITS_PER_WORD; - - /* EH_RETURN requires the use of moves to function properly. */ - if (crtl->calls_eh_return) -@@ -13397,11 +13397,11 @@ ix86_expand_epilogue (int style) - else if (TARGET_EPILOGUE_USING_MOVE - && cfun->machine->use_fast_prologue_epilogue - && (frame.nregs > 1 -- || m->fs.sp_offset != frame.reg_save_offset)) -+ || m->fs.sp_offset != reg_save_offset)) - restore_regs_via_mov = true; - else if (frame_pointer_needed - && !frame.nregs -- && m->fs.sp_offset != frame.reg_save_offset) -+ && m->fs.sp_offset != reg_save_offset) - restore_regs_via_mov = true; - else if (frame_pointer_needed - && TARGET_USE_LEAVE -@@ -13439,7 +13439,7 @@ ix86_expand_epilogue (int style) - rtx t; - - if (frame.nregs) -- ix86_emit_restore_regs_using_mov (frame.reg_save_offset, style == 2); -+ ix86_emit_restore_regs_using_mov (reg_save_offset, style == 2); - - /* eh_return epilogues need %ecx added to the stack pointer. */ - if (style == 2) -@@ -13529,19 +13529,19 @@ ix86_expand_epilogue (int style) - epilogues. */ - if (!m->fs.sp_valid - || (TARGET_SEH -- && (m->fs.sp_offset - frame.reg_save_offset -+ && (m->fs.sp_offset - reg_save_offset - >= SEH_MAX_FRAME_SIZE))) - { - pro_epilogue_adjust_stack (stack_pointer_rtx, hard_frame_pointer_rtx, - GEN_INT (m->fs.fp_offset -- - frame.reg_save_offset), -+ - reg_save_offset), - style, false); - } -- else if (m->fs.sp_offset != frame.reg_save_offset) -+ else if (m->fs.sp_offset != reg_save_offset) - { - pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, - GEN_INT (m->fs.sp_offset -- - frame.reg_save_offset), -+ - reg_save_offset), - style, - m->fs.cfa_reg == stack_pointer_rtx); - } --- -2.16.3 - diff --git a/main/gcc/0004-x86-Add-mindirect-branch.patch b/main/gcc/0004-x86-Add-mindirect-branch.patch deleted file mode 100644 index db5fe2f48b..0000000000 --- a/main/gcc/0004-x86-Add-mindirect-branch.patch +++ /dev/null @@ -1,2149 +0,0 @@ -From 64da0f4b794672ae14350b09c276422f79f78fc0 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sat, 6 Jan 2018 22:29:55 -0800 -Subject: [PATCH 04/13] 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 - 2018-01-14 H.J. Lu - - * 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. - -gcc/testsuite/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * gcc.target/i386/indirect-thunk-1.c: New test. - * gcc.target/i386/indirect-thunk-2.c: Likewise. - * gcc.target/i386/indirect-thunk-3.c: Likewise. - * gcc.target/i386/indirect-thunk-4.c: Likewise. - * gcc.target/i386/indirect-thunk-5.c: Likewise. - * gcc.target/i386/indirect-thunk-6.c: Likewise. - * gcc.target/i386/indirect-thunk-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-8.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-1.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-3.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-5.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-6.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-5.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-6.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. ---- - gcc/config/i386/i386-opts.h | 13 + - gcc/config/i386/i386-protos.h | 1 + - gcc/config/i386/i386.c | 639 ++++++++++++++++++++- - 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 | 13 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 20 + - gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 20 + - gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 21 + - gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 21 + - gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 17 + - gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 18 + - gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 44 ++ - .../gcc.target/i386/indirect-thunk-attr-1.c | 23 + - .../gcc.target/i386/indirect-thunk-attr-2.c | 21 + - .../gcc.target/i386/indirect-thunk-attr-3.c | 23 + - .../gcc.target/i386/indirect-thunk-attr-4.c | 22 + - .../gcc.target/i386/indirect-thunk-attr-5.c | 22 + - .../gcc.target/i386/indirect-thunk-attr-6.c | 21 + - .../gcc.target/i386/indirect-thunk-attr-7.c | 44 ++ - .../gcc.target/i386/indirect-thunk-attr-8.c | 42 ++ - .../gcc.target/i386/indirect-thunk-bnd-1.c | 20 + - .../gcc.target/i386/indirect-thunk-bnd-2.c | 21 + - .../gcc.target/i386/indirect-thunk-bnd-3.c | 19 + - .../gcc.target/i386/indirect-thunk-bnd-4.c | 20 + - .../gcc.target/i386/indirect-thunk-extern-1.c | 19 + - .../gcc.target/i386/indirect-thunk-extern-2.c | 19 + - .../gcc.target/i386/indirect-thunk-extern-3.c | 20 + - .../gcc.target/i386/indirect-thunk-extern-4.c | 20 + - .../gcc.target/i386/indirect-thunk-extern-5.c | 16 + - .../gcc.target/i386/indirect-thunk-extern-6.c | 17 + - .../gcc.target/i386/indirect-thunk-extern-7.c | 43 ++ - .../gcc.target/i386/indirect-thunk-inline-1.c | 20 + - .../gcc.target/i386/indirect-thunk-inline-2.c | 20 + - .../gcc.target/i386/indirect-thunk-inline-3.c | 21 + - .../gcc.target/i386/indirect-thunk-inline-4.c | 21 + - .../gcc.target/i386/indirect-thunk-inline-5.c | 17 + - .../gcc.target/i386/indirect-thunk-inline-6.c | 18 + - .../gcc.target/i386/indirect-thunk-inline-7.c | 44 ++ - 41 files changed, 1486 insertions(+), 17 deletions(-) - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-5.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-6.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-7.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c - -diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h -index b7f92e3bea1..cc21152875f 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 ff47bc15600..eca4cbf0776 100644 ---- a/gcc/config/i386/i386-protos.h -+++ b/gcc/config/i386/i386-protos.h -@@ -311,6 +311,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 6c98f7581e2..0b9fc4d3026 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -3662,12 +3662,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 -@@ -6350,6 +6361,37 @@ ix86_reset_previous_fndecl (void) - ix86_previous_fndecl = NULL_TREE; - } - -+/* 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. */ -@@ -6360,7 +6402,13 @@ ix86_set_current_function (tree fndecl) - several times in the course of compiling a function, and we don't want to - slow things down too much or call target_reinit when it isn't safe. */ - if (fndecl == ix86_previous_fndecl) -- return; -+ { -+ /* There may be 2 function bodies for the same function FNDECL, -+ one is extern inline and one isn't. */ -+ if (fndecl != NULL_TREE) -+ ix86_set_indirect_branch_type (fndecl); -+ return; -+ } - - tree old_tree; - if (ix86_previous_fndecl == NULL_TREE) -@@ -6377,6 +6425,8 @@ ix86_set_current_function (tree fndecl) - return; - } - -+ ix86_set_indirect_branch_type (fndecl); -+ - tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); - if (new_tree == NULL_TREE) - new_tree = target_option_default_node; -@@ -10962,6 +11012,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 -@@ -10988,11 +11252,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; - -@@ -27369,12 +27654,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; - -@@ -27383,7 +27948,13 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op) - if (direct_p) - { - if (ix86_nopic_noplt_attribute_p (call_op)) -- xasm = "%!jmp\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}"; -+ { -+ direct_p = false; -+ 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"; - } -@@ -27392,9 +27963,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 ""; - } - -@@ -27431,14 +28010,28 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op) - if (direct_p) - { - if (ix86_nopic_noplt_attribute_p (call_op)) -- xasm = "%!call\t{*%p0@GOTPCREL(%%rip)|[QWORD PTR %p0@GOTPCREL[rip]]}"; -+ { -+ direct_p = false; -+ 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"; - } - 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"; -@@ -44836,7 +45429,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) -@@ -44845,6 +45438,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; - } - -@@ -49072,6 +49688,9 @@ static const struct attribute_spec ix86_attribute_table[] = - false }, - { "callee_pop_aggregate_return", 1, 1, false, true, true, - ix86_handle_callee_pop_aggregate_return, true }, -+ { "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 54144166172..9dccdb0351e 100644 ---- a/gcc/config/i386/i386.h -+++ b/gcc/config/i386/i386.h -@@ -2572,6 +2572,13 @@ struct GTY(()) machine_function { - /* If true, it is safe to not save/restore DRAP register. */ - BOOL_BITFIELD no_drap_save_restore : 1; - -+ /* 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, there is register available for argument passing. This - is used only in ix86_function_ok_for_sibcall by 32-bit to determine - if there is scratch register available for indirect sibcall. In -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md -index d2bfe314f71..153e1622b2d 100644 ---- a/gcc/config/i386/i386.md -+++ b/gcc/config/i386/i386.md -@@ -11807,13 +11807,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")]) - -@@ -11856,14 +11861,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")]) - -@@ -12520,8 +12530,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 f304b621e6a..5ffa3349a30 100644 ---- a/gcc/config/i386/i386.opt -+++ b/gcc/config/i386/i386.opt -@@ -897,3 +897,23 @@ Enum(stack_protector_guard) String(global) Value(SSP_GLOBAL) - mmitigate-rop - Target Var(flag_mitigate_rop) Init(0) - Attempt to avoid generating instruction sequences containing ret bytes. -+ -+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 8cc4f7e1f6a..8668dae9e99 100644 ---- a/gcc/doc/extend.texi -+++ b/gcc/doc/extend.texi -@@ -5419,6 +5419,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 1d3a824d7b8..6f60339a56a 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -1169,7 +1169,7 @@ 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} -+-mmitigate-rop -mindirect-branch=@var{choice}} - - @emph{x86 Windows Options} - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol -@@ -24230,6 +24230,17 @@ opcodes, to mitigate against certain forms of attack. At the moment, - this option is limited in what it can do and should not be relied - on to provide serious protection. - -+@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/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -new file mode 100644 -index 00000000000..d983e1c3e26 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -new file mode 100644 -index 00000000000..58f09b42d8a ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -new file mode 100644 -index 00000000000..f20d35c19b6 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -new file mode 100644 -index 00000000000..0eff8fb658a ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -new file mode 100644 -index 00000000000..a25b20dd808 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -@@ -0,0 +1,17 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk" } */ -+ -+extern void bar (void); -+ -+void -+foo (void) -+{ -+ bar (); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -new file mode 100644 -index 00000000000..cff114a6c29 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -@@ -0,0 +1,18 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk" } */ -+ -+extern void bar (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -new file mode 100644 -index 00000000000..afdb6007986 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -@@ -0,0 +1,44 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+void func0 (void); -+void func1 (void); -+void func2 (void); -+void func3 (void); -+void func4 (void); -+void func4 (void); -+void func5 (void); -+ -+void -+bar (int i) -+{ -+ switch (i) -+ { -+ default: -+ func0 (); -+ break; -+ case 1: -+ func1 (); -+ break; -+ case 2: -+ func2 (); -+ break; -+ case 3: -+ func3 (); -+ break; -+ case 4: -+ func4 (); -+ break; -+ case 5: -+ func5 (); -+ break; -+ } -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -new file mode 100644 -index 00000000000..d64d978b699 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -@@ -0,0 +1,23 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+extern void male_indirect_jump (long) -+ __attribute__ ((indirect_branch("thunk"))); -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -new file mode 100644 -index 00000000000..93067454d3d ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+__attribute__ ((indirect_branch("thunk"))) -+void -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -new file mode 100644 -index 00000000000..97744d65729 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -@@ -0,0 +1,23 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+extern int male_indirect_jump (long) -+ __attribute__ ((indirect_branch("thunk-inline"))); -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -new file mode 100644 -index 00000000000..bfce3ea5cb2 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+__attribute__ ((indirect_branch("thunk-inline"))) -+int -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -new file mode 100644 -index 00000000000..0833606046b ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+extern int male_indirect_jump (long) -+ __attribute__ ((indirect_branch("thunk-extern"))); -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -new file mode 100644 -index 00000000000..2eba0fbd9b2 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+__attribute__ ((indirect_branch("thunk-extern"))) -+int -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -new file mode 100644 -index 00000000000..f58427eae11 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -@@ -0,0 +1,44 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fno-pic" } */ -+ -+void func0 (void); -+void func1 (void); -+void func2 (void); -+void func3 (void); -+void func4 (void); -+void func4 (void); -+void func5 (void); -+ -+__attribute__ ((indirect_branch("thunk-extern"))) -+void -+bar (int i) -+{ -+ switch (i) -+ { -+ default: -+ func0 (); -+ break; -+ case 1: -+ func1 (); -+ break; -+ case 2: -+ func2 (); -+ break; -+ case 3: -+ func3 (); -+ break; -+ case 4: -+ func4 (); -+ break; -+ case 5: -+ func5 (); -+ break; -+ } -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c -new file mode 100644 -index 00000000000..564ed39547c ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c -@@ -0,0 +1,42 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+ -+void func0 (void); -+void func1 (void); -+void func2 (void); -+void func3 (void); -+void func4 (void); -+void func4 (void); -+void func5 (void); -+ -+__attribute__ ((indirect_branch("keep"))) -+void -+bar (int i) -+{ -+ switch (i) -+ { -+ default: -+ func0 (); -+ break; -+ case 1: -+ func1 (); -+ break; -+ case 2: -+ func2 (); -+ break; -+ case 3: -+ func3 (); -+ break; -+ case 4: -+ func4 (); -+ break; -+ case 5: -+ func5 (); -+ break; -+ } -+} -+ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -new file mode 100644 -index 00000000000..50fbee20a5a ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile { target { ! x32 } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+ -+void (*dispatch) (char *); -+char buf[10]; -+ -+void -+foo (void) -+{ -+ dispatch (buf); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd ret" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -new file mode 100644 -index 00000000000..2976e67adce ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile { target { ! x32 } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+ -+void (*dispatch) (char *); -+char buf[10]; -+ -+int -+foo (void) -+{ -+ dispatch (buf); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd ret" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -new file mode 100644 -index 00000000000..da4bc98ef23 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -@@ -0,0 +1,19 @@ -+/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+ -+void bar (char *); -+char buf[10]; -+ -+void -+foo (void) -+{ -+ bar (buf); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "bnd ret" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -new file mode 100644 -index 00000000000..c64d12ef989 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+ -+void bar (char *); -+char buf[10]; -+ -+int -+foo (void) -+{ -+ bar (buf); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-times "bnd call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler "bnd ret" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -new file mode 100644 -index 00000000000..49f27b49465 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -@@ -0,0 +1,19 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -new file mode 100644 -index 00000000000..a1e3eb6fc74 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -@@ -0,0 +1,19 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -new file mode 100644 -index 00000000000..395634e7e5c ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -new file mode 100644 -index 00000000000..fd3f63379a1 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -new file mode 100644 -index 00000000000..ba2f92b6f34 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -@@ -0,0 +1,16 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+ -+extern void bar (void); -+ -+void -+foo (void) -+{ -+ bar (); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -new file mode 100644 -index 00000000000..0c5a2d472c6 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -@@ -0,0 +1,17 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+ -+extern void bar (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -new file mode 100644 -index 00000000000..665252327aa ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -@@ -0,0 +1,43 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+void func0 (void); -+void func1 (void); -+void func2 (void); -+void func3 (void); -+void func4 (void); -+void func4 (void); -+void func5 (void); -+ -+void -+bar (int i) -+{ -+ switch (i) -+ { -+ default: -+ func0 (); -+ break; -+ case 1: -+ func1 (); -+ break; -+ case 2: -+ func2 (); -+ break; -+ case 3: -+ func3 (); -+ break; -+ case 4: -+ func4 (); -+ break; -+ case 5: -+ func5 (); -+ break; -+ } -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -new file mode 100644 -index 00000000000..68c0ff713b3 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -new file mode 100644 -index 00000000000..e2da1fcb683 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -new file mode 100644 -index 00000000000..244fec708d6 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -new file mode 100644 -index 00000000000..107ebe32f54 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -@@ -0,0 +1,21 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch[256]; -+ -+int -+male_indirect_jump (long offset) -+{ -+ dispatch[offset](offset); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -new file mode 100644 -index 00000000000..17b04ef2229 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -@@ -0,0 +1,17 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+ -+extern void bar (void); -+ -+void -+foo (void) -+{ -+ bar (); -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -new file mode 100644 -index 00000000000..d9eb11285aa ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -@@ -0,0 +1,18 @@ -+/* { dg-do compile { target *-*-linux* } } */ -+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+ -+extern void bar (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -new file mode 100644 -index 00000000000..d02b1dcb1b9 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -@@ -0,0 +1,44 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+void func0 (void); -+void func1 (void); -+void func2 (void); -+void func3 (void); -+void func4 (void); -+void func4 (void); -+void func5 (void); -+ -+void -+bar (int i) -+{ -+ switch (i) -+ { -+ default: -+ func0 (); -+ break; -+ case 1: -+ func1 (); -+ break; -+ case 2: -+ func2 (); -+ break; -+ case 3: -+ func3 (); -+ break; -+ case 4: -+ func4 (); -+ break; -+ case 5: -+ func5 (); -+ break; -+ } -+} -+ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ --- -2.16.3 - diff --git a/main/gcc/0005-x86-Add-mfunction-return.patch b/main/gcc/0005-x86-Add-mfunction-return.patch deleted file mode 100644 index f311d06780..0000000000 --- a/main/gcc/0005-x86-Add-mfunction-return.patch +++ /dev/null @@ -1,1565 +0,0 @@ -From 3b946bffc536481a484d9a2b98b829f3d71b5519 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sat, 6 Jan 2018 22:29:56 -0800 -Subject: [PATCH 05/13] 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 - --mindirect-branch= tests are updated with -mfunction-return=keep to -avoid false test failures when -mfunction-return=thunk is added to -RUNTESTFLAGS for "make check". - -gcc/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * 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. - -gcc/testsuite/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * gcc.target/i386/indirect-thunk-1.c (dg-options): Add - -mfunction-return=keep. - * gcc.target/i386/indirect-thunk-2.c: Likewise. - * gcc.target/i386/indirect-thunk-3.c: Likewise. - * gcc.target/i386/indirect-thunk-4.c: Likewise. - * gcc.target/i386/indirect-thunk-5.c: Likewise. - * gcc.target/i386/indirect-thunk-6.c: Likewise. - * gcc.target/i386/indirect-thunk-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-8.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-1.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-3.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-5.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-6.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-5.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-6.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. - * gcc.target/i386/ret-thunk-1.c: New test. - * gcc.target/i386/ret-thunk-10.c: Likewise. - * gcc.target/i386/ret-thunk-11.c: Likewise. - * gcc.target/i386/ret-thunk-12.c: Likewise. - * gcc.target/i386/ret-thunk-13.c: Likewise. - * gcc.target/i386/ret-thunk-14.c: Likewise. - * gcc.target/i386/ret-thunk-15.c: Likewise. - * gcc.target/i386/ret-thunk-16.c: Likewise. - * gcc.target/i386/ret-thunk-2.c: Likewise. - * gcc.target/i386/ret-thunk-3.c: Likewise. - * gcc.target/i386/ret-thunk-4.c: Likewise. - * gcc.target/i386/ret-thunk-5.c: Likewise. - * gcc.target/i386/ret-thunk-6.c: Likewise. - * gcc.target/i386/ret-thunk-7.c: Likewise. - * gcc.target/i386/ret-thunk-8.c: Likewise. - * gcc.target/i386/ret-thunk-9.c: Likewise. - -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 - - 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. - -gcc/testsuite/ - - Backport from mainline - 2018-01-15 H.J. Lu - - PR target/83839 - * gcc.target/i386/indirect-thunk-1.c: Scan for "push" only on - Linux. - * gcc.target/i386/indirect-thunk-2.c: Likewise. - * gcc.target/i386/indirect-thunk-3.c: Likewise. - * gcc.target/i386/indirect-thunk-4.c: Likewise. - * gcc.target/i386/indirect-thunk-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. - * gcc.target/i386/indirect-thunk-register-1.c: Likewise. - * gcc.target/i386/indirect-thunk-register-3.c: Likewise. - * gcc.target/i386/indirect-thunk-register-4.c: Likewise. - * gcc.target/i386/ret-thunk-10.c: Likewise. - * gcc.target/i386/ret-thunk-11.c: Likewise. - * gcc.target/i386/ret-thunk-12.c: Likewise. - * gcc.target/i386/ret-thunk-13.c: Likewise. - * gcc.target/i386/ret-thunk-14.c: Likewise. - * gcc.target/i386/ret-thunk-15.c: Likewise. - * gcc.target/i386/ret-thunk-9.c: Don't check the - __x86_return_thunk label. - Scan for "push" only for Linux. ---- - 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 | 14 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 4 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 4 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 4 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 4 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-1.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-2.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-3.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-4.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-5.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-6.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-7.c | 4 +- - .../gcc.target/i386/indirect-thunk-attr-8.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-1.c | 4 +- - .../gcc.target/i386/indirect-thunk-bnd-2.c | 4 +- - .../gcc.target/i386/indirect-thunk-bnd-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-1.c | 4 +- - .../gcc.target/i386/indirect-thunk-extern-2.c | 4 +- - .../gcc.target/i386/indirect-thunk-extern-3.c | 4 +- - .../gcc.target/i386/indirect-thunk-extern-4.c | 4 +- - .../gcc.target/i386/indirect-thunk-extern-5.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-6.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-7.c | 4 +- - .../gcc.target/i386/indirect-thunk-inline-1.c | 4 +- - .../gcc.target/i386/indirect-thunk-inline-2.c | 4 +- - .../gcc.target/i386/indirect-thunk-inline-3.c | 4 +- - .../gcc.target/i386/indirect-thunk-inline-4.c | 4 +- - .../gcc.target/i386/indirect-thunk-inline-5.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-6.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-7.c | 4 +- - gcc/testsuite/gcc.target/i386/ret-thunk-1.c | 13 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 23 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 23 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 22 +++ - gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 22 +++ - gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 22 +++ - gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 22 +++ - gcc/testsuite/gcc.target/i386/ret-thunk-16.c | 18 +++ - gcc/testsuite/gcc.target/i386/ret-thunk-2.c | 13 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-3.c | 12 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-4.c | 12 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-5.c | 15 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-6.c | 14 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-7.c | 13 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-8.c | 14 ++ - gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 24 ++++ - 56 files changed, 516 insertions(+), 74 deletions(-) - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-10.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-11.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-12.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-13.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-14.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-15.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-16.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-3.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-4.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-5.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-6.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-7.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-8.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-9.c - -diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h -index eca4cbf0776..620d70ef9f6 100644 ---- a/gcc/config/i386/i386-protos.h -+++ b/gcc/config/i386/i386-protos.h -@@ -312,6 +312,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 0b9fc4d3026..34e26a3a3c7 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -6390,6 +6390,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 -@@ -11036,8 +11061,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" : ""; -@@ -11052,7 +11081,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 - { -@@ -11065,10 +11097,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); -+ } - } - } - } -@@ -11163,7 +11205,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)); -@@ -11206,6 +11248,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); -@@ -27687,7 +27759,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 -@@ -27796,7 +27868,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 -@@ -27931,6 +28003,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 * -@@ -45461,6 +45573,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; - } - -@@ -49690,6 +49824,8 @@ static const struct attribute_spec ix86_attribute_table[] = - ix86_handle_callee_pop_aggregate_return, true }, - { "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 9dccdb0351e..b34bc117c34 100644 ---- a/gcc/config/i386/i386.h -+++ b/gcc/config/i386/i386.h -@@ -2579,6 +2579,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, there is register available for argument passing. This - is used only in ix86_function_ok_for_sibcall by 32-bit to determine - if there is scratch register available for indirect sibcall. In -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md -index 153e1622b2d..2da671e9f2d 100644 ---- a/gcc/config/i386/i386.md -+++ b/gcc/config/i386/i386.md -@@ -12489,7 +12489,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") -@@ -12503,12 +12503,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 5ffa3349a30..ad5916fb643 100644 ---- a/gcc/config/i386/i386.opt -+++ b/gcc/config/i386/i386.opt -@@ -902,9 +902,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 8668dae9e99..2cb6bd1ef3e 100644 ---- a/gcc/doc/extend.texi -+++ b/gcc/doc/extend.texi -@@ -5429,6 +5429,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 6f60339a56a..337a761015a 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -1169,7 +1169,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 -mindirect-branch=@var{choice}} -+-mmitigate-rop -mindirect-branch=@var{choice} @gol -+-mfunction-return=@var{choice}} - - @emph{x86 Windows Options} - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol -@@ -24241,6 +24242,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/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -index d983e1c3e26..e365ef5698a 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -index 58f09b42d8a..05a51ad9157 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -index f20d35c19b6..3c0d4c39f0b 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -index 0eff8fb658a..14d4ef6dd98 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -index a25b20dd808..b4836c38d6c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -index cff114a6c29..1f06bd1af74 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -index afdb6007986..bc6b47a636e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - void func0 (void); - void func1 (void); -@@ -35,7 +35,7 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -index d64d978b699..2257be3affa 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -14,7 +14,7 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -index 93067454d3d..e9cfdc5879e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -index 97744d65729..f938db050f7 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -14,7 +14,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -index bfce3ea5cb2..4e58599692a 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -13,7 +13,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -index 0833606046b..b8d50249d8b 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -14,7 +14,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -index 2eba0fbd9b2..455adabfe0e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -13,7 +13,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -index f58427eae11..4595b841ec0 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ - - void func0 (void); - void func1 (void); -@@ -36,7 +36,7 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c -index 564ed39547c..d730d31bda1 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - void func0 (void); - void func1 (void); -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -index 50fbee20a5a..5e3e118e9bd 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! x32 } } } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - - void (*dispatch) (char *); - char buf[10]; -@@ -10,7 +10,7 @@ foo (void) - dispatch (buf); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ - /* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -index 2976e67adce..2801aa4192e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! x32 } } } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - - void (*dispatch) (char *); - char buf[10]; -@@ -11,7 +11,7 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ - /* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ - /* { dg-final { scan-assembler "bnd jmp\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -index da4bc98ef23..70b4fb36eea 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - - void bar (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -index c64d12ef989..3baf03ee77c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ --/* { dg-options "-O2 -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - - void bar (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -index 49f27b49465..edeb264218c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -index a1e3eb6fc74..1d00413a76a 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -index 395634e7e5c..06ebf1c9063 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -index fd3f63379a1..1c8f9446636 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -index ba2f92b6f34..21740ac5b7f 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -index 0c5a2d472c6..a77c1f470b8 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -index 665252327aa..86e9fd1f1e4 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - void func0 (void); - void func1 (void); -@@ -35,7 +35,7 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -index 68c0ff713b3..3ecde878867 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -index e2da1fcb683..df32a19a2b5 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -index 244fec708d6..9540996de01 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -index 107ebe32f54..f3db6e2441f 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -index 17b04ef2229..0f687c3b027 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -index d9eb11285aa..b27c6fc96a2 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -index d02b1dcb1b9..764a375fc37 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - void func0 (void); - void func1 (void); -@@ -35,7 +35,7 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-1.c b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c -new file mode 100644 -index 00000000000..7223f67ba5e ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c -@@ -0,0 +1,13 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk" } */ -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -new file mode 100644 -index 00000000000..3a6727b5c54 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -@@ -0,0 +1,23 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 2 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -new file mode 100644 -index 00000000000..b8f68188313 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -@@ -0,0 +1,23 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -new file mode 100644 -index 00000000000..01b0a02f80b ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -new file mode 100644 -index 00000000000..4b497b5f8af ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+ -+extern void (*bar) (void); -+extern int foo (void) __attribute__ ((function_return("thunk"))); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 2 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 3 } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 3 } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -new file mode 100644 -index 00000000000..4ae4c44a3fd ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+__attribute__ ((function_return("thunk-inline"))) -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -new file mode 100644 -index 00000000000..5b5bc765a7e ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+__attribute__ ((function_return("thunk-extern"), indirect_branch("thunk"))) -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-16.c b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c -new file mode 100644 -index 00000000000..a16cad16aaa ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c -@@ -0,0 +1,18 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk-extern -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+__attribute__ ((function_return("keep"), indirect_branch("keep"))) -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler-not "__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-2.c b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c -new file mode 100644 -index 00000000000..c6659e3ad09 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c -@@ -0,0 +1,13 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */ -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-3.c b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c -new file mode 100644 -index 00000000000..0f7f388f459 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c -@@ -0,0 +1,12 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */ -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-4.c b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c -new file mode 100644 -index 00000000000..9ae37e835a0 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c -@@ -0,0 +1,12 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep" } */ -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-5.c b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c -new file mode 100644 -index 00000000000..4bd0d2a27bc ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c -@@ -0,0 +1,15 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep" } */ -+ -+extern void foo (void) __attribute__ ((function_return("thunk"))); -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-6.c b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c -new file mode 100644 -index 00000000000..053841f6f7d ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c -@@ -0,0 +1,14 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep" } */ -+ -+__attribute__ ((function_return("thunk-inline"))) -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-7.c b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c -new file mode 100644 -index 00000000000..262e6780112 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c -@@ -0,0 +1,13 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=keep" } */ -+ -+__attribute__ ((function_return("thunk-extern"))) -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-8.c b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c -new file mode 100644 -index 00000000000..c1658e96673 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c -@@ -0,0 +1,14 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */ -+ -+extern void foo (void) __attribute__ ((function_return("keep"))); -+ -+void -+foo (void) -+{ -+} -+ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -new file mode 100644 -index 00000000000..fa24a1f7365 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -@@ -0,0 +1,24 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */ -+ -+extern void (*bar) (void); -+ -+int -+foo (void) -+{ -+ bar (); -+ return 0; -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */ -+/* { dg-final { scan-assembler-times {\tpause} 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times {\tpause} 2 { target { x32 } } } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 2 { target { x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ --- -2.16.3 - diff --git a/main/gcc/0006-x86-Add-mindirect-branch-register.patch b/main/gcc/0006-x86-Add-mindirect-branch-register.patch deleted file mode 100644 index 111e6e43d4..0000000000 --- a/main/gcc/0006-x86-Add-mindirect-branch-register.patch +++ /dev/null @@ -1,941 +0,0 @@ -From 61bb7f0e152ce5be700a44007d036ea0de4b254d Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sat, 6 Jan 2018 22:29:56 -0800 -Subject: [PATCH 06/13] 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 - - * 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. - -gcc/testsuite/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * gcc.target/i386/indirect-thunk-1.c (dg-options): Add - -mno-indirect-branch-register. - * gcc.target/i386/indirect-thunk-2.c: Likewise. - * gcc.target/i386/indirect-thunk-3.c: Likewise. - * gcc.target/i386/indirect-thunk-4.c: Likewise. - * gcc.target/i386/indirect-thunk-5.c: Likewise. - * gcc.target/i386/indirect-thunk-6.c: Likewise. - * gcc.target/i386/indirect-thunk-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-1.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-3.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-5.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-6.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-5.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-6.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. - * gcc.target/i386/ret-thunk-10.c: Likewise. - * gcc.target/i386/ret-thunk-11.c: Likewise. - * gcc.target/i386/ret-thunk-12.c: Likewise. - * gcc.target/i386/ret-thunk-13.c: Likewise. - * gcc.target/i386/ret-thunk-14.c: Likewise. - * gcc.target/i386/ret-thunk-15.c: Likewise. - * gcc.target/i386/ret-thunk-9.c: Likewise. - * gcc.target/i386/indirect-thunk-register-1.c: New test. - * gcc.target/i386/indirect-thunk-register-2.c: Likewise. - * gcc.target/i386/indirect-thunk-register-3.c: Likewise. - -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 - - * 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 - - * 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 - - * 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 - - * config/i386/predicates.md (indirect_branch_operand): Rewrite - ix86_indirect_branch_register logic. ---- - 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 | 6 +++- - gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 2 +- - gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-1.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-2.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-5.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-6.c | 2 +- - .../gcc.target/i386/indirect-thunk-attr-7.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-1.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-2.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-bnd-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-1.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-2.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-5.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-6.c | 2 +- - .../gcc.target/i386/indirect-thunk-extern-7.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-1.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-2.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-5.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-6.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-7.c | 2 +- - .../gcc.target/i386/indirect-thunk-register-1.c | 22 ++++++++++++++ - .../gcc.target/i386/indirect-thunk-register-2.c | 20 +++++++++++++ - .../gcc.target/i386/indirect-thunk-register-3.c | 19 ++++++++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 2 +- - gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +- - 47 files changed, 147 insertions(+), 63 deletions(-) - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c - -diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md -index 1a4c701ad13..9204c8e8487 100644 ---- a/gcc/config/i386/constraints.md -+++ b/gcc/config/i386/constraints.md -@@ -172,14 +172,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 2da671e9f2d..05a88fff356 100644 ---- a/gcc/config/i386/i386.md -+++ b/gcc/config/i386/i386.md -@@ -11805,7 +11805,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; - }) -@@ -11859,7 +11859,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; - }) -@@ -12048,7 +12048,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")]) - -@@ -12057,7 +12057,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)) -@@ -12070,7 +12072,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) -@@ -12092,7 +12096,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) -@@ -12112,7 +12116,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) -@@ -12166,7 +12170,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 -@@ -12244,7 +12250,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")]) - -@@ -12254,7 +12260,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) -@@ -12269,7 +12277,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) -@@ -12294,7 +12304,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 ad5916fb643..a97f84f68f2 100644 ---- a/gcc/config/i386/i386.opt -+++ b/gcc/config/i386/i386.opt -@@ -921,3 +921,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 93dda7bb0e7..d1f0a7dbf61 100644 ---- a/gcc/config/i386/predicates.md -+++ b/gcc/config/i386/predicates.md -@@ -593,7 +593,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. -@@ -636,20 +637,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 337a761015a..94374661f2d 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -1170,7 +1170,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 -mindirect-branch=@var{choice} @gol ---mfunction-return=@var{choice}} -+-mfunction-return=@var{choice} -mindirect-branch-register} - - @emph{x86 Windows Options} - @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol -@@ -24253,6 +24253,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/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -index e365ef5698a..60d09881a99 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -index 05a51ad9157..aac75163794 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -index 3c0d4c39f0b..9e24a385387 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -index 14d4ef6dd98..127b5d94523 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -index b4836c38d6c..fcaa18d10b7 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -index 1f06bd1af74..e4649283d10 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -index bc6b47a636e..17c2d0faf88 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - void func0 (void); - void func1 (void); -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -index 2257be3affa..9194ccf3cbc 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -index e9cfdc5879e..e51f261a612 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -index f938db050f7..4aeec1833cd 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -index 4e58599692a..ac0e5999f63 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -index b8d50249d8b..573cf1ef09e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -index 455adabfe0e..b2b37fc6e2e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -index 4595b841ec0..4a43e199931 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ - - void func0 (void); - void func1 (void); -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -index 5e3e118e9bd..ac84ab623fa 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! x32 } } } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - - void (*dispatch) (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -index 2801aa4192e..ce655e8be1c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! x32 } } } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - - void (*dispatch) (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -index 70b4fb36eea..d34485a0010 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - - void bar (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -index 3baf03ee77c..0e19830de4d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - - void bar (char *); - char buf[10]; -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -index edeb264218c..579441f250e 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -index 1d00413a76a..c92e6f2b02d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -index 06ebf1c9063..d9964c25bbd 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -index 1c8f9446636..d4dca4dc5fe 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -index 21740ac5b7f..5c07e02df6a 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -index a77c1f470b8..3eb440693a0 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-extern" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -index 86e9fd1f1e4..aece9383697 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - void func0 (void); - void func1 (void); -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -index 3ecde878867..3aba5e8c81f 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -index df32a19a2b5..0f0181d6672 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -index 9540996de01..2eef6f35a75 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -index f3db6e2441f..e825a10f14c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - typedef void (*dispatch_t)(long offset); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -index 0f687c3b027..c6d77e10352 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -index b27c6fc96a2..6454827b780 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target *-*-linux* } } */ --/* { dg-options "-O2 -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fpic -fno-plt -mindirect-branch=thunk-inline" } */ - - extern void bar (void); - -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -index 764a375fc37..c67066cf197 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - void func0 (void); - void func1 (void); -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c -new file mode 100644 -index 00000000000..7d396a31953 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c -@@ -0,0 +1,22 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c -new file mode 100644 -index 00000000000..e7e616bb271 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c -new file mode 100644 -index 00000000000..5320e923be2 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c -@@ -0,0 +1,19 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */ -+ -+typedef void (*dispatch_t)(long offset); -+ -+dispatch_t dispatch; -+ -+void -+male_indirect_jump (long offset) -+{ -+ dispatch(offset); -+} -+ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -+/* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -index 3a6727b5c54..e6fea84a4d9 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */ - - extern void (*bar) (void); - -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -index b8f68188313..e239ec4542f 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */ - - extern void (*bar) (void); - -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -index 01b0a02f80b..fa3181303c9 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ - - extern void (*bar) (void); - -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -index 4b497b5f8af..fd5b41fdd3f 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ - - extern void (*bar) (void); - extern int foo (void) __attribute__ ((function_return("thunk"))); -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -index 4ae4c44a3fd..d606373ead1 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ - - extern void (*bar) (void); - -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -index 5b5bc765a7e..75e45e226b8 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */ - - extern void (*bar) (void); - -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -index fa24a1f7365..d1db41cc128 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */ -+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */ - - extern void (*bar) (void); - --- -2.16.3 - diff --git a/main/gcc/0007-x86-Add-V-register-operand-modifier.patch b/main/gcc/0007-x86-Add-V-register-operand-modifier.patch deleted file mode 100644 index f75b2133c8..0000000000 --- a/main/gcc/0007-x86-Add-V-register-operand-modifier.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 92308185917678406afee3c165ea5e71b53b3cc1 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sat, 6 Jan 2018 22:29:56 -0800 -Subject: [PATCH 07/13] x86: Add 'V' register operand modifier - -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/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * 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/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * 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 34e26a3a3c7..eeca7e5e490 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -16869,6 +16869,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 -@@ -16879,7 +16880,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) -@@ -16922,6 +16923,14 @@ print_reg (rtx x, int code, FILE *file) - && regno != FPSR_REG - && regno != FPCR_REG); - -+ 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) -@@ -17035,6 +17044,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. -@@ -17259,6 +17269,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 2cb6bd1ef3e..76ba1d4f913 100644 ---- a/gcc/doc/extend.texi -+++ b/gcc/doc/extend.texi -@@ -8511,6 +8511,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.16.3 - diff --git a/main/gcc/0008-s390x-muslldso.patch b/main/gcc/0008-s390x-muslldso.patch new file mode 100644 index 0000000000..64833f308f --- /dev/null +++ b/main/gcc/0008-s390x-muslldso.patch @@ -0,0 +1,26 @@ +From b693804c8dba92fea7beee98f0aa520853a0532b Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Thu, 22 Dec 2016 11:22:28 +0000 +Subject: [PATCH 08/12] s390x muslldso + +--- + gcc/config/s390/linux.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h +index 525c17c2c9f..2d4f4a0654e 100644 +--- a/gcc/config/s390/linux.h ++++ b/gcc/config/s390/linux.h +@@ -76,6 +76,9 @@ along with GCC; see the file COPYING3. If not see + #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" + #define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1" + ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1" ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1" ++ + #undef LINK_SPEC + #define LINK_SPEC \ + "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ +-- +2.17.1 + diff --git a/main/gcc/0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch b/main/gcc/0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch deleted file mode 100644 index 73a58bf86e..0000000000 --- a/main/gcc/0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch +++ /dev/null @@ -1,299 +0,0 @@ -From 087b12213a5b4b8654c70320c671bb05c1b1b012 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sat, 13 Jan 2018 18:01:54 -0800 -Subject: [PATCH 08/13] 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 - - * 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. - -gcc/testsuite/ - - Backport from mainline - 2018-01-14 H.J. Lu - - * gcc.target/i386/indirect-thunk-10.c: New test. - * gcc.target/i386/indirect-thunk-8.c: Likewise. - * gcc.target/i386/indirect-thunk-9.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-10.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-11.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-9.c: Likewise. - * gcc.target/i386/ret-thunk-17.c: Likewise. - * gcc.target/i386/ret-thunk-18.c: Likewise. - * gcc.target/i386/ret-thunk-19.c: Likewise. - * gcc.target/i386/ret-thunk-20.c: Likewise. - * gcc.target/i386/ret-thunk-21.c: Likewise. ---- - gcc/config/i386/i386.c | 26 ++++++++++++++++++++++ - gcc/doc/invoke.texi | 11 +++++++++ - gcc/testsuite/gcc.target/i386/indirect-thunk-10.c | 7 ++++++ - gcc/testsuite/gcc.target/i386/indirect-thunk-8.c | 7 ++++++ - gcc/testsuite/gcc.target/i386/indirect-thunk-9.c | 7 ++++++ - .../gcc.target/i386/indirect-thunk-attr-10.c | 9 ++++++++ - .../gcc.target/i386/indirect-thunk-attr-11.c | 9 ++++++++ - .../gcc.target/i386/indirect-thunk-attr-9.c | 9 ++++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-17.c | 7 ++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-18.c | 8 +++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-19.c | 8 +++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-20.c | 9 ++++++++ - gcc/testsuite/gcc.target/i386/ret-thunk-21.c | 9 ++++++++ - 13 files changed, 126 insertions(+) - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-10.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-8.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-9.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c - create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-17.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-18.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-19.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-20.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-21.c - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index eeca7e5e490..9c038bee000 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -6389,6 +6389,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) -@@ -6414,6 +6427,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 94374661f2d..1dee495c86b 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -24242,6 +24242,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}, -@@ -24253,6 +24258,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/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c -new file mode 100644 -index 00000000000..a0674bd2363 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c -@@ -0,0 +1,7 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mfunction-return=keep -mcmodel=large" } */ -+ -+void -+bar (void) -+{ -+} -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c -new file mode 100644 -index 00000000000..7a80a8986e8 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c -@@ -0,0 +1,7 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk -mfunction-return=keep -mcmodel=large" } */ -+ -+void -+bar (void) -+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c -new file mode 100644 -index 00000000000..d4d45c5114d ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c -@@ -0,0 +1,7 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mfunction-return=keep -mcmodel=large" } */ -+ -+void -+bar (void) -+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c -new file mode 100644 -index 00000000000..3a2aeaddbc5 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+__attribute__ ((indirect_branch("thunk-extern"))) -+void -+bar (void) -+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c -new file mode 100644 -index 00000000000..8e52f032b6c ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+__attribute__ ((indirect_branch("thunk-inline"))) -+void -+bar (void) -+{ -+} -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c -new file mode 100644 -index 00000000000..bdaa4f6911b ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+__attribute__ ((indirect_branch("thunk"))) -+void -+bar (void) -+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-17.c b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c -new file mode 100644 -index 00000000000..0605e2c6542 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c -@@ -0,0 +1,7 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=keep -mcmodel=large" } */ -+ -+void -+bar (void) -+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-18.c b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c -new file mode 100644 -index 00000000000..307019dc242 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c -@@ -0,0 +1,8 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+void -+bar (void) -+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-19.c b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c -new file mode 100644 -index 00000000000..772617f4010 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c -@@ -0,0 +1,8 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */ -+ -+__attribute__ ((function_return("thunk"))) -+void -+bar (void) -+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-20.c b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c -new file mode 100644 -index 00000000000..1e9f9bd5a66 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+__attribute__ ((function_return("thunk-extern"))) -+void -+bar (void) -+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */ -+} -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-21.c b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c -new file mode 100644 -index 00000000000..eea07f7abe1 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile { target { lp64 } } } */ -+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */ -+/* { dg-additional-options "-fPIC" { target fpic } } */ -+ -+__attribute__ ((function_return("thunk-inline"))) -+void -+bar (void) -+{ -+} --- -2.16.3 - diff --git a/main/gcc/0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch b/main/gcc/0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch deleted file mode 100644 index f33946c157..0000000000 --- a/main/gcc/0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch +++ /dev/null @@ -1,121 +0,0 @@ -From 07857bd9fb9ccab67a932ad9df3e53f3f0c2c617 Mon Sep 17 00:00:00 2001 -From: uros -Date: Thu, 25 Jan 2018 19:39:01 +0000 -Subject: [PATCH 09/13] Use INVALID_REGNUM in indirect thunk processing - - Backport from mainline - 2018-01-17 Uros Bizjak - - * config/i386/i386.c (indirect_thunk_name): Declare regno - as unsigned int. Compare regno with INVALID_REGNUM. - (output_indirect_thunk): Ditto. - (output_indirect_thunk_function): Ditto. - (ix86_code_end): Declare regno as unsigned int. Use INVALID_REGNUM - in the call to output_indirect_thunk_function. - -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257067 138bc75d-0d04-0410-961f-82ee72b054a4 ---- - gcc/config/i386/i386.c | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index 9c038bee000..40126579c22 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -11087,16 +11087,16 @@ 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, -- bool ret_p) -+indirect_thunk_name (char name[32], unsigned int regno, -+ bool need_bnd_p, bool ret_p) - { -- if (regno >= 0 && ret_p) -+ if (regno != INVALID_REGNUM && ret_p) - gcc_unreachable (); - - if (USE_HIDDEN_LINKONCE) - { - const char *bnd = need_bnd_p ? "_bnd" : ""; -- if (regno >= 0) -+ if (regno != INVALID_REGNUM) - { - const char *reg_prefix; - if (LEGACY_INT_REGNO_P (regno)) -@@ -11114,7 +11114,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p, - } - else - { -- if (regno >= 0) -+ if (regno != INVALID_REGNUM) - { - if (need_bnd_p) - ASM_GENERATE_INTERNAL_LABEL (name, "LITBR", regno); -@@ -11166,7 +11166,7 @@ indirect_thunk_name (char name[32], int regno, bool need_bnd_p, - */ - - static void --output_indirect_thunk (bool need_bnd_p, int regno) -+output_indirect_thunk (bool need_bnd_p, unsigned int regno) - { - char indirectlabel1[32]; - char indirectlabel2[32]; -@@ -11196,7 +11196,7 @@ output_indirect_thunk (bool need_bnd_p, int regno) - - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2); - -- if (regno >= 0) -+ if (regno != INVALID_REGNUM) - { - /* MOV. */ - rtx xops[2]; -@@ -11220,12 +11220,12 @@ output_indirect_thunk (bool need_bnd_p, int regno) - } - - /* 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 -+ If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM, -+ 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) -+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) - { - char name[32]; - tree decl; -@@ -11274,7 +11274,7 @@ output_indirect_thunk_function (bool need_bnd_p, int regno) - ASM_OUTPUT_LABEL (asm_out_file, name); - } - -- if (regno < 0) -+ if (regno == INVALID_REGNUM) - { - /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */ - char alias[32]; -@@ -11348,16 +11348,16 @@ static void - ix86_code_end (void) - { - rtx xops[2]; -- int regno; -+ unsigned int regno; - - if (indirect_thunk_needed) -- output_indirect_thunk_function (false, -1); -+ output_indirect_thunk_function (false, INVALID_REGNUM); - if (indirect_thunk_bnd_needed) -- output_indirect_thunk_function (true, -1); -+ output_indirect_thunk_function (true, INVALID_REGNUM); - - for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++) - { -- int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1; -+ unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1; - if ((indirect_thunks_used & (1 << i))) - output_indirect_thunk_function (false, regno); - --- -2.16.3 - diff --git a/main/gcc/0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch b/main/gcc/0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch deleted file mode 100644 index 08593c2b3e..0000000000 --- a/main/gcc/0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 3815e98f0f46b6c4c41e6810bad987bd083691aa Mon Sep 17 00:00:00 2001 -From: hjl -Date: Fri, 2 Feb 2018 16:47:02 +0000 -Subject: [PATCH 10/13] i386: Pass INVALID_REGNUM as invalid register number - - Backport from mainline - * config/i386/i386.c (ix86_output_function_return): Pass - INVALID_REGNUM, instead of -1, as invalid register number to - indirect_thunk_name and output_indirect_thunk. - -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257341 138bc75d-0d04-0410-961f-82ee72b054a4 ---- - gcc/config/i386/i386.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index 40126579c22..66502ee6da6 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -28056,7 +28056,8 @@ ix86_output_function_return (bool long_p) - { - bool need_thunk = (cfun->machine->function_return_type - == indirect_branch_thunk); -- indirect_thunk_name (thunk_name, -1, need_bnd_p, true); -+ indirect_thunk_name (thunk_name, INVALID_REGNUM, need_bnd_p, -+ true); - if (need_bnd_p) - { - indirect_thunk_bnd_needed |= need_thunk; -@@ -28069,7 +28070,7 @@ ix86_output_function_return (bool long_p) - } - } - else -- output_indirect_thunk (need_bnd_p, -1); -+ output_indirect_thunk (need_bnd_p, INVALID_REGNUM); - - return ""; - } --- -2.16.3 - diff --git a/main/gcc/0010-ldbl128-config.patch b/main/gcc/0010-ldbl128-config.patch new file mode 100644 index 0000000000..b5a1010528 --- /dev/null +++ b/main/gcc/0010-ldbl128-config.patch @@ -0,0 +1,76 @@ +From 47467f3ab0fb2f2fcede81060fe8bb339d0909eb Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Wed, 28 Feb 2018 00:54:05 +0000 +Subject: [PATCH 10/12] ldbl128 config + +--- + gcc/configure | 13 +++++++++++++ + gcc/configure.ac | 16 ++++++++++++++-- + 2 files changed, 27 insertions(+), 2 deletions(-) + +diff --git a/gcc/configure b/gcc/configure +index 6121e163259..07ff8597d48 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -29309,6 +29309,15 @@ if test "${with_long_double_128+set}" = set; then : + withval=$with_long_double_128; gcc_cv_target_ldbl128="$with_long_double_128" + else + ++ case "$target" in ++ s390*-*-linux-musl*) ++ gcc_cv_target_ldbl128=yes ++ ;; ++ powerpc*-*-linux-musl*) ++ gcc_cv_target_ldbl128=no ++ ;; ++ *) ++ + if test $glibc_version_major -gt 2 \ + || ( test $glibc_version_major -eq 2 && test $glibc_version_minor -ge 4 ); then : + gcc_cv_target_ldbl128=yes +@@ -29320,6 +29329,10 @@ else + && gcc_cv_target_ldbl128=yes + + fi ++ ++ ;; ++ esac ++ + fi + + ;; +diff --git a/gcc/configure.ac b/gcc/configure.ac +index b066cc609e1..6c15ed898c0 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -5971,13 +5971,25 @@ case "$target" in + AC_ARG_WITH(long-double-128, + [AS_HELP_STRING([--with-long-double-128], + [use 128-bit long double by default])], +- gcc_cv_target_ldbl128="$with_long_double_128", ++ gcc_cv_target_ldbl128="$with_long_double_128", [ ++ case "$target" in ++ s390*-*-linux-musl*) ++ gcc_cv_target_ldbl128=yes ++ ;; ++ powerpc*-*-linux-musl*) ++ gcc_cv_target_ldbl128=no ++ ;; ++ *)] + [GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_target_ldbl128=yes], [ + [gcc_cv_target_ldbl128=no + grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \ + $target_header_dir/bits/wordsize.h > /dev/null 2>&1 \ + && gcc_cv_target_ldbl128=yes +- ]])]) ++ ]])] ++ [ ++ ;; ++ esac ++ ]) + ;; + esac + if test x$gcc_cv_target_ldbl128 = xyes; then +-- +2.17.1 + diff --git a/main/gcc/0011-i386-Update-mfunction-return-for-return-with-pop.patch b/main/gcc/0011-i386-Update-mfunction-return-for-return-with-pop.patch deleted file mode 100644 index 3d528395b9..0000000000 --- a/main/gcc/0011-i386-Update-mfunction-return-for-return-with-pop.patch +++ /dev/null @@ -1,456 +0,0 @@ -From 771535dec733e4b85924f00a3a94c29683d614e5 Mon Sep 17 00:00:00 2001 -From: hjl -Date: Mon, 26 Feb 2018 15:29:30 +0000 -Subject: [PATCH 11/13] i386: Update -mfunction-return= for return with pop - -When -mfunction-return= is used, simple_return_pop_internal should pop -return address into ECX register, adjust stack by bytes to pop from stack -and jump to the return thunk via ECX register. - -Revision 257992 removed the bool argument from ix86_output_indirect_jmp. -Update comments to reflect it. - -Tested on i686 and x86-64. - -gcc/ - - Backport from mainline - 2018-02-26 H.J. Lu - - * config/i386/i386.c (ix86_output_indirect_jmp): Update comments. - - 2018-02-26 H.J. Lu - - PR target/84530 - * config/i386/i386-protos.h (ix86_output_indirect_jmp): Remove - the bool argument. - (ix86_output_indirect_function_return): New prototype. - (ix86_split_simple_return_pop_internal): Likewise. - * config/i386/i386.c (indirect_return_via_cx): New. - (indirect_return_via_cx_bnd): Likewise. - (indirect_thunk_name): Handle return va CX_REG. - (output_indirect_thunk_function): Create alias for - __x86_return_thunk_[re]cx and __x86_return_thunk_[re]cx_bnd. - (ix86_output_indirect_jmp): Remove the bool argument. - (ix86_output_indirect_function_return): New function. - (ix86_split_simple_return_pop_internal): Likewise. - * config/i386/i386.md (*indirect_jump): Don't pass false - to ix86_output_indirect_jmp. - (*tablejump_1): Likewise. - (simple_return_pop_internal): Change it to define_insn_and_split. - Call ix86_split_simple_return_pop_internal to split it for - -mfunction-return=. - (simple_return_indirect_internal): Call - ix86_output_indirect_function_return instead of - ix86_output_indirect_jmp. - -gcc/testsuite/ - - Backport from mainline - 2018-02-26 H.J. Lu - - PR target/84530 - * gcc.target/i386/ret-thunk-22.c: New test. - * gcc.target/i386/ret-thunk-23.c: Likewise. - * gcc.target/i386/ret-thunk-24.c: Likewise. - * gcc.target/i386/ret-thunk-25.c: Likewise. - * gcc.target/i386/ret-thunk-26.c: Likewise. ---- - gcc/config/i386/i386-protos.h | 4 +- - gcc/config/i386/i386.c | 127 +++++++++++++++++++++++---- - gcc/config/i386/i386.md | 11 ++- - gcc/testsuite/gcc.target/i386/ret-thunk-22.c | 15 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-23.c | 15 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-24.c | 15 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-25.c | 15 ++++ - gcc/testsuite/gcc.target/i386/ret-thunk-26.c | 40 +++++++++ - 8 files changed, 222 insertions(+), 20 deletions(-) - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-22.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-23.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-24.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-25.c - create mode 100644 gcc/testsuite/gcc.target/i386/ret-thunk-26.c - -diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h -index 620d70ef9f6..c7a0ccb58d3 100644 ---- a/gcc/config/i386/i386-protos.h -+++ b/gcc/config/i386/i386-protos.h -@@ -311,8 +311,10 @@ 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 const char * ix86_output_indirect_jmp (rtx call_op); - extern const char * ix86_output_function_return (bool long_p); -+extern const char * ix86_output_indirect_function_return (rtx ret_op); -+extern void ix86_split_simple_return_pop_internal (rtx); - 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 66502ee6da6..21c3c18bd3c 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -11080,6 +11080,12 @@ static int indirect_thunks_used; - by call and return thunks functions with the BND prefix. */ - static int indirect_thunks_bnd_used; - -+/* True if return thunk function via CX is needed. */ -+static bool indirect_return_via_cx; -+/* True if return thunk function via CX with the BND prefix is -+ needed. */ -+static bool indirect_return_via_cx_bnd; -+ - #ifndef INDIRECT_LABEL - # define INDIRECT_LABEL "LIND" - #endif -@@ -11090,12 +11096,13 @@ static void - indirect_thunk_name (char name[32], unsigned int regno, - bool need_bnd_p, bool ret_p) - { -- if (regno != INVALID_REGNUM && ret_p) -+ if (regno != INVALID_REGNUM && regno != CX_REG && ret_p) - gcc_unreachable (); - - if (USE_HIDDEN_LINKONCE) - { - const char *bnd = need_bnd_p ? "_bnd" : ""; -+ const char *ret = ret_p ? "return" : "indirect"; - if (regno != INVALID_REGNUM) - { - const char *reg_prefix; -@@ -11103,14 +11110,11 @@ indirect_thunk_name (char name[32], unsigned int regno, - reg_prefix = TARGET_64BIT ? "r" : "e"; - else - reg_prefix = ""; -- sprintf (name, "__x86_indirect_thunk%s_%s%s", -- bnd, reg_prefix, reg_names[regno]); -+ sprintf (name, "__x86_%s_thunk%s_%s%s", -+ ret, bnd, reg_prefix, reg_names[regno]); - } - else -- { -- const char *ret = ret_p ? "return" : "indirect"; -- sprintf (name, "__x86_%s_thunk%s", ret, bnd); -- } -+ sprintf (name, "__x86_%s_thunk%s", ret, bnd); - } - else - { -@@ -11274,9 +11278,23 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) - ASM_OUTPUT_LABEL (asm_out_file, name); - } - -+ /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or -+ __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */ -+ bool need_alias; - if (regno == INVALID_REGNUM) -+ need_alias = true; -+ else if (regno == CX_REG) -+ { -+ if (need_bnd_p) -+ need_alias = indirect_return_via_cx_bnd; -+ else -+ need_alias = indirect_return_via_cx; -+ } -+ else -+ need_alias = false; -+ -+ if (need_alias) - { -- /* Create alias for __x86.return_thunk/__x86.return_thunk_bnd. */ - char alias[32]; - - indirect_thunk_name (alias, regno, need_bnd_p, true); -@@ -28019,18 +28037,17 @@ ix86_output_indirect_branch (rtx call_op, const char *xasm, - 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. */ -+ -+/* Output indirect jump. CALL_OP is the jump target. */ - - const char * --ix86_output_indirect_jmp (rtx call_op, bool ret_p) -+ix86_output_indirect_jmp (rtx call_op) - { - 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) -+ /* We can't have red-zone since "call" in the indirect thunk -+ pushes the return address onto stack, destroying red-zone. */ -+ if (ix86_red_zone_size != 0) - gcc_unreachable (); - - ix86_output_indirect_branch (call_op, "%0", true); -@@ -28081,6 +28098,86 @@ ix86_output_function_return (bool long_p) - return "rep%; ret"; - } - -+/* Output indirect function return. RET_OP is the function return -+ target. */ -+ -+const char * -+ix86_output_indirect_function_return (rtx ret_op) -+{ -+ 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); -+ unsigned int regno = REGNO (ret_op); -+ gcc_assert (regno == CX_REG); -+ -+ 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, regno, need_bnd_p, true); -+ if (need_bnd_p) -+ { -+ if (need_thunk) -+ { -+ indirect_return_via_cx_bnd = true; -+ indirect_thunks_bnd_used |= 1 << CX_REG; -+ } -+ fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name); -+ } -+ else -+ { -+ if (need_thunk) -+ { -+ indirect_return_via_cx = true; -+ indirect_thunks_used |= 1 << CX_REG; -+ } -+ fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); -+ } -+ } -+ else -+ output_indirect_thunk (need_bnd_p, regno); -+ -+ return ""; -+ } -+ else -+ return "%!jmp\t%A0"; -+} -+ -+/* Split simple return with popping POPC bytes from stack to indirect -+ branch with stack adjustment . */ -+ -+void -+ix86_split_simple_return_pop_internal (rtx popc) -+{ -+ struct machine_function *m = cfun->machine; -+ rtx ecx = gen_rtx_REG (SImode, CX_REG); -+ rtx_insn *insn; -+ -+ /* There is no "pascal" calling convention in any 64bit ABI. */ -+ gcc_assert (!TARGET_64BIT); -+ -+ insn = emit_insn (gen_pop (ecx)); -+ m->fs.cfa_offset -= UNITS_PER_WORD; -+ m->fs.sp_offset -= UNITS_PER_WORD; -+ -+ rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD); -+ x = gen_rtx_SET (stack_pointer_rtx, x); -+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x); -+ add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (ecx, pc_rtx)); -+ RTX_FRAME_RELATED_P (insn) = 1; -+ -+ x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, popc); -+ x = gen_rtx_SET (stack_pointer_rtx, x); -+ insn = emit_insn (x); -+ add_reg_note (insn, REG_CFA_ADJUST_CFA, x); -+ RTX_FRAME_RELATED_P (insn) = 1; -+ -+ /* Now return address is in ECX. */ -+ emit_jump_insn (gen_simple_return_indirect_internal (ecx)); -+} -+ - /* Output the assembly for a call instruction. */ - - const char * -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md -index 05a88fff356..857466a6361 100644 ---- a/gcc/config/i386/i386.md -+++ b/gcc/config/i386/i386.md -@@ -11813,7 +11813,7 @@ - (define_insn "*indirect_jump" - [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw"))] - "" -- "* return ix86_output_indirect_jmp (operands[0], false);" -+ "* return ix86_output_indirect_jmp (operands[0]);" - [(set (attr "type") - (if_then_else (match_test "(cfun->machine->indirect_branch_type - != indirect_branch_keep)") -@@ -11868,7 +11868,7 @@ - [(set (pc) (match_operand:W 0 "indirect_branch_operand" "rBw")) - (use (label_ref (match_operand 1)))] - "" -- "* return ix86_output_indirect_jmp (operands[0], false);" -+ "* return ix86_output_indirect_jmp (operands[0]);" - [(set (attr "type") - (if_then_else (match_test "(cfun->machine->indirect_branch_type - != indirect_branch_keep)") -@@ -12520,11 +12520,14 @@ - (set_attr "prefix_rep" "1") - (set_attr "modrm" "0")]) - --(define_insn "simple_return_pop_internal" -+(define_insn_and_split "simple_return_pop_internal" - [(simple_return) - (use (match_operand:SI 0 "const_int_operand"))] - "reload_completed" - "%!ret\t%0" -+ "&& cfun->machine->function_return_type != indirect_branch_keep" -+ [(const_int 0)] -+ "ix86_split_simple_return_pop_internal (operands[0]); DONE;" - [(set_attr "length" "3") - (set_attr "atom_unit" "jeu") - (set_attr "length_immediate" "2") -@@ -12535,7 +12538,7 @@ - [(simple_return) - (use (match_operand:SI 0 "register_operand" "r"))] - "reload_completed" -- "* return ix86_output_indirect_jmp (operands[0], true);" -+ "* return ix86_output_indirect_function_return (operands[0]);" - [(set (attr "type") - (if_then_else (match_test "(cfun->machine->indirect_branch_type - != indirect_branch_keep)") -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c -new file mode 100644 -index 00000000000..89e086de97b ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c -@@ -0,0 +1,15 @@ -+/* PR target/r84530 */ -+/* { dg-do compile { target ia32 } } */ -+/* { dg-options "-O2 -mfunction-return=thunk" } */ -+ -+struct s { _Complex unsigned short x; }; -+struct s gs = { 100 + 200i }; -+struct s __attribute__((noinline)) foo (void) { return gs; } -+ -+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c -new file mode 100644 -index 00000000000..43f0ccaa854 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c -@@ -0,0 +1,15 @@ -+/* PR target/r84530 */ -+/* { dg-do compile { target ia32 } } */ -+/* { dg-options "-O2 -mfunction-return=thunk-extern" } */ -+ -+struct s { _Complex unsigned short x; }; -+struct s gs = { 100 + 200i }; -+struct s __attribute__((noinline)) foo (void) { return gs; } -+ -+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not {\tpause} } } */ -+/* { dg-final { scan-assembler-not {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c -new file mode 100644 -index 00000000000..8729e35147e ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c -@@ -0,0 +1,15 @@ -+/* PR target/r84530 */ -+/* { dg-do compile { target ia32 } } */ -+/* { dg-options "-O2 -mfunction-return=thunk-inline" } */ -+ -+struct s { _Complex unsigned short x; }; -+struct s gs = { 100 + 200i }; -+struct s __attribute__((noinline)) foo (void) { return gs; } -+ -+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c -new file mode 100644 -index 00000000000..f73553c9a9f ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c -@@ -0,0 +1,15 @@ -+/* PR target/r84530 */ -+/* { dg-do compile { target ia32 } } */ -+/* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ -+ -+struct s { _Complex unsigned short x; }; -+struct s gs = { 100 + 200i }; -+struct s __attribute__((noinline)) foo (void) { return gs; } -+ -+/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -+/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_bnd_ecx" } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler {\tpause} } } */ -+/* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-26.c b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c -new file mode 100644 -index 00000000000..9144e988735 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-26.c -@@ -0,0 +1,40 @@ -+/* PR target/r84530 */ -+/* { dg-do run } */ -+/* { dg-options "-Os -mfunction-return=thunk" } */ -+ -+struct S { int i; }; -+__attribute__((const, noinline, noclone)) -+struct S foo (int x) -+{ -+ struct S s; -+ s.i = x; -+ return s; -+} -+ -+int a[2048], b[2048], c[2048], d[2048]; -+struct S e[2048]; -+ -+__attribute__((noinline, noclone)) void -+bar (void) -+{ -+ int i; -+ for (i = 0; i < 1024; i++) -+ { -+ e[i] = foo (i); -+ a[i+2] = a[i] + a[i+1]; -+ b[10] = b[10] + i; -+ c[i] = c[2047 - i]; -+ d[i] = d[i + 1]; -+ } -+} -+ -+int -+main () -+{ -+ int i; -+ bar (); -+ for (i = 0; i < 1024; i++) -+ if (e[i].i != i) -+ __builtin_abort (); -+ return 0; -+} --- -2.16.3 - diff --git a/main/gcc/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch b/main/gcc/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch deleted file mode 100644 index 1bd6134cea..0000000000 --- a/main/gcc/0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch +++ /dev/null @@ -1,1003 +0,0 @@ -From a34d0b92e2c81792bd1f27e872c4c97a2df6861c Mon Sep 17 00:00:00 2001 -From: hjl -Date: Mon, 26 Feb 2018 17:00:46 +0000 -Subject: [PATCH 12/13] i386: Add TARGET_INDIRECT_BRANCH_REGISTER - -For - ---- -struct C { - virtual ~C(); - virtual void f(); -}; - -void -f (C *p) -{ - p->f(); - p->f(); -} ---- - --mindirect-branch=thunk-extern -O2 on x86-64 GNU/Linux generates: - -_Z1fP1C: -.LFB0: - .cfi_startproc - pushq %rbx - .cfi_def_cfa_offset 16 - .cfi_offset 3, -16 - movq (%rdi), %rax - movq %rdi, %rbx - jmp .LIND1 -.LIND0: - pushq 16(%rax) - jmp __x86_indirect_thunk -.LIND1: - call .LIND0 - movq (%rbx), %rax - movq %rbx, %rdi - popq %rbx - .cfi_def_cfa_offset 8 - movq 16(%rax), %rax - jmp __x86_indirect_thunk_rax - .cfi_endproc - -x86-64 is supposed to have asynchronous unwind tables by default, but -there is nothing that reflects the change in the (relative) frame -address after .LIND0. That region really has to be moved outside of -the .cfi_startproc/.cfi_endproc bracket. - -This patch adds TARGET_INDIRECT_BRANCH_REGISTER to force indirect -branch via register whenever -mindirect-branch= is used. Now, --mindirect-branch=thunk-extern -O2 on x86-64 GNU/Linux generates: - -_Z1fP1C: -.LFB0: - .cfi_startproc - pushq %rbx - .cfi_def_cfa_offset 16 - .cfi_offset 3, -16 - movq (%rdi), %rax - movq %rdi, %rbx - movq 16(%rax), %rax - call __x86_indirect_thunk_rax - movq (%rbx), %rax - movq %rbx, %rdi - popq %rbx - .cfi_def_cfa_offset 8 - movq 16(%rax), %rax - jmp __x86_indirect_thunk_rax - .cfi_endproc - -so that "-mindirect-branch=thunk-extern" is equivalent to -"-mindirect-branch=thunk-extern -mindirect-branch-register", which is -used by Linux kernel. - -gcc/ - - Backport from mainline - 2018-02-26 H.J. Lu - - PR target/84039 - * config/i386/constraints.md (Bs): Replace - ix86_indirect_branch_register with - TARGET_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. - (*sibcall_GOT_32): Disallowed for TARGET_INDIRECT_BRANCH_REGISTER. - (*sibcall_value_GOT_32): 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.h (TARGET_INDIRECT_BRANCH_REGISTER): New. - -gcc/testsuite/ - - Backport from mainline - 2018-02-26 H.J. Lu - - PR target/84039 - * gcc.target/i386/indirect-thunk-1.c: Updated. - * gcc.target/i386/indirect-thunk-2.c: Likewise. - * gcc.target/i386/indirect-thunk-3.c: Likewise. - * gcc.target/i386/indirect-thunk-4.c: Likewise. - * gcc.target/i386/indirect-thunk-5.c: Likewise. - * gcc.target/i386/indirect-thunk-6.c: Likewise. - * gcc.target/i386/indirect-thunk-7.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. - * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-1.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-3.c: Likewise. - * gcc.target/i386/indirect-thunk-bnd-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-5.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-6.c: Likewise. - * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-5.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-6.c: Likewise. - * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. - * gcc.target/i386/ret-thunk-9.c: Likewise. - * gcc.target/i386/ret-thunk-10.c: Likewise. - * gcc.target/i386/ret-thunk-11.c: Likewise. - * gcc.target/i386/ret-thunk-12.c: Likewise. - * gcc.target/i386/ret-thunk-13.c: Likewise. - * gcc.target/i386/ret-thunk-14.c: Likewise. - * gcc.target/i386/ret-thunk-15.c: Likewise. ---- - gcc/config/i386/constraints.md | 4 ++-- - gcc/config/i386/i386.h | 5 ++++ - gcc/config/i386/i386.md | 28 +++++++++++++--------- - gcc/config/i386/predicates.md | 6 ++--- - gcc/testsuite/gcc.target/i386/indirect-thunk-1.c | 5 ++-- - gcc/testsuite/gcc.target/i386/indirect-thunk-2.c | 5 ++-- - gcc/testsuite/gcc.target/i386/indirect-thunk-3.c | 5 ++-- - gcc/testsuite/gcc.target/i386/indirect-thunk-4.c | 5 ++-- - gcc/testsuite/gcc.target/i386/indirect-thunk-5.c | 6 +++-- - gcc/testsuite/gcc.target/i386/indirect-thunk-6.c | 12 ++++++---- - gcc/testsuite/gcc.target/i386/indirect-thunk-7.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-attr-1.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-attr-2.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-attr-3.c | 3 +-- - .../gcc.target/i386/indirect-thunk-attr-4.c | 3 +-- - .../gcc.target/i386/indirect-thunk-attr-5.c | 9 ++++--- - .../gcc.target/i386/indirect-thunk-attr-6.c | 9 ++++--- - .../gcc.target/i386/indirect-thunk-attr-7.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-bnd-1.c | 6 ++--- - .../gcc.target/i386/indirect-thunk-bnd-2.c | 6 ++--- - .../gcc.target/i386/indirect-thunk-bnd-3.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-bnd-4.c | 7 +++--- - .../gcc.target/i386/indirect-thunk-extern-1.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-extern-2.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-extern-3.c | 9 ++++--- - .../gcc.target/i386/indirect-thunk-extern-4.c | 6 ++--- - .../gcc.target/i386/indirect-thunk-extern-5.c | 6 +++-- - .../gcc.target/i386/indirect-thunk-extern-6.c | 8 +++---- - .../gcc.target/i386/indirect-thunk-extern-7.c | 5 ++-- - .../gcc.target/i386/indirect-thunk-inline-1.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-2.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-3.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-4.c | 2 +- - .../gcc.target/i386/indirect-thunk-inline-5.c | 3 ++- - .../gcc.target/i386/indirect-thunk-inline-6.c | 3 ++- - .../gcc.target/i386/indirect-thunk-inline-7.c | 4 ++-- - gcc/testsuite/gcc.target/i386/ret-thunk-10.c | 9 +++---- - gcc/testsuite/gcc.target/i386/ret-thunk-11.c | 9 +++---- - gcc/testsuite/gcc.target/i386/ret-thunk-12.c | 8 +++---- - gcc/testsuite/gcc.target/i386/ret-thunk-13.c | 5 ++-- - gcc/testsuite/gcc.target/i386/ret-thunk-14.c | 7 +++--- - gcc/testsuite/gcc.target/i386/ret-thunk-15.c | 7 +++--- - gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 13 ++++------ - 43 files changed, 128 insertions(+), 141 deletions(-) - -diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md -index 9204c8e8487..ef684a95497 100644 ---- a/gcc/config/i386/constraints.md -+++ b/gcc/config/i386/constraints.md -@@ -172,7 +172,7 @@ - - (define_constraint "Bs" - "@internal Sibcall memory operand." -- (ior (and (not (match_test "ix86_indirect_branch_register")) -+ (ior (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER")) - (not (match_test "TARGET_X32")) - (match_operand 0 "sibcall_memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode") -@@ -180,7 +180,7 @@ - - (define_constraint "Bw" - "@internal Call memory operand." -- (ior (and (not (match_test "ix86_indirect_branch_register")) -+ (ior (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER")) - (not (match_test "TARGET_X32")) - (match_operand 0 "memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode") -diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h -index b34bc117c34..1816d710f4e 100644 ---- a/gcc/config/i386/i386.h -+++ b/gcc/config/i386/i386.h -@@ -2676,6 +2676,11 @@ extern void debug_dispatch_window (int); - #define TARGET_RECIP_VEC_DIV ((recip_mask & RECIP_MASK_VEC_DIV) != 0) - #define TARGET_RECIP_VEC_SQRT ((recip_mask & RECIP_MASK_VEC_SQRT) != 0) - -+ -+#define TARGET_INDIRECT_BRANCH_REGISTER \ -+ (ix86_indirect_branch_register \ -+ || cfun->machine->indirect_branch_type != indirect_branch_keep) -+ - #define IX86_HLE_ACQUIRE (1 << 16) - #define IX86_HLE_RELEASE (1 << 17) - -diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md -index 857466a6361..6a6dc26799c 100644 ---- a/gcc/config/i386/i386.md -+++ b/gcc/config/i386/i386.md -@@ -11805,7 +11805,7 @@ - [(set (pc) (match_operand 0 "indirect_branch_operand"))] - "" - { -- if (TARGET_X32 || ix86_indirect_branch_register) -+ if (TARGET_X32 || TARGET_INDIRECT_BRANCH_REGISTER) - operands[0] = convert_memory_address (word_mode, operands[0]); - cfun->machine->has_local_indirect_jump = true; - }) -@@ -11859,7 +11859,7 @@ - OPTAB_DIRECT); - } - -- if (TARGET_X32 || ix86_indirect_branch_register) -+ if (TARGET_X32 || TARGET_INDIRECT_BRANCH_REGISTER) - operands[0] = convert_memory_address (word_mode, operands[0]); - cfun->machine->has_local_indirect_jump = true; - }) -@@ -12029,7 +12029,10 @@ - (match_operand:SI 0 "register_no_elim_operand" "U") - (match_operand:SI 1 "GOT32_symbol_operand")))) - (match_operand 2))] -- "!TARGET_MACHO && !TARGET_64BIT && SIBLING_CALL_P (insn)" -+ "!TARGET_MACHO -+ && !TARGET_64BIT -+ && !TARGET_INDIRECT_BRANCH_REGISTER -+ && SIBLING_CALL_P (insn)" - { - rtx fnaddr = gen_rtx_PLUS (Pmode, operands[0], operands[1]); - fnaddr = gen_const_mem (Pmode, fnaddr); -@@ -12048,7 +12051,7 @@ - [(call (mem:QI (match_operand:W 0 "memory_operand" "m")) - (match_operand 1)) - (unspec [(const_int 0)] UNSPEC_PEEPSIB)] -- "!TARGET_X32 && !ix86_indirect_branch_register" -+ "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER" - "* return ix86_output_call_insn (insn, operands[0]);" - [(set_attr "type" "call")]) - -@@ -12058,7 +12061,7 @@ - (call (mem:QI (match_dup 0)) - (match_operand 3))] - "!TARGET_X32 -- && !ix86_indirect_branch_register -+ && !TARGET_INDIRECT_BRANCH_REGISTER - && SIBLING_CALL_P (peep2_next_insn (1)) - && !reg_mentioned_p (operands[0], - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))" -@@ -12073,7 +12076,7 @@ - (call (mem:QI (match_dup 0)) - (match_operand 3))] - "!TARGET_X32 -- && !ix86_indirect_branch_register -+ && !TARGET_INDIRECT_BRANCH_REGISTER - && SIBLING_CALL_P (peep2_next_insn (2)) - && !reg_mentioned_p (operands[0], - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))" -@@ -12171,7 +12174,7 @@ - (match_operand:W 1 "memory_operand")) - (set (pc) (match_dup 0))] - "!TARGET_X32 -- && !ix86_indirect_branch_register -+ && !TARGET_INDIRECT_BRANCH_REGISTER - && peep2_reg_dead_p (2, operands[0])" - [(set (pc) (match_dup 1))]) - -@@ -12229,7 +12232,10 @@ - (match_operand:SI 1 "register_no_elim_operand" "U") - (match_operand:SI 2 "GOT32_symbol_operand")))) - (match_operand 3)))] -- "!TARGET_MACHO && !TARGET_64BIT && SIBLING_CALL_P (insn)" -+ "!TARGET_MACHO -+ && !TARGET_64BIT -+ && !TARGET_INDIRECT_BRANCH_REGISTER -+ && SIBLING_CALL_P (insn)" - { - rtx fnaddr = gen_rtx_PLUS (Pmode, operands[1], operands[2]); - fnaddr = gen_const_mem (Pmode, fnaddr); -@@ -12250,7 +12256,7 @@ - (call (mem:QI (match_operand:W 1 "memory_operand" "m")) - (match_operand 2))) - (unspec [(const_int 0)] UNSPEC_PEEPSIB)] -- "!TARGET_X32 && !ix86_indirect_branch_register" -+ "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER" - "* return ix86_output_call_insn (insn, operands[1]);" - [(set_attr "type" "callv")]) - -@@ -12261,7 +12267,7 @@ - (call (mem:QI (match_dup 0)) - (match_operand 3)))] - "!TARGET_X32 -- && !ix86_indirect_branch_register -+ && !TARGET_INDIRECT_BRANCH_REGISTER - && SIBLING_CALL_P (peep2_next_insn (1)) - && !reg_mentioned_p (operands[0], - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))" -@@ -12278,7 +12284,7 @@ - (call (mem:QI (match_dup 0)) - (match_operand 3)))] - "!TARGET_X32 -- && !ix86_indirect_branch_register -+ && !TARGET_INDIRECT_BRANCH_REGISTER - && SIBLING_CALL_P (peep2_next_insn (2)) - && !reg_mentioned_p (operands[0], - CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))" -diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md -index d1f0a7dbf61..5f8a98faead 100644 ---- a/gcc/config/i386/predicates.md -+++ b/gcc/config/i386/predicates.md -@@ -593,7 +593,7 @@ - ;; Test for a valid operand for indirect branch. - (define_predicate "indirect_branch_operand" - (ior (match_operand 0 "register_operand") -- (and (not (match_test "ix86_indirect_branch_register")) -+ (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER")) - (not (match_test "TARGET_X32")) - (match_operand 0 "memory_operand")))) - -@@ -637,7 +637,7 @@ - (ior (match_test "constant_call_address_operand - (op, mode == VOIDmode ? mode : Pmode)") - (match_operand 0 "call_register_no_elim_operand") -- (and (not (match_test "ix86_indirect_branch_register")) -+ (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER")) - (ior (and (not (match_test "TARGET_X32")) - (match_operand 0 "memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode") -@@ -648,7 +648,7 @@ - (ior (match_test "constant_call_address_operand - (op, mode == VOIDmode ? mode : Pmode)") - (match_operand 0 "register_no_elim_operand") -- (and (not (match_test "ix86_indirect_branch_register")) -+ (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER")) - (ior (and (not (match_test "TARGET_X32")) - (match_operand 0 "sibcall_memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode") -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -index 60d09881a99..6e94d2c4865 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c -@@ -11,9 +11,8 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -index aac75163794..3c467078964 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c -@@ -11,9 +11,8 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -index 9e24a385387..2c7fb52b59d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c -@@ -12,9 +12,8 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -index 127b5d94523..0d3f895009d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c -@@ -12,9 +12,8 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -index fcaa18d10b7..fb26c005e80 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-5.c -@@ -9,8 +9,10 @@ foo (void) - bar (); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -index e4649283d10..aa03fbd8446 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-6.c -@@ -10,9 +10,13 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target x32 } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 { target x32 } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler {\tpause} } } */ - /* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -index 17c2d0faf88..3c72036dbaf 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c -@@ -35,9 +35,8 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -index 9194ccf3cbc..7106407b83d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c -@@ -14,9 +14,8 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -index e51f261a612..27c7e5b029b 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c -@@ -12,9 +12,8 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -index 4aeec1833cd..89a2bac8403 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c -@@ -14,10 +14,9 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler {\tpause} } } */ - /* { dg-final { scan-assembler {\tlfence} } } */ - /* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -index ac0e5999f63..3eb83c3779a 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c -@@ -13,10 +13,9 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler {\tpause} } } */ - /* { dg-final { scan-assembler {\tlfence} } } */ - /* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -index 573cf1ef09e..0098dd1133d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c -@@ -14,9 +14,8 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -index b2b37fc6e2e..ece8de15a4b 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c -@@ -13,9 +13,8 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -index 4a43e199931..d53fc887dcc 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c -@@ -36,9 +36,8 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -index ac84ab623fa..73d16baddc7 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c -@@ -10,9 +10,9 @@ foo (void) - dispatch (buf); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "bnd ret" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -index ce655e8be1c..856751ac224 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c -@@ -11,10 +11,8 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "pushq\[ \t\]%rax" { target x32 } } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_(r|e)ax" } } */ - /* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "bnd ret" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -index d34485a0010..42312f65588 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c -@@ -10,8 +10,9 @@ foo (void) - bar (buf); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd" } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "bnd ret" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -index 0e19830de4d..c8ca102c8df 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c -@@ -11,10 +11,9 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk" } } */ --/* { dg-final { scan-assembler "bnd jmp\[ \t\]*\.LIND" } } */ --/* { dg-final { scan-assembler-times "bnd call\[ \t\]*\.LIND" 2 } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-times "bnd call\[ \t\]*\.LIND" 1 } } */ - /* { dg-final { scan-assembler "bnd ret" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ - /* { dg-final { scan-assembler {\tlfence} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -index 579441f250e..c09dd0afd2d 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c -@@ -11,9 +11,8 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -index c92e6f2b02d..826425a5115 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c -@@ -11,9 +11,8 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -index d9964c25bbd..385626850a2 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c -@@ -12,9 +12,8 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -index d4dca4dc5fe..1ae49b137ca 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c -@@ -12,9 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -index 5c07e02df6a..53282390977 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-5.c -@@ -9,8 +9,10 @@ foo (void) - bar (); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -index 3eb440693a0..8ae43482d0c 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-6.c -@@ -10,8 +10,8 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ --/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 1 } } */ --/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 1 } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -index aece9383697..2b9a33e93dc 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c -@@ -35,9 +35,8 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ - /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -index 3aba5e8c81f..869d9040838 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch(offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -index 0f0181d6672..c5c16ed8bd8 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c -@@ -11,7 +11,7 @@ male_indirect_jump (long offset) - dispatch[offset](offset); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -index 2eef6f35a75..4a63ebed8ab 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -index e825a10f14c..a395ffca018 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c -@@ -12,7 +12,7 @@ male_indirect_jump (long offset) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -index c6d77e10352..21cbfd39582 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-5.c -@@ -9,7 +9,8 @@ foo (void) - bar (); - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -index 6454827b780..d1300f18dc7 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-6.c -@@ -10,7 +10,8 @@ foo (void) - return 0; - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" } } */ -+/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*bar@GOT" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" { target { ! x32 } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ -diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -index c67066cf197..ea009245a58 100644 ---- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c -@@ -35,8 +35,8 @@ bar (int i) - } - } - --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%(r|e)ax" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler {\tpause} } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -index e6fea84a4d9..af9023af613 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c -@@ -15,9 +15,6 @@ foo (void) - /* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ - /* { dg-final { scan-assembler-times {\tpause} 2 } } */ - /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -index e239ec4542f..ba467c59b36 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c -@@ -15,9 +15,6 @@ foo (void) - /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -index fa3181303c9..43e57cac2c3 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c -@@ -15,8 +15,6 @@ foo (void) - /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk:" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -index fd5b41fdd3f..55f156c4376 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c -@@ -14,9 +14,8 @@ foo (void) - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ - /* { dg-final { scan-assembler-times {\tpause} 2 } } */ - /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ - /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 3 } } */ - /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 3 } } */ - /* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_indirect_thunk" } } */ --/* { dg-final { scan-assembler-not "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler-not "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -index d606373ead1..1c790436a53 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c -@@ -16,7 +16,6 @@ foo (void) - /* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -index 75e45e226b8..58aba319cba 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c -@@ -16,7 +16,6 @@ foo (void) - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler-times {\tpause} 1 } } */ - /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -index d1db41cc128..d2df8b874e0 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -@@ -14,11 +14,8 @@ foo (void) - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */ --/* { dg-final { scan-assembler-times {\tpause} 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times {\tlfence} 1 { target { ! x32 } } } } */ --/* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */ --/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk" { target { ! x32 } } } } */ --/* { dg-final { scan-assembler-times {\tpause} 2 { target { x32 } } } } */ --/* { dg-final { scan-assembler-times {\tlfence} 2 { target { x32 } } } } */ --/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target { x32 } } } } */ --/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ -+/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ -+/* { dg-final { scan-assembler-times {\tpause} 2 } } */ -+/* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ --- -2.16.3 - diff --git a/main/gcc/0012-static-pie.patch b/main/gcc/0012-static-pie.patch new file mode 100644 index 0000000000..03a4f68f60 --- /dev/null +++ b/main/gcc/0012-static-pie.patch @@ -0,0 +1,138 @@ +From a4aa319f7c19e564dced3daeb7222c9315af936c Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sat, 18 Aug 2018 23:58:45 +0000 +Subject: [PATCH 12/12] static-pie + +in gcc-8 -static means static non-pie, even if -pie or -static-pie +are specified, -static-pie can be used to build static pie. + +in musl toolchains -static -pie always meant static pie, so this +patch fixes the link specs accordingly, the new -static-pie is just +an alias to -static -pie. +--- + gcc/common.opt | 4 ++-- + gcc/config/gnu-user.h | 12 +++++------- + gcc/config/rs6000/sysv4.h | 11 +++++------ + gcc/gcc.c | 6 +++--- + 4 files changed, 15 insertions(+), 18 deletions(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index b52ef0b38c8..0ce5857e01d 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -3197,11 +3197,11 @@ Driver + + no-pie + Driver RejectNegative Negative(shared) +-Don't create a dynamically linked position independent executable. ++Don't create a position independent executable. + + pie + Driver RejectNegative Negative(no-pie) +-Create a dynamically linked position independent executable. ++Create a position independent executable. + + static-pie + Driver RejectNegative Negative(pie) +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index 8620de3e42d..235328a2642 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -52,13 +52,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define GNU_USER_TARGET_STARTFILE_SPEC \ + "%{shared:; \ + pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \ +- static:crt1.o%s; \ +- static-pie:rcrt1.o%s; \ ++ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \ + " PIE_SPEC ":Scrt1.o%s; \ + :crt1.o%s} \ + crti.o%s \ +- %{static:crtbeginT.o%s; \ +- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \ ++ %{shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ static:crtbeginT.o%s; \ + :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ +@@ -92,8 +91,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{static:crtend.o%s; \ +- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \ ++ %{shared|" PIE_SPEC ":crtendS.o%s; \ + :crtend.o%s} \ + crtn.o%s \ + " CRTOFFLOADEND +@@ -133,7 +131,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC + + #if defined(HAVE_LD_EH_FRAME_HDR) +-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " ++#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} " + #endif + + #undef LINK_GCC_C_SEQUENCE_SPEC +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index bb19d0dcd41..bb2a2324eb0 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -763,12 +763,12 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) + #define STARTFILE_LINUX_SPEC \ + "%{shared:; \ + pg|p|profile:gcrt1.o%s; \ +- static:crt1.o%s; \ +- static-pie|" PIE_SPEC ":Scrt1.o%s; \ ++ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \ ++ " PIE_SPEC ":Scrt1.o%s; \ + :crt1.o%s} \ + %{mnewlib:ecrti.o%s;:crti.o%s} \ +- %{static:crtbeginT.o%s; \ +- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \ ++ %{shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ static:crtbeginT.o%s; \ + :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ +@@ -781,8 +781,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{static:crtend.o%s; \ +- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \ ++ %{shared|" PIE_SPEC ":crtendS.o%s; \ + :crtend.o%s} \ + %{mnewlib:ecrtn.o%s;:crtn.o%s} \ + " CRTOFFLOADEND +diff --git a/gcc/gcc.c b/gcc/gcc.c +index eb1610ba8b0..87560afb03c 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -900,7 +900,7 @@ proper position among the other output files. */ + #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC + #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;" + #else +-#define PIE_SPEC "pie" ++#define PIE_SPEC "pie|static-pie" + #define FPIE1_SPEC "fpie" + #define NO_FPIE1_SPEC FPIE1_SPEC ":;" + #define FPIE2_SPEC "fPIE" +@@ -924,12 +924,12 @@ proper position among the other output files. */ + #ifndef LINK_PIE_SPEC + #ifdef HAVE_LD_PIE + #ifndef LD_PIE_SPEC +-#define LD_PIE_SPEC "-pie" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}" + #endif + #else + #define LD_PIE_SPEC "" + #endif +-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " ++#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " + #endif + + #ifndef LINK_BUILDID_SPEC +-- +2.17.1 + diff --git a/main/gcc/0013-i386-Don-t-generate-alias-for-function-return-thunk.patch b/main/gcc/0013-i386-Don-t-generate-alias-for-function-return-thunk.patch deleted file mode 100644 index d846ac77d9..0000000000 --- a/main/gcc/0013-i386-Don-t-generate-alias-for-function-return-thunk.patch +++ /dev/null @@ -1,225 +0,0 @@ -From e7fbaebc8ff650df76f43e92cb9ca59d5174ebe7 Mon Sep 17 00:00:00 2001 -From: hjl -Date: Thu, 15 Mar 2018 17:54:40 +0000 -Subject: [PATCH 13/13] i386: Don't generate alias for function return thunk - -Function return thunks shouldn't be aliased to indirect branch thunks -since indirect branch thunks are placed in COMDAT section and a COMDAT -section with indirect branch may not have function return thunk. This -patch generates function return thunks directly. - -gcc/ - - Backport from mainline - PR target/84574 - * config/i386/i386.c (indirect_thunk_needed): Update comments. - (indirect_thunk_bnd_needed): Likewise. - (indirect_thunks_used): Likewise. - (indirect_thunks_bnd_used): Likewise. - (indirect_return_needed): New. - (indirect_return_bnd_needed): Likewise. - (output_indirect_thunk_function): Add a bool argument for - function return. - (output_indirect_thunk_function): Don't generate alias for - function return thunk. - (ix86_code_end): Call output_indirect_thunk_function to generate - function return thunks. - (ix86_output_function_return): Set indirect_return_bnd_needed - and indirect_return_needed instead of indirect_thunk_bnd_needed - and indirect_thunk_needed. - -gcc/testsuite/ - - Backport from mainline - PR target/84574 - * gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk - label instead of __x86_indirect_thunk label. ---- - gcc/config/i386/i386.c | 92 ++++++++++------------------- - gcc/testsuite/gcc.target/i386/ret-thunk-9.c | 2 +- - 2 files changed, 33 insertions(+), 61 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index 21c3c18bd3c..f4cd1c6f4e9 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -11067,19 +11067,23 @@ ix86_setup_frame_addresses (void) - labels in call and return thunks. */ - static int indirectlabelno; - --/* True if call and return thunk functions are needed. */ -+/* True if call thunk function is needed. */ - static bool indirect_thunk_needed = false; --/* True if call and return thunk functions with the BND prefix are -- needed. */ -+/* True if call thunk function with the BND prefix is needed. */ - static bool indirect_thunk_bnd_needed = false; - - /* Bit masks of integer registers, which contain branch target, used -- by call and return thunks functions. */ -+ by call thunk 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. */ -+ by call thunk functions with the BND prefix. */ - static int indirect_thunks_bnd_used; - -+/* True if return thunk function is needed. */ -+static bool indirect_return_needed = false; -+/* True if return thunk function with the BND prefix is needed. */ -+static bool indirect_return_bnd_needed = false; -+ - /* True if return thunk function via CX is needed. */ - static bool indirect_return_via_cx; - /* True if return thunk function via CX with the BND prefix is -@@ -11226,16 +11230,18 @@ output_indirect_thunk (bool need_bnd_p, unsigned int regno) - /* Output a funtion with a call and return thunk for indirect branch. - If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM, - the function address is in REGNO. Otherwise, the function address is -- on the top of stack. */ -+ on the top of stack. Thunk is used for function return if RET_P is -+ true. */ - - static void --output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) -+output_indirect_thunk_function (bool need_bnd_p, unsigned int regno, -+ bool ret_p) - { - char name[32]; - tree decl; - - /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */ -- indirect_thunk_name (name, regno, need_bnd_p, false); -+ indirect_thunk_name (name, regno, need_bnd_p, ret_p); - decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, - get_identifier (name), - build_function_type_list (void_type_node, NULL_TREE)); -@@ -11278,50 +11284,6 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) - ASM_OUTPUT_LABEL (asm_out_file, name); - } - -- /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or -- __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */ -- bool need_alias; -- if (regno == INVALID_REGNUM) -- need_alias = true; -- else if (regno == CX_REG) -- { -- if (need_bnd_p) -- need_alias = indirect_return_via_cx_bnd; -- else -- need_alias = indirect_return_via_cx; -- } -- else -- need_alias = false; -- -- if (need_alias) -- { -- 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); -@@ -11368,19 +11330,29 @@ ix86_code_end (void) - rtx xops[2]; - unsigned int regno; - -+ if (indirect_return_needed) -+ output_indirect_thunk_function (false, INVALID_REGNUM, true); -+ if (indirect_return_bnd_needed) -+ output_indirect_thunk_function (true, INVALID_REGNUM, true); -+ -+ if (indirect_return_via_cx) -+ output_indirect_thunk_function (false, CX_REG, true); -+ if (indirect_return_via_cx_bnd) -+ output_indirect_thunk_function (true, CX_REG, true); -+ - if (indirect_thunk_needed) -- output_indirect_thunk_function (false, INVALID_REGNUM); -+ output_indirect_thunk_function (false, INVALID_REGNUM, false); - if (indirect_thunk_bnd_needed) -- output_indirect_thunk_function (true, INVALID_REGNUM); -+ output_indirect_thunk_function (true, INVALID_REGNUM, false); - - for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++) - { - unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1; - if ((indirect_thunks_used & (1 << i))) -- output_indirect_thunk_function (false, regno); -+ output_indirect_thunk_function (false, regno, false); - - if ((indirect_thunks_bnd_used & (1 << i))) -- output_indirect_thunk_function (true, regno); -+ output_indirect_thunk_function (true, regno, false); - } - - for (regno = AX_REG; regno <= SP_REG; regno++) -@@ -11389,10 +11361,10 @@ ix86_code_end (void) - tree decl; - - if ((indirect_thunks_used & (1 << regno))) -- output_indirect_thunk_function (false, regno); -+ output_indirect_thunk_function (false, regno, false); - - if ((indirect_thunks_bnd_used & (1 << regno))) -- output_indirect_thunk_function (true, regno); -+ output_indirect_thunk_function (true, regno, false); - - if (!(pic_labels_used & (1 << regno))) - continue; -@@ -28077,12 +28049,12 @@ ix86_output_function_return (bool long_p) - true); - if (need_bnd_p) - { -- indirect_thunk_bnd_needed |= need_thunk; -+ indirect_return_bnd_needed |= need_thunk; - fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name); - } - else - { -- indirect_thunk_needed |= need_thunk; -+ indirect_return_needed |= need_thunk; - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); - } - } -diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -index d2df8b874e0..eee230ca2f6 100644 ---- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c -@@ -13,7 +13,7 @@ foo (void) - /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ - /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ - /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ --/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */ -+/* { dg-final { scan-assembler "__x86_return_thunk:" } } */ - /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ - /* { dg-final { scan-assembler-times {\tpause} 2 } } */ - /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ --- -2.16.3 - diff --git a/main/gcc/001_all_default-ssp-strong.patch b/main/gcc/001_all_default-ssp-strong.patch deleted file mode 100644 index 95949eb00f..0000000000 --- a/main/gcc/001_all_default-ssp-strong.patch +++ /dev/null @@ -1,215 +0,0 @@ -# DP: Turn on -fstack-protector by default for C, C++, ObjC, ObjC++. -# DP: Build libgcc using -fno-stack-protector. - ---- - gcc/Makefile.in | 2 ++ - gcc/cp/lang-specs.h | 6 +++--- - gcc/doc/invoke.texi | 4 ++++ - gcc/gcc.c | 18 ++++++++++++++---- - gcc/objc/lang-specs.h | 10 +++++----- - gcc/objcp/lang-specs.h | 8 ++++---- - 6 files changed, 32 insertions(+), 16 deletions(-) - -Index: b/gcc/gcc.c -=================================================================== ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -858,6 +858,14 @@ proper position among the other output f - #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G" - #endif - -+#ifndef SSP_DEFAULT_SPEC -+#ifdef TARGET_LIBC_PROVIDES_SSP -+#define SSP_DEFAULT_SPEC "%{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}}}}" -+#else -+#define SSP_DEFAULT_SPEC "" -+#endif -+#endif -+ - #ifndef LINK_SSP_SPEC - #ifdef TARGET_LIBC_PROVIDES_SSP - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -@@ -1057,6 +1065,7 @@ static const char *cc1_spec = CC1_SPEC; - static const char *cc1plus_spec = CC1PLUS_SPEC; - static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; - static const char *link_ssp_spec = LINK_SSP_SPEC; -+static const char *ssp_default_spec = SSP_DEFAULT_SPEC; - static const char *asm_spec = ASM_SPEC; - static const char *asm_final_spec = ASM_FINAL_SPEC; - static const char *link_spec = LINK_SPEC; -@@ -1112,7 +1121,7 @@ static const char *cpp_unique_options = - static const char *cpp_options = - "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ - %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\ -- %{undef} %{save-temps*:-fpch-preprocess}"; -+ %{undef} %{save-temps*:-fpch-preprocess} %(ssp_default)"; - - /* This contains cpp options which are not passed when the preprocessor - output will be used by another program. */ -@@ -1301,9 +1310,9 @@ static const struct compiler default_com - %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ - %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ - cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ -- %(cc1_options)}\ -+ %(cc1_options) %(ssp_default)}\ - %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ -- cc1 %(cpp_unique_options) %(cc1_options)}}}\ -+ cc1 %(cpp_unique_options) %(cc1_options) %(ssp_default)}}}\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1}, - {"-", - "%{!E:%e-E or -x required when input is from standard input}\ -@@ -1328,7 +1337,7 @@ static const struct compiler default_com - %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, - {".i", "@cpp-output", 0, 0, 0}, - {"@cpp-output", -- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -+ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(ssp_default) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, - {".s", "@assembler", 0, 0, 0}, - {"@assembler", - "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, -@@ -1560,6 +1569,7 @@ static struct spec_list static_specs[] = - INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec), - INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec), - INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec), -+ INIT_STATIC_SPEC ("ssp_default", &ssp_default_spec), - INIT_STATIC_SPEC ("endfile", &endfile_spec), - INIT_STATIC_SPEC ("link", &link_spec), - INIT_STATIC_SPEC ("lib", &lib_spec), -Index: b/gcc/cp/lang-specs.h -=================================================================== ---- a/gcc/cp/lang-specs.h -+++ b/gcc/cp/lang-specs.h -@@ -46,7 +46,7 @@ along with GCC; see the file COPYING3. - %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\ - cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\ - %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ -- %(cc1_options) %2\ -+ %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:-o %g.s \ - %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\ - %W{o*:--output-pch=%*}}%V}}}}", -@@ -58,11 +58,11 @@ along with GCC; see the file COPYING3. - %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\ - cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\ - %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ -- %(cc1_options) %2\ -+ %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", - CPLUSPLUS_CPP_SPEC, 0, 0}, - {".ii", "@c++-cpp-output", 0, 0, 0}, - {"@c++-cpp-output", - "%{!M:%{!MM:%{!E:\ -- cc1plus -fpreprocessed %i %(cc1_options) %2\ -+ cc1plus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -Index: b/gcc/params.def -=================================================================== ---- a/gcc/params.def -+++ b/gcc/params.def -@@ -673,7 +673,7 @@ DEFPARAM (PARAM_INTEGER_SHARE_LIMIT, - DEFPARAM (PARAM_SSP_BUFFER_SIZE, - "ssp-buffer-size", - "The lower bound for a buffer to be considered for stack smashing protection.", -- 8, 1, 0) -+ 4, 1, 0) - - DEFPARAM (PARAM_MIN_SIZE_FOR_STACK_SHARING, - "min-size-for-stack-sharing", -Index: b/gcc/objc/lang-specs.h -=================================================================== ---- a/gcc/objc/lang-specs.h -+++ b/gcc/objc/lang-specs.h -@@ -29,9 +29,9 @@ along with GCC; see the file COPYING3. - %{traditional|traditional-cpp:\ - %eGNU Objective C no longer supports traditional compilation}\ - %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ -- cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\ -+ cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}}\ - %{!save-temps*:%{!no-integrated-cpp:\ -- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\ -+ cc1obj %(cpp_unique_options) %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}}}\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, - {"@objective-c-header", - "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\ -@@ -40,18 +40,18 @@ along with GCC; see the file COPYING3. - %{traditional|traditional-cpp:\ - %eGNU Objective C no longer supports traditional compilation}\ - %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ -- cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ -+ cc1obj -fpreprocessed %b.mi %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ - -o %g.s %{!o*:--output-pch=%i.gch}\ - %W{o*:--output-pch=%*}%V}\ - %{!save-temps*:%{!no-integrated-cpp:\ -- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ -+ cc1obj %(cpp_unique_options) %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ - -o %g.s %{!o*:--output-pch=%i.gch}\ - %W{o*:--output-pch=%*}%V}}}}}", 0, 0, 0}, - {".mi", "@objective-c-cpp-output", 0, 0, 0}, - {"@objective-c-cpp-output", -- "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ -+ "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, - {"@objc-cpp-output", - "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\ -- %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ -+ %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -Index: b/gcc/objcp/lang-specs.h -=================================================================== ---- a/gcc/objcp/lang-specs.h -+++ b/gcc/objcp/lang-specs.h -@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. - %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ - cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ - %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ -- %(cc1_options) %2\ -+ %(cc1_options) %(ssp_default) %2\ - -o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}%V}}}", - CPLUSPLUS_CPP_SPEC, 0, 0}, - {"@objective-c++", -@@ -46,16 +46,16 @@ along with GCC; see the file COPYING3. - %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ - cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ - %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ -- %(cc1_options) %2\ -+ %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", - CPLUSPLUS_CPP_SPEC, 0, 0}, - {".mii", "@objective-c++-cpp-output", 0, 0, 0}, - {"@objective-c++-cpp-output", - "%{!M:%{!MM:%{!E:\ -- cc1objplus -fpreprocessed %i %(cc1_options) %2\ -+ cc1objplus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, - {"@objc++-cpp-output", - "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\ - %{!M:%{!MM:%{!E:\ -- cc1objplus -fpreprocessed %i %(cc1_options) %2\ -+ cc1objplus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -Index: b/gcc/doc/invoke.texi -=================================================================== ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -9247,6 +9247,9 @@ - The minimum size of variables taking part in stack slot sharing when not - optimizing. The default value is 32. - -+The Alpine Linux default is "4", to increase -+the number of functions protected by the stack protector. -+ - @item max-jump-thread-duplication-stmts - Maximum number of statements allowed in a block that needs to be - duplicated when threading jumps. -@@ -10185,6 +10188,11 @@ - Like @option{-fstack-protector} but includes additional functions to - be protected --- those that have local array definitions, or have - references to local frame addresses. -+ -+NOTE: In Alpine Linux, -+@option{-fstack-protector-strong} is enabled by default for C, -+C++, ObjC, ObjC++, if none of @option{-fno-stack-protector}, -+@option{-nostdlib}, nor @option{-ffreestanding} are found. - - @item -fstack-protector-explicit - @opindex fstack-protector-explicit diff --git a/main/gcc/005_all_default-as-needed.patch b/main/gcc/005_all_default-as-needed.patch index ee4f7962a1..00852197fa 100644 --- a/main/gcc/005_all_default-as-needed.patch +++ b/main/gcc/005_all_default-as-needed.patch @@ -1,9 +1,25 @@ # DP: On linux targets pass --as-needed by default to the linker, but always # DP: link the sanitizer libraries with --no-as-needed. +Index: b/gcc/gcc.c +=================================================================== --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -568,8 +568,11 @@ proper position among the other output f +@@ -692,8 +692,11 @@ proper position among the other output f + #ifdef LIBASAN_EARLY_SPEC + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ +- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lasan " \ ++ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBASAN_LIBS + #else + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS +@@ -710,8 +713,11 @@ proper position among the other output f #ifdef LIBTSAN_EARLY_SPEC #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) @@ -17,21 +33,53 @@ STATIC_LIBTSAN_LIBS #else #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS +@@ -728,8 +734,11 @@ proper position among the other output f + #ifdef LIBLSAN_EARLY_SPEC + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \ +- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -llsan " \ ++ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBLSAN_LIBS + #else + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS +@@ -744,8 +753,11 @@ proper position among the other output f + #define STATIC_LIBUBSAN_LIBS \ + " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" + #ifdef HAVE_LD_STATIC_DYNAMIC +-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \ +- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lubsan " \ ++ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBUBSAN_LIBS + #else + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS +Index: b/gcc/config/gnu-user.h +=================================================================== --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h -@@ -124,13 +124,13 @@ +@@ -161,15 +161,15 @@ see the files COPYING3 and COPYING.RUNTI #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ "%{static-libasan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ - LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" + LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}" #undef LIBTSAN_EARLY_SPEC - #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \ + #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \ + "%{static-libtsan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ - LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" + LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}" #undef LIBLSAN_EARLY_SPEC - #define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \ + #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \ + "%{static-liblsan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \ - LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}" + LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}" @@ -40,7 +88,8 @@ Index: b/gcc/config/aarch64/aarch64-linux.h =================================================================== --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h -@@ -36,5 +36,6 @@ +@@ -35,6 +35,7 @@ + #define CPP_SPEC "%{pthread:-D_REENTRANT}" #define LINUX_TARGET_LINK_SPEC "%{h*} \ + --as-needed \ @@ -77,7 +126,7 @@ Index: b/gcc/config/s390/linux.h =================================================================== --- a/gcc/config/s390/linux.h +++ b/gcc/config/s390/linux.h -@@ -65,7 +65,7 @@ along with GCC; see the file COPYING3. +@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3. #undef LINK_SPEC #define LINK_SPEC \ @@ -90,26 +139,27 @@ Index: b/gcc/config/rs6000/linux64.h =================================================================== --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h -@@ -466,12 +466,12 @@ extern int dot_symbols; +@@ -490,13 +490,13 @@ extern int dot_symbols; " -m elf64ppc") #endif -#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ +#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \ - %{rdynamic:-export-dynamic} \ - -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \ + %{!static-pie: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \ %(link_os_extra_spec32)" -#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \ +#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \ - %{rdynamic:-export-dynamic} \ - -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}} \ - %(link_os_extra_spec64)" + %{!static-pie: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \ Index: b/gcc/config/rs6000/sysv4.h =================================================================== --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h -@@ -784,7 +784,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF +@@ -811,7 +811,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ MUSL_DYNAMIC_LINKER) @@ -122,7 +172,8 @@ Index: b/gcc/config/i386/gnu-user64.h =================================================================== --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h -@@ -57,5 +57,6 @@ see the files COPYING3 and COPYING.RUNTI +@@ -56,6 +56,7 @@ + "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \ %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \ %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \ + --as-needed \ @@ -141,7 +192,7 @@ Index: b/gcc/config/i386/gnu-user.h +#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \ %{!shared: \ %{!static: \ - %{rdynamic:-export-dynamic} \ + %{!static-pie: \ Index: b/gcc/config/alpha/linux-elf.h =================================================================== --- a/gcc/config/alpha/linux-elf.h @@ -151,7 +202,7 @@ Index: b/gcc/config/alpha/linux-elf.h #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER -#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \ -+#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \ ++#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \ %{O*:-O3} %{!O*:-O1} \ %{shared:-shared} \ %{!shared: \ @@ -159,7 +210,8 @@ Index: b/gcc/config/arm/linux-elf.h =================================================================== --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h -@@ -73,5 +73,6 @@ +@@ -70,6 +70,7 @@ + %{rdynamic:-export-dynamic} \ %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ -X \ + --as-needed \ @@ -178,64 +230,15 @@ Index: b/gcc/config/mips/gnu-user.h %{!shared: \ %{!static: \ %{rdynamic:-export-dynamic} \ -Index: b/libjava/Makefile.am -=================================================================== ---- a/libjava/Makefile.am -+++ b/libjava/Makefile.am -@@ -627,14 +631,14 @@ - rm .libs/libgcj_bc.so; \ - mv .libs/libgcj_bc.so.1.0.0 .libs/libgcj_bc.so; \ - $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ -- -o .libs/libgcj_bc.so.1.0.0 -lgcj || exit; \ -+ -o .libs/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ - rm .libs/libgcj_bc.so.1; \ - $(LN_S) libgcj_bc.so.1.0.0 .libs/libgcj_bc.so.1 - - ## This rule creates the libgcj_bc library that is actually installed. - install/libgcj_bc.la: $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_DEPENDENCIES) install/$(am__dirstamp) - $(libgcj_bc_la_LINK) $(am_libgcj_bc_la_rpath) $(libgcj_bc_la_LDFLAGS) \ -- $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -+ $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -Wl,--no-as-needed -lgcj - - ## Note that property_files is defined in sources.am. - propertyo_files = $(patsubst classpath/resource/%,%,$(addsuffix .lo,$(property_files))) -@@ -762,7 +766,7 @@ - rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ - mv $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ - $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ -- -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -lgcj || exit; \ -+ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ - rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ - $(LN_S) libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ - rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.la; - -Index: b/libjava/Makefile.in +Index: b/gcc/config/riscv/linux.h =================================================================== ---- a/libjava/Makefile.in -+++ b/libjava/Makefile.in -@@ -10644,13 +10648,13 @@ - rm .libs/libgcj_bc.so; \ - mv .libs/libgcj_bc.so.1.0.0 .libs/libgcj_bc.so; \ - $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ -- -o .libs/libgcj_bc.so.1.0.0 -lgcj || exit; \ -+ -o .libs/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ - rm .libs/libgcj_bc.so.1; \ - $(LN_S) libgcj_bc.so.1.0.0 .libs/libgcj_bc.so.1 - - install/libgcj_bc.la: $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_DEPENDENCIES) install/$(am__dirstamp) - $(libgcj_bc_la_LINK) $(am_libgcj_bc_la_rpath) $(libgcj_bc_la_LDFLAGS) \ -- $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -+ $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -Wl,--no-as-needed -lgcj - - $(propertyo_files): %.lo: classpath/resource/% - $(mkinstalldirs) `dirname $@`; \ -@@ -12494,7 +12498,7 @@ - @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ - @USE_LIBGCJ_BC_TRUE@ mv $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ - @USE_LIBGCJ_BC_TRUE@ $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ --@USE_LIBGCJ_BC_TRUE@ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -lgcj || exit; \ -+@USE_LIBGCJ_BC_TRUE@ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ - @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ - @USE_LIBGCJ_BC_TRUE@ $(LN_S) libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ - @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.la; - +--- a/gcc/config/riscv/linux.h ++++ b/gcc/config/riscv/linux.h +@@ -50,6 +50,7 @@ + #define CPP_SPEC "%{pthread:-D_REENTRANT}" + + #define LINK_SPEC "\ ++-as-needed \ + -melf" XLEN_SPEC "lriscv \ + %{mno-relax:--no-relax} \ + %{shared} \ diff --git a/main/gcc/011_all_default-warn-format-security.patch b/main/gcc/011_all_default-warn-format-security.patch index a58383a8ec..f809abd9e7 100644 --- a/main/gcc/011_all_default-warn-format-security.patch +++ b/main/gcc/011_all_default-warn-format-security.patch @@ -1,43 +1,22 @@ Enable -Wformat and -Wformat-security by default. - ---- a/gcc/c-family/c.opt -+++ b/gcc/c-family/c.opt -@@ -412,7 +412,7 @@ C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning LangEnabledBy(C ObjC C++ O - Warn about format strings that are not literals +--- a/gcc/c-family/c.opt 2016-03-23 18:51:56.000000000 +0100 ++++ b/gcc/c-family/c.opt 2016-04-28 23:45:54.063351272 +0200 +@@ -459,7 +459,7 @@ C ObjC C++ ObjC++ Var(warn_format_nonlit + Warn about format strings that are not literals. Wformat-security -C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) +C ObjC C++ ObjC++ Var(warn_format_security) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) - Warn about possible security problems with format functions + Warn about possible security problems with format functions. - Wformat-y2k -@@ -424,7 +424,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ - Warn about zero-length formats + Wformat-signedness +@@ -475,7 +475,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_l + Warn about zero-length formats. Wformat= --C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) -+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) - Warn about printf/scanf/strftime/strfmon format string anomalies +-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) ++C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) + Warn about printf/scanf/strftime/strfmon format string anomalies. Wignored-qualifiers ---- a/gcc/doc/gcc.info -+++ b/gcc/doc/gcc.info -@@ -3451,6 +3451,8 @@ compiler warns that an unrecognized option is present. - '-Wno-format-contains-nul', '-Wno-format-extra-args', and - '-Wno-format-zero-length'. '-Wformat' is enabled by '-Wall'. - -+ This option is enabled by default in Alpine Linux. -+ - '-Wno-format-contains-nul' - If '-Wformat' is specified, do not warn about format strings - that contain NUL bytes. -@@ -3496,6 +3498,8 @@ compiler warns that an unrecognized option is present. - future warnings may be added to '-Wformat-security' that are - not included in '-Wformat-nonliteral'.) - -+ This option is enabled by default in Alpine Linux. -+ - '-Wformat-y2k' - If '-Wformat' is specified, also warn about 'strftime' formats - that may yield only a two-digit year. diff --git a/main/gcc/012_all_default-warn-trampolines.patch b/main/gcc/012_all_default-warn-trampolines.patch index 9ab4378d4d..7a644cb1e1 100644 --- a/main/gcc/012_all_default-warn-trampolines.patch +++ b/main/gcc/012_all_default-warn-trampolines.patch @@ -1,25 +1,13 @@ Enable -Wtrampolines by default. - --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -648,7 +648,7 @@ Common Var(warn_system_headers) Warning - Do not suppress warnings from system headers +@@ -712,7 +712,7 @@ Common Var(warn_system_headers) Warning + Do not suppress warnings from system headers. Wtrampolines -Common Var(warn_trampolines) Warning +Common Var(warn_trampolines) Init(1) Warning - Warn whenever a trampoline is generated + Warn whenever a trampoline is generated. Wtype-limits ---- a/gcc/doc/gcc.info -+++ b/gcc/doc/gcc.info -@@ -4021,6 +4021,8 @@ compiler warns that an unrecognized option is present. - and thus requires the stack to be made executable in order for the - program to work properly. - -+ This warning is enabled by default in Gentoo. -+ - '-Wfloat-equal' - Warn if floating-point values are used in equality comparisons. - diff --git a/main/gcc/013_all_default-ssp-fix.patch b/main/gcc/013_all_default-ssp-fix.patch new file mode 100644 index 0000000000..d2deac760b --- /dev/null +++ b/main/gcc/013_all_default-ssp-fix.patch @@ -0,0 +1,38 @@ +Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding +Change the buffer size. + +--- a/gcc/gcc.c 2017-07-04 09:15:57.740793000 +0200 ++++ b/gcc/gcc.c 2018-03-02 13:58:44.387741114 +0100 +@@ -857,6 +857,12 @@ proper position among the other output f + #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G" + #endif + ++#ifdef ENABLE_DEFAULT_SSP ++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} " ++#else ++#define NO_SSP_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1131,7 +1148,7 @@ static const char *cc1_options = + %{-version:--version}\ + %{-help=*:--help=%*}\ + %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ +- %{fsyntax-only:-o %j} %{-param*}\ ++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\ + %{coverage:-fprofile-arcs -ftest-coverage}\ + %{fprofile-arcs|fprofile-generate*|coverage:\ + %{!fprofile-update=singel:\ +--- a/gcc/params.def 2016-03-30 09:47:40.000000000 +0200 ++++ b/gcc/params.def 2016-09-19 12:56:58.443179039 +0200 +@@ -673,7 +673,7 @@ DEFPARAM (PARAM_INTEGER_SHARE_LIMIT, + DEFPARAM (PARAM_SSP_BUFFER_SIZE, + "ssp-buffer-size", + "The lower bound for a buffer to be considered for stack smashing protection.", +- 8, 1, 0) ++ 4, 1, 0) + + DEFPARAM (PARAM_MIN_SIZE_FOR_STACK_SHARING, + "min-size-for-stack-sharing", diff --git a/main/gcc/067_all_gcc-poison-system-directories.patch b/main/gcc/067_all_gcc-poison-system-directories.patch deleted file mode 100644 index 1036716175..0000000000 --- a/main/gcc/067_all_gcc-poison-system-directories.patch +++ /dev/null @@ -1,194 +0,0 @@ -http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch - -From d76250323dad69212c958e4857a98d99ab51a39e Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 08:59:00 +0400 -Subject: [PATCH 10/46] gcc: poison-system-directories - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [distribution: codesourcery] ---- - gcc/common.opt | 4 ++++ - gcc/config.in | 6 ++++++ - gcc/configure | 16 ++++++++++++++++ - gcc/configure.ac | 10 ++++++++++ - gcc/doc/invoke.texi | 9 +++++++++ - gcc/gcc.c | 2 ++ - gcc/incpath.c | 19 +++++++++++++++++++ - 7 files changed, 66 insertions(+) - -diff --git a/gcc/common.opt b/gcc/common.opt -index 67048db..733185c 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -659,6 +659,10 @@ Wreturn-local-addr - Common Var(warn_return_local_addr) Init(1) Warning - Warn about returning a pointer/reference to a local or temporary variable. - -+Wpoison-system-directories -+Common Var(flag_poison_system_directories) Init(1) Warning -+Warn for -I and -L options using system directories if cross compiling -+ - Wshadow - Common Var(warn_shadow) Warning - Warn when one local variable shadows another. -diff --git a/gcc/config.in b/gcc/config.in -index 115cb61..105b30f 100644 ---- a/gcc/config.in -+++ b/gcc/config.in -@@ -187,6 +187,12 @@ - #endif - - -+/* Define to warn for use of native system header directories */ -+#ifndef USED_FOR_TARGET -+#undef ENABLE_POISON_SYSTEM_DIRECTORIES -+#endif -+ -+ - /* Define if you want all operations on RTL (the basic data structure of the - optimizer and back end) to be checked for dynamic type safety at runtime. - This is quite expensive. */ -diff --git a/gcc/configure b/gcc/configure -index 1c6e340..8f83152 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -942,6 +942,7 @@ with_system_zlib - enable_maintainer_mode - enable_link_mutex - enable_version_specific_runtime_libs -+enable_poison_system_directories - enable_plugin - enable_host_shared - enable_libquadmath_support -@@ -1681,6 +1682,8 @@ Optional Features: - --enable-version-specific-runtime-libs - specify that runtime libraries should be installed - in a compiler-specific directory -+ --enable-poison-system-directories -+ warn for use of native system header directories - --enable-plugin enable plugin support - --enable-host-shared build host code as shared libraries - --disable-libquadmath-support -@@ -28908,6 +28911,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : - fi - - -+# Check whether --enable-poison-system-directories was given. -+if test "${enable_poison_system_directories+set}" = set; then : -+ enableval=$enable_poison_system_directories; -+else -+ enable_poison_system_directories=no -+fi -+ -+if test "x${enable_poison_system_directories}" = "xyes"; then -+ -+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h -+ -+fi -+ - # Substitute configuration variables - - -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 6c1dcd9..0fccaef 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -5861,6 +5861,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, - [specify that runtime libraries should be - installed in a compiler-specific directory])]) - -+AC_ARG_ENABLE([poison-system-directories], -+ AS_HELP_STRING([--enable-poison-system-directories], -+ [warn for use of native system header directories]),, -+ [enable_poison_system_directories=no]) -+if test "x${enable_poison_system_directories}" = "xyes"; then -+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], -+ [1], -+ [Define to warn for use of native system header directories]) -+fi -+ - # Substitute configuration variables - AC_SUBST(subdirs) - AC_SUBST(srcdir) -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index 821f8fd..8bb49e7 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -284,6 +284,7 @@ Objective-C and Objective-C++ Dialects}. - -Wparentheses -Wno-pedantic-ms-format @gol - -Wplacement-new -Wplacement-new=@var{n} @gol - -Wpointer-arith -Wno-pointer-to-int-cast @gol -+-Wno-poison-system-directories @gol - -Wno-pragmas -Wredundant-decls -Wno-return-local-addr @gol - -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol - -Wshift-overflow -Wshift-overflow=@var{n} @gol -@@ -4723,6 +4724,14 @@ made up of data only and thus requires no special treatment. But, for - most targets, it is made up of code and thus requires the stack to be - made executable in order for the program to work properly. - -+@item -Wno-poison-system-directories -+@opindex Wno-poison-system-directories -+Do not warn for @option{-I} or @option{-L} options using system -+directories such as @file{/usr/include} when cross compiling. This -+option is intended for use in chroot environments when such -+directories contain the correct headers and libraries for the target -+system rather than the host. -+ - @item -Wfloat-equal - @opindex Wfloat-equal - @opindex Wno-float-equal -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 1af5920..4cfef7f 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1017,6 +1017,8 @@ proper position among the other output files. */ - "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ - "%X %{o*} %{e*} %{N} %{n} %{r}\ - %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ -+ %{Wno-poison-system-directories:--no-poison-system-directories} \ -+ %{Werror=poison-system-directories:--error-poison-system-directories} \ - %{static:} %{L*} %(mfwrap) %(link_libgcc) " \ - VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ - %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ -diff --git a/gcc/incpath.c b/gcc/incpath.c -index ea40f4a..856da41 100644 ---- a/gcc/incpath.c -+++ b/gcc/incpath.c -@@ -26,6 +26,7 @@ - #include "intl.h" - #include "incpath.h" - #include "cppdefault.h" -+#include "diagnostic-core.h" - - /* Microsoft Windows does not natively support inodes. - VMS has non-numeric inodes. */ -@@ -381,6 +382,24 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) - } - fprintf (stderr, _("End of search list.\n")); - } -+ -+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES -+ if (flag_poison_system_directories) -+ { -+ struct cpp_dir *p; -+ -+ for (p = heads[QUOTE]; p; p = p->next) -+ { -+ if ((!strncmp (p->name, "/usr/include", 12)) -+ || (!strncmp (p->name, "/usr/local/include", 18)) -+ || (!strncmp (p->name, "/usr/X11R6/include", 18))) -+ warning (OPT_Wpoison_system_directories, -+ "include location \"%s\" is unsafe for " -+ "cross-compilation", -+ p->name); -+ } -+ } -+#endif - } - - /* Use given -I paths for #include "..." but not #include <...>, and --- -2.8.2 - diff --git a/main/gcc/201-cilkrts.patch b/main/gcc/201-cilkrts.patch deleted file mode 100644 index 4aac10d6d9..0000000000 --- a/main/gcc/201-cilkrts.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 594e3c1ab576daddeb86015efc8b1677020b1878 Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Sat, 24 Oct 2015 20:39:30 +0000 -Subject: [PATCH 1/6] cilkrts - ---- - libcilkrts/runtime/os-unix.c | 22 +++++++--------------- - 1 file changed, 7 insertions(+), 15 deletions(-) - -diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c -index cb582dd..e43d7d5 100644 ---- a/libcilkrts/runtime/os-unix.c -+++ b/libcilkrts/runtime/os-unix.c -@@ -51,6 +51,7 @@ - #if defined __linux__ - # include - # include -+# include - #elif defined __APPLE__ - # include - // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output -@@ -400,28 +401,19 @@ COMMON_SYSDEP void __cilkrts_sleep(void) - - COMMON_SYSDEP void __cilkrts_yield(void) - { --#if __APPLE__ || __FreeBSD__ || __VXWORKS__ -- // On MacOS, call sched_yield to yield quantum. I'm not sure why we -- // don't do this on Linux also. -- sched_yield(); --#elif defined(__DragonFly__) -- // On DragonFly BSD, call sched_yield to yield quantum. -- sched_yield(); --#elif defined(__MIC__) -+#if defined(__MIC__) - // On MIC, pthread_yield() really trashes things. Arch's measurements - // showed that calling _mm_delay_32() (or doing nothing) was a better - // option. Delaying 1024 clock cycles is a reasonable compromise between - // giving up the processor and latency starting up when work becomes - // available - _mm_delay_32(1024); --#elif defined(__ANDROID__) || (defined(__sun__) && defined(__svr4__)) -- // On Android and Solaris, call sched_yield to yield quantum. I'm not -- // sure why we don't do this on Linux also. -- sched_yield(); --#else -- // On Linux, call pthread_yield (which in turn will call sched_yield) -- // to yield quantum. -+#elif defined(__sun__) && !defined(__svr4__) -+ // On old SunOS call pthread_yield to yield a quantum. - pthread_yield(); -+#else -+ // On other platforms call sched_yield to yield a quantum. -+ sched_yield(); - #endif - } - --- -2.8.1 - diff --git a/main/gcc/203-libgcc_s.patch b/main/gcc/203-libgcc_s.patch index c74351c713..f8cab7d194 100644 --- a/main/gcc/203-libgcc_s.patch +++ b/main/gcc/203-libgcc_s.patch @@ -45,12 +45,13 @@ diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux index 11bb46e..4f47f7b 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux -@@ -3,4 +3,4 @@ +@@ -3,5 +3,5 @@ # t-slibgcc-elf-ver and t-linux SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver --HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER -+HOST_LIBGCC2_CFLAGS += -mlong-double-80 +-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS) ++HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) + CRTSTUFF_T_CFLAGS += $(CET_FLAGS) -- 2.8.1 diff --git a/main/gcc/204-linux_libc_has_function.patch b/main/gcc/204-linux_libc_has_function.patch deleted file mode 100644 index 2dcedc3a7a..0000000000 --- a/main/gcc/204-linux_libc_has_function.patch +++ /dev/null @@ -1,25 +0,0 @@ -From edec78452d693fb524daa9a6efd45c850b27b25c Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Fri, 6 Nov 2015 23:59:20 +0000 -Subject: [PATCH 4/6] linux_libc_has_function - ---- - gcc/config/linux.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gcc/config/linux.c b/gcc/config/linux.c -index 250296b..16c3768 100644 ---- a/gcc/config/linux.c -+++ b/gcc/config/linux.c -@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see - bool - linux_libc_has_function (enum function_class fn_class) - { -- if (OPTION_GLIBC) -+ if (OPTION_GLIBC || OPTION_MUSL) - return true; - if (OPTION_BIONIC) - if (fn_class == function_c94 --- -2.8.1 - diff --git a/main/gcc/207-static-pie.patch b/main/gcc/207-static-pie.patch deleted file mode 100644 index 9355c584b5..0000000000 --- a/main/gcc/207-static-pie.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h -index b0bf40a..d4b56fe 100644 ---- a/gcc/config/gnu-user.h -+++ b/gcc/config/gnu-user.h -@@ -51,10 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - #if defined HAVE_LD_PIE - #define GNU_USER_TARGET_STARTFILE_SPEC \ - "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ -- %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \ -- crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \ -+ %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \ -+ crti.o%s %{shared:crtbeginS.o%s;: \ - %{" PIE_SPEC ":crtbeginS.o%s} \ -- %{" NO_PIE_SPEC ":crtbegin.o%s}} \ -+ %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \ - %{fvtable-verify=none:%s; \ - fvtable-verify=preinit:vtv_start_preinit.o%s; \ - fvtable-verify=std:vtv_start.o%s} \ -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 0208d61..731564e 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -870,7 +870,7 @@ proper position among the other output files. */ - #endif - - #ifdef ENABLE_DEFAULT_PIE --#define NO_PIE_SPEC "no-pie|static" -+#define NO_PIE_SPEC "no-pie" - #define PIE_SPEC NO_PIE_SPEC "|r|shared:;" - #define NO_FPIE1_SPEC "fno-pie" - #define FPIE1_SPEC NO_FPIE1_SPEC ":;" -@@ -916,7 +916,7 @@ proper position among the other output files. */ - #ifndef LINK_PIE_SPEC - #ifdef HAVE_LD_PIE - #ifndef LD_PIE_SPEC --#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic}" - #endif - #else - #define LD_PIE_SPEC "" diff --git a/main/gcc/300-main-gcc-add-musl-s390x-dynamic-linker.patch b/main/gcc/300-main-gcc-add-musl-s390x-dynamic-linker.patch deleted file mode 100644 index 2419578715..0000000000 --- a/main/gcc/300-main-gcc-add-musl-s390x-dynamic-linker.patch +++ /dev/null @@ -1,32 +0,0 @@ -From be841c16dd544553c67faac79bd4cc3cd10a1dc0 Mon Sep 17 00:00:00 2001 -From: "Tuan M. Hoang" -Date: Mon, 21 Nov 2016 01:42:16 +0700 -Subject: [PATCH] main/gcc: add musl s390x dynamic linker - ---- - gcc/config/s390/linux.h | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h -index 1e3ed35..a244214 100644 ---- a/gcc/config/s390/linux.h -+++ b/gcc/config/s390/linux.h -@@ -63,6 +63,15 @@ along with GCC; see the file COPYING3. If not see - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" - #define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1" - -+#undef MUSL_DYNAMIC_LINKER -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-s390x.so.1" -+#undef MUSL_DYNAMIC_LINKER32 -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390x.so.1" -+#undef MUSL_DYNAMIC_LINKER64 -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1" -+#undef MUSL_DYNAMIC_LINKERX32 -+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-s390x.so.1" -+ - #undef LINK_SPEC - #define LINK_SPEC \ - "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \ --- -2.10.2 - diff --git a/main/gcc/310-build-gcj-s390x.patch b/main/gcc/310-build-gcj-s390x.patch deleted file mode 100644 index 1e522ee152..0000000000 --- a/main/gcc/310-build-gcj-s390x.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 697a7ba791fce2ffab2ed723d909a89684019e3d Mon Sep 17 00:00:00 2001 -From: "Tuan M. Hoang" -Date: Sun, 19 Feb 2017 17:03:33 +0000 -Subject: [PATCH] main/gcc : when building gcc-java on s390x, libgcj.so - complains about undefined reference to __data_start. Using - SEARCH_FOR_DATA_START instead solved it. Credit to Andrew Haley at RedHat. - ---- - boehm-gc/include/private/gcconfig.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h -index 4ca6a80..a15fff6 100644 ---- a/boehm-gc/include/private/gcconfig.h -+++ b/boehm-gc/include/private/gcconfig.h -@@ -1837,8 +1837,7 @@ - # define OS_TYPE "LINUX" - # define LINUX_STACKBOTTOM - # define DYNAMIC_LOADING -- extern int __data_start[]; --# define DATASTART ((ptr_t)(__data_start)) -+# define SEARCH_FOR_DATA_START - extern int _end[]; - # define DATAEND (_end) - # define CACHE_LINE_SIZE 256 --- -2.11.1 - diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD index 87798b45bd..a6d9a7841c 100644 --- a/main/gcc/APKBUILD +++ b/main/gcc/APKBUILD @@ -1,12 +1,12 @@ # Maintainer: Natanael Copa pkgname=gcc -pkgver=6.4.0 +pkgver=8.2.0 [ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname="$pkgname$_target" -pkgrel=8 +pkgrel=0 pkgdesc="The GNU Compiler Collection" url="http://gcc.gnu.org" arch="all" @@ -21,7 +21,6 @@ replaces="libstdc++ binutils" : ${LANG_CXX:=true} : ${LANG_OBJC:=true} -: ${LANG_JAVA:=true} : ${LANG_GO:=true} : ${LANG_FORTRAN:=true} : ${LANG_ADA:=true} @@ -41,7 +40,6 @@ if [ "$CHOST" != "$CTARGET" ]; then _builddir="$srcdir/build-cross-final" fi LANG_OBJC=false - LANG_JAVA=false LANG_GO=false LANG_FORTRAN=false LIBGOMP=false @@ -78,7 +76,6 @@ elif [ "$CBUILD" != "$CHOST" ]; then # Languages that do not need bootstrapping LANG_OBJC=false - LANG_JAVA=false LANG_GO=false LANG_FORTRAN=false @@ -124,10 +121,6 @@ if $LANG_OBJC; then subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" _languages="$_languages,objc" fi -if $LANG_JAVA; then - subpackages="$subpackages libgcj::$CTARGET_ARCH gcc-java$_target:java" - _languages="$_languages,java" -fi if $LANG_GO; then subpackages="$subpackages libgo::$CTARGET_ARCH gcc-go$_target:go" _languages="$_languages,go" @@ -144,67 +137,44 @@ fi makedepends="$makedepends_build $makedepends_host" source="http://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz - http://sourceware.org/pub/java/ecj-4.9.jar - - 001_all_default-ssp-strong.patch 002_all_default-relro.patch 003_all_default-fortify-source.patch 005_all_default-as-needed.patch + gcc-as-needed-gold.patch + gcc-as-needed-push-pop.patch 011_all_default-warn-format-security.patch 012_all_default-warn-trampolines.patch + 013_all_default-ssp-fix.patch 020_all_msgfmt-libstdc++-link.patch 050_all_libiberty-asprintf.patch 051_all_libiberty-pic.patch 053_all_libitm-no-fortify-source.patch - 067_all_gcc-poison-system-directories.patch 090_all_pr55930-dependency-tracking.patch + 0003-gcc-poison-system-directories.patch - 201-cilkrts.patch 203-libgcc_s.patch - 204-linux_libc_has_function.patch 205-nopie.patch - 207-static-pie.patch + 0002-posix_memalign.patch + 0008-s390x-muslldso.patch + 0010-ldbl128-config.patch + 0012-static-pie.patch libgcc-always-build-gcceh.a.patch gcc-4.9-musl-fortify.patch gcc-6.1-musl-libssp.patch - boehm-gc-musl.patch gcc-pure64.patch - fix-gcj-stdgnu14-link.patch - fix-gcj-musl.patch - fix-gcj-iconv-musl.patch - gcc-4.8-build-args.patch fix-cxxflags-passing.patch - ada-fixes.patch ada-shared.patch ada-musl.patch - ada-aarch64-multiarch.patch - 300-main-gcc-add-musl-s390x-dynamic-linker.patch - 310-build-gcj-s390x.patch 320-libffi-gnulinux.patch - fix-rs6000-pie.patch - fix-linux-header-use-in-libgcc.patch gcc-pure64-mips.patch - ada-mips64.patch - - 0001-i386-Move-struct-ix86_frame-to-machine_function.patch - 0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch - 0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch - 0004-x86-Add-mindirect-branch.patch - 0005-x86-Add-mfunction-return.patch - 0006-x86-Add-mindirect-branch-register.patch - 0007-x86-Add-V-register-operand-modifier.patch - 0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch - 0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch - 0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch - 0011-i386-Update-mfunction-return-for-return-with-pop.patch - 0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch - 0013-i386-Don-t-generate-alias-for-function-return-thunk.patch " +# gcc-4.8-build-args.patch + # we build out-of-tree _gccdir="$srcdir"/gcc-${_pkgbase:-$pkgver} _gcclibdir=/usr/lib/gcc/${CTARGET}/$pkgver @@ -218,7 +188,7 @@ prepare() { case "$i" in *.patch) msg "Applying $i" - patch -p1 -F3 -i "$srcdir"/$i || _err="$_err $i" + patch -p1 -i "$srcdir"/$i || _err="$_err $i" ;; esac done @@ -231,9 +201,6 @@ prepare() { return 1 fi - # see http://gcc.gnu.org/ml/java/2008-04/msg00027.html - mv "$srcdir"/ecj-*.jar ecj.jar - echo ${pkgver} > gcc/BASE-VER } @@ -324,6 +291,7 @@ build() { $_symvers \ --enable-__cxa_atexit \ --enable-default-pie \ + --enable-default-ssp \ --enable-cloog-backend \ --enable-languages=$_languages \ $_arch_configure \ @@ -343,10 +311,9 @@ package() { # we dont support gcj -static # and saving 35MB is not bad. - find "$pkgdir" -name libgcj.a -o -name libgtkpeer.a \ - -o -name libgjsmalsa.a -o -name libgcj-tools.a \ - -o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \ - -o -name libjavamath.a \ + find "$pkgdir" -name libgtkpeer.a \ + -o -name libgjsmalsa.a -o \ + -o -name libgij.a -o \ | xargs rm -f # strip debug info from some static libs @@ -357,11 +324,6 @@ package() { -o -name libatomic.a -o -name libasan.a -o -name libtsan.a \) \ -a -type f` - if $LANG_JAVA; then - sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \ - "$pkgdir"/usr/lib/libgcj.spec - fi - if $LIBGOMP; then mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir fi @@ -505,59 +467,6 @@ libgomp() { mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgomp.so.* "$subpkgdir"/usr/lib/ } -java() { - pkgdesc="Java support for GCC" - depends="zlib-dev gcc=$_gccrel libgcj=$_gccrel" - - paxmark -pm "$pkgdir"/$_gcclibexec/ecj1 - mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib "$subpkgdir"/$_gcclibdir/ - cd "$pkgdir"/usr/bin - mv gcj gcj-dbtool gjavah gcjh jcf-dump "$subpkgdir"/usr/bin/ - cd "$pkgdir" - for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do - mkdir -p "$subpkgdir"/${i%/*} - mv "$pkgdir"/$i "$subpkgdir"/$i - done - for i in "$pkgdir"/usr/lib/libgcj*.so; do - if [ -L "$i" ]; then - mv "$i" "$subpkgdir"/usr/lib/ - fi - done - mv "$pkgdir"/usr/lib/libgij.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgcj.spec "$subpkgdir"/$_gcclibdir/ -} - -libgcj() { - pkgdesc="Java runtime library for gcc" - # libgcj_bc.so moved from gcc-java to libgcj - replaces="gcc-java" - depends= - - mkdir -p "$subpkgdir"/usr/bin - cd "$pkgdir"/usr/bin - paxmark -pmse "$pkgdir"/usr/bin/gij - mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\ - gnative2ascii gorbd grmic grmid grmiregistry gserialver \ - gtnameserv jv-convert rebuild-gcj-db \ - "$subpkgdir"/usr/bin/ - cd "$pkgdir" - for i in $(find usr/lib -name jc1 -o -name jvgenmain); do - mkdir -p "$subpkgdir"/${i%/*} - mv "$pkgdir"/$i "$subpkgdir"/$i - done - mkdir -p "$subpkgdir"/usr/lib - mv "$pkgdir"/usr/lib/gcj-* \ - "$pkgdir"/usr/lib/libgcj_bc.so \ - "$pkgdir"/usr/lib/libgcj*.so.* \ - "$pkgdir"/usr/lib/libgij.so.* \ - "$pkgdir"/usr/lib/logging.properties \ - "$pkgdir"/usr/lib/security \ - "$subpkgdir"/usr/lib/ - - mkdir -p "$subpkgdir"/usr/share/ - mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/ -} - libgo() { pkgdesc="Go runtime library for GCC" depends= @@ -643,56 +552,33 @@ gnat() { mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/ } -sha512sums="02c60e54527c7adf584798d5251f8a0b80c93d5deafce82501b2c28e6692e0bd783927bbfc4bc527a863c0cccc025150a34740a9e29badb02d4b48e56a8aba90 gcc-6.4.0.tar.xz -28f8c6fdbcb19e950b1d0bafb3bcc7a8cba87bc673aa6027cece116599cdee80f0cf5e95a1440544890239f5c754e8a93ab46d9daedd937faef445d7ea33b226 ecj-4.9.jar -a1335adc2fbee98e36c4437ff2587771b98ed4180726779020f65039498235626a411cdb0100dbd20cd19d12f0d94f9a21af179ff624676c28cead9d60598b5d 001_all_default-ssp-strong.patch +sha512sums="64898a165f67e136d802a92e7633bf1b06c85266027e52127ea025bf5fc2291b5e858288aac0bdba246e6cdf7c6ec88bc8e0e7f3f6f1985f4297710cafde56ed gcc-8.2.0.tar.xz e36e95b81489163abd6fe9d58f7867bdca43e61143afacbfb17f4698c0b16ec5fd0061d8fab7b2ae615540bebd721c2e2227f80401b4e7fc253da9da62e6b513 002_all_default-relro.patch f86466c62b8291fac46f9c250c7ad8fa5ab7b1cce2504442fd07ddc4543665b317ae28951f244e39aba29aeaf3fff252ec4f6a147aa16adb2b7aed747dd89188 003_all_default-fortify-source.patch -51282fea54c7e616367bbeb2479ba13fec6f24eb47bd04e2071907b3b36273b2ff24676f46ef8d22f241c8ab4857307861eee076eab66797c3a50a8ecaa1809a 005_all_default-as-needed.patch -3398386dd1e079d6545dd9799adc799c6b80e3984fac6899d0e1a7ee21b66d0c7e53cddf17a65d590c883db750f9f79aaedd857355a8b9f7fb9476c906237919 011_all_default-warn-format-security.patch -9adb0d2b9b67dd957df6c609b8714c7c078efb52cd88770905c37c67827be8fc83d1125037b9c29d77db21ce78756aa2bb0bacdb0b98d869ac126da76a298e21 012_all_default-warn-trampolines.patch +02b725b220e540077efef741e9d457f9e004fe53ae642a138e214875d076a60f7c2f27de0ed9a4225db2030fc9c3d2c5b0414c895b9eec0f5f48fad70e2fb029 005_all_default-as-needed.patch +6c9a5068f6eea8a85d297a3555b1d2333ffd4b9ddbfb7560a3e643f8577603871ca123373ef7f96e894225291d88f7bf575c7f8386bcfdd1dabcd7ba12598b65 gcc-as-needed-gold.patch +ab0df1862f1b645634e79b8101326ce53215eba39861a455cd145b81b5267a6a61bc6e76b32d53887a0a48873f7efc23e2c52cc04400c6afd89822f245cdbc77 gcc-as-needed-push-pop.patch +e026bf9f73ee254528423c6cabdfd7794960c567161581b7d4b7c61c45027e12a6efef79662d4288b9cbaecb4798f01af6a5b4a13b766c2d501444ac1846fd43 011_all_default-warn-format-security.patch +37de4cc9061bfe1963e6e6570e1a6bbfd58204bf90e0eef819882599a9a80ea28f3eb815c20c1f173dc25d4bd9971b7c7f7f9512d6f8f91f04de1e1175114d4d 012_all_default-warn-trampolines.patch +38a0fedeac3eebe4a6a957792ba520225cf42663c96a171cd168fdb6c91ffa9a56b80351f8238c5d03b78d3ae2a6539a54481fe4848b4a395e2c87f2ff7adc08 013_all_default-ssp-fix.patch d35a3ac7e13a4446921a90e1ff3eec1079840c845f9d523c868e24ae21f94cf69ba041de5341ebef96432a6f57598e223381d4286e8fb8baaa25906707f29fbd 020_all_msgfmt-libstdc++-link.patch 840070a3c423e6206aaa6e63e1d9a0fcd6efd53626cd1240a193f0b60aa5d84216acc4a2a4fa8bce74549b07e6a316b01d638f20cea13dc62473491a302fb3d6 050_all_libiberty-asprintf.patch 0a0bc72b9366158f5d23fff1928e756fdd212433bac6ab1f00d632f241382820db8db5d475ddf11ea020eaf7e2e71b12fb9b1c3c870cf84adf6c2b16f15aabca 051_all_libiberty-pic.patch e7a2eb1b1870e199d6fd753d065781575656fa12baa264f96c5d179689d88c31b8a3f92a5dae96088c05e96aa2bda138364ad7dbcc79e1819a102f192cbb7bab 053_all_libitm-no-fortify-source.patch -e87da18aa7ab92b02b06168658c63b42a6c73a08fad2a30f81ef6296100fdbe3c3a91548fd0cb24eaf591e862bb08e4b67249bc4b977b07da33523aee0c686bc 067_all_gcc-poison-system-directories.patch 4a328d1e1a56c20166307edcfa322068915784d9c08025b7f81cf69714da48fc266b6d34f77b9135c2f10da830d9df408276a1b78d1fd218637c2823506593c2 090_all_pr55930-dependency-tracking.patch -ef052d0c3c9642fcb5ed570069c5a49c8ef523c47ac8ce3f201a801766f72ae4ff7c3725a70ee66e52c0fb559621e35fe0cf5b88b901d71ceadd381f49653a08 201-cilkrts.patch -808e206f5e107084156fba333d4e091dcbd62f5d7756142bc292d4b0a52619f8c2aaca3617defc2f5b6552ba0439aebd33f4141329d88eab6ddf2dd637d92c08 203-libgcc_s.patch -fc0de05b36613b732a0222ea005c90653c6a40d6761b6894af2419272f4e74875f37e26af33a9b9940669ef89269c44c46d17ca5bcd54b5cd1176e5eaf2992c1 204-linux_libc_has_function.patch +3842bd2be3e53db34e59bfb2bd438b244fc3712055058b9e232e33345f0fab216256b79e364fbac335972dc599a1d74393704f0cd595f3f076dcc10883c85b28 0003-gcc-poison-system-directories.patch +d1c2d7ff7f673375dc7cd84ae9d8515853b5af6390c70bb763412c012101344e4ee1ce155151ce3fb6ba2b80af7ed42d697dbe1bf6fd6e7b2b9087a378c47c37 203-libgcc_s.patch 98473bcaa77903a223ca9b0d2087c0921b287a2816d308cc32c8fe009e6cbf5dd1ae7fba27794ab8d9c09e117fe534413d91a464d1218474fc123ce0adfdc2c1 205-nopie.patch -3287d5b443bea8ec64132bcabe869c738ae98ea8f1a86df1c5d18c927f8816edbfcefeefc47792dbbb2bcacf50319af00e01b3735d34525913b64350770ad453 207-static-pie.patch +6d84354e6df96d5ea244eb3bb5f044781796b88040b11c78fb6ee509e5aac19d46e0e92ca836e98e6495d9751f52439833b748efc419e4f5d5301fb549c4dcc9 0002-posix_memalign.patch +7f434a7350c9b06d0ae7cc18a569d813238483afa34b0801d112844a0dfe6164ae36b0416955fd4da7a8caa54672247f319a8ec7ce4b6a97a5f4e17ec083112a 0008-s390x-muslldso.patch +66085c5555e6b91b6874d1782d5a1dc0ab1792889f9400f48cde9483f82b51b9e3a5de1efbba21a19fc5e664334f2188d0c2bc988d42335efa26118b3c85cc7f 0010-ldbl128-config.patch +45d5bc11a89e5af77503ca06eec52d6d84e6fea0be021aaee1bcc39f8dd3c7b4baa4200cfa2b0688faa0f207d005db89c029eff32f362207aa3d2365b2f2363e 0012-static-pie.patch d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b libgcc-always-build-gcceh.a.patch 600fe5098dc54edaa9808fd5717af9dec058953f9ad37d49cfba1db4f7e9a7a8f02019342f75157fc575946fa693259422184de27b7ecc8386d9f3ecc0f7cc5d gcc-4.9-musl-fortify.patch dbe0ee917fc7668571722364ab7c806731e3a31e8bfa30b4941b28b16b877d2a32b4a3897ef533399a28f82d43cac9b28e92de0493f0e779046db56584e07fa4 gcc-6.1-musl-libssp.patch -bda845a6aa1854d2c883910b115f79ccfa93dfc2b5eac69a3a236d83eb34cadc140731d616ffc24698c7abc8878dd15f231bcc5119f1860e575a120b311706c7 boehm-gc-musl.patch fa62556719449caec6b2b434355bfbcaa5ae55ffe017b3e1f827f66a2aae21b79c571ee7a4ce723ea69169bc3a6447e73650991a200cc372adf2f102677518d7 gcc-pure64.patch -2253941f3d19b6d08801d3782f5f5ed56c3b73fbc9d3561a8f01c702963ac4fab91599c686076e7081eb6a80c37ccd33591ae978996d6eee1dc0ce0f1c50259a fix-gcj-stdgnu14-link.patch -f89ddeb21bc8f97e6a850a6b70b4501a8f3e49a4bc8cc82897488decda5d98ad01cb7f6c8b392d452e9579924a523bc75da6e0648c1c976d42e40af48b10343b fix-gcj-musl.patch -54d67cc008b735e47771314171930c5d8b8f5f5dc97fcf4214824c105c808f3e75d22d5a4fdf5068ed0457fa0d46c60cfb442e276259a4a5e9b8722a027d18e6 fix-gcj-iconv-musl.patch -abe9aaf9aa956058d0386a4396a511d176a46bb3906b90e952383646cdc158cbeb0a5dc616a1ccb1ca7d49fd0b5e351532aa15a3b13362abbf1ca4266f54a687 gcc-4.8-build-args.patch 35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282 fix-cxxflags-passing.patch -9016b257abd8fa981de44a49512e35db814d1cbb47c1a87cd31c12d4ae20b13e9e149fe41691a7ec3c95bbcfde8a79194a8d2eaf547ceade3a246fad67c47dd8 ada-fixes.patch 3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19 ada-shared.patch -631d4bdef6d8bde34df7978bb53ec28c3c909cf1f87139e5f148138d0f09adc58b41ecf0148bbf50fb4bc916c411e9bf8a2b6c046c75c0e77d754d8c35bcd4d7 ada-musl.patch -fa44c8158111627aa0e91c43e7cc3aa38642c2041c96532dd4f0932dae4d6f92ea2850b683abcf10e7e120299d42ea6b69adc00002a514c76be8e39e99fa052b ada-aarch64-multiarch.patch -4b4a0ff306a8ef34ff6e3284fbfca869012164a47ba7cb099085c1dd03e6ca0cdd462f82710e08c9a02895adc7484e4c5eef17b5aa264cf5d978fe8ad78eea93 300-main-gcc-add-musl-s390x-dynamic-linker.patch -385bc2fa50204f678964e5148c6170f572701dab920fbec8301f505bda34d182cde0adb7da042fee71719e12fb59f59181897f9b1bb4f4716ff59aad46ca1998 310-build-gcj-s390x.patch +50537add461714f44dc6a778e0c6d0e15d6a782591c8aff38d1fb559191ddac2b5ee14a43a3005b389fdf98d2e7468ff4e64c88ba024cf94f9fe0d9854b9e9c8 ada-musl.patch f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45b58ba8764ab1eb575d4eb6d6dfc550a87a183f8b94e76181 320-libffi-gnulinux.patch -01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed fix-rs6000-pie.patch -34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c fix-linux-header-use-in-libgcc.patch -86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch -508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch -7912964bf3a985e9f870250d6e068f715582a4fb04270849d697a50e6aad0cf50df3d483ff80a0eb777d9940fd85526dd8d0b85da9bc71a5f2fbc07616263866 0001-i386-Move-struct-ix86_frame-to-machine_function.patch -baa27a4b912d8e27cd65a556b09cf45289a0e00e86dae3925f2923d1f3752080e80d80e159c996ef4156c4df1dfc3069114810a846672170ef3ae461ae0ab7e1 0002-i386-Use-reference-of-struct-ix86_frame-to-avoid-cop.patch -6701d15000bdd7c4c98a8fece8c814f5e4e73603eecf84fe4dc5ac10f79b3074afba7c2cc9e51d08b2abade1c34cb0c944c08ead7a85db94e97158c752fd1aac 0003-i386-Use-const-reference-of-struct-ix86_frame-to-avo.patch -4e7e71ae57e232b29a6455ec977f60b47df1356eca0e85976ae2b4567c4c39541be9f10c30fe0085d69be5acdb61dff51d3e9d7af587c95d9cd2cb9ee307bd13 0004-x86-Add-mindirect-branch.patch -07f7fdbd9b4876f36ed7715a35a369dbaf1016f46c42a8935930cfcc9ea250de2dbe8113f077373ccce3c39cd728f957b6c4c7c6a7da299f160a4109f0bbe88d 0005-x86-Add-mfunction-return.patch -76ea947591e5241f8e6216ce337baaf1b5dfe3f02d8251f77a4acd70e2a5e7798e2867d70f452027f51a2e3baf1b5c94c3bffe9ef8e0a5ce24dc5d509adaf414 0006-x86-Add-mindirect-branch-register.patch -1c33c5cd34efb44d4fa0ace56e3d27ec802a66e03b08a29ab6122cbc70edbbe22313a34114437a41e09e0a6869af3cea3fb18f5bcb49db2f8e3f155026fe15f0 0007-x86-Add-V-register-operand-modifier.patch -5366e2cff0629304394bf35e9417c7faea6b6f3fc565d0410a17fdafcb2b30c9a218f8ca098274c09ca4c982ff5b178ad6df5bf464ec541aa086966915c7fe11 0008-x86-Disallow-mindirect-branch-mfunction-return-with-.patch -67c738b1f6afb09b6f0469c9cb282ab4d51fc8dd8e39df1cfdff8831788c1022081fccd446a482623f649898733aeaaa205cba0aa41162cdbdc74e57de9bb6eb 0009-Use-INVALID_REGNUM-in-indirect-thunk-processing.patch -b7b59f3203bf53168de2170b91738cd456f6ae205b3fe5bf8aacbaa8cc5624dd09c941ad8f1071d1ab8ab4fb5f69068a4bc792c0486fdec1ee2eb9c83688bb78 0010-i386-Pass-INVALID_REGNUM-as-invalid-register-number.patch -c53d4c5968865abb709ee8a9af9d57917d43ea3ba31ee8312f9e8f338e9b1b44babf5aa3414848da7267e5cf13a9261815eb9185dc153cbd41ee7ce5ea23d2d0 0011-i386-Update-mfunction-return-for-return-with-pop.patch -955080ba3e42cfe2f604e5dcef46aa6fca7c899c7808398947af655ff3b7954e30807ef85246986a5cc7db36dbc870db151e9fa8d8bc967b89ea56efdf64614c 0012-i386-Add-TARGET_INDIRECT_BRANCH_REGISTER.patch -3aae3a9cef8e8afe5a5433db8d9f410e1a2882481af01bb1d33232f987dbb74d7780c32be70b868bb391b3601b65ed3a16d777afea946f5eeaff72aa1e7fa3a9 0013-i386-Don-t-generate-alias-for-function-return-thunk.patch" +86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch" diff --git a/main/gcc/ada-aarch64-multiarch.patch b/main/gcc/ada-aarch64-multiarch.patch deleted file mode 100644 index ac60b6f6a2..0000000000 --- a/main/gcc/ada-aarch64-multiarch.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- gcc-6.4.0/gcc/ada/gcc-interface/Makefile.in.orig -+++ gcc-6.4.0/gcc/ada/gcc-interface/Makefile.in -@@ -2042,13 +2042,8 @@ - system.ads - #else - #include -+#include - #endif - - #ifdef __MINGW32__ ---- gcc-6.1.0.orig/gcc/ada/terminals.c -+++ gcc-6.1.0/gcc/ada/terminals.c -@@ -1068,13 +1068,6 @@ - #include - #include - --/* On some system termio is either absent or including it will disable termios -- (HP-UX) */ --#if !defined (__hpux__) && !defined (BSD) && !defined (__APPLE__) \ -- && !defined (__rtems__) --# include --#endif -- - #include - #include - #include -@@ -1169,7 +1162,7 @@ - char *slave_name = NULL; - - #ifdef USE_GETPT -- master_fd = getpt (); -+ master_fd = posix_openpt (O_RDWR); - #elif defined (USE_OPENPTY) - status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); - #elif defined (USE_CLONE_DEVICE) diff --git a/main/gcc/ada-mips64.patch b/main/gcc/ada-mips64.patch deleted file mode 100644 index b7cd3debcf..0000000000 --- a/main/gcc/ada-mips64.patch +++ /dev/null @@ -1,224 +0,0 @@ -From 5bbd6ca3755e2a199de98d2b270d8a6f616aa6a6 Mon Sep 17 00:00:00 2001 -From: Nils Andreas Svee -Date: Thu, 21 Dec 2017 16:46:12 +0100 -Subject: [PATCH] ada-mips64 - ---- - gcc/ada/gcc-interface/Makefile.in | 29 ++++++-- - gcc/ada/system-linux-mips64.ads | 147 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 171 insertions(+), 5 deletions(-) - create mode 100644 gcc/ada/system-linux-mips64.ads - -diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in -index 598b262d9..1844a6962 100644 ---- a/gcc/ada/gcc-interface/Makefile.in -+++ b/gcc/ada/gcc-interface/Makefile.in -@@ -1854,9 +1854,9 @@ ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(target_os))),) - LIBRARY_VERSION := $(LIB_VERSION) - endif - --# Mips Linux --ifeq ($(strip $(filter-out mips linux%,$(target_cpu) $(target_os))),) -- LIBGNAT_TARGET_PAIRS = \ -+# Mips and Mips64 Linux -+ifeq ($(strip $(filter-out mips mips64 linux%,$(target_cpu) $(target_os))),) -+ LIBGNAT_TARGET_PAIRS_COMMON = \ - a-intnam.ads. -- -+-- -- -+-- GNAT was originally developed by the GNAT team at New York University. -- -+-- Extensive contributions were provided by Ada Core Technologies Inc. -- -+-- -- -+------------------------------------------------------------------------------ -+ -+package System is -+ pragma Pure; -+ -- Note that we take advantage of the implementation permission to make -+ -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada -+ -- 2005, this is Pure in any case (AI-362). -+ -+ pragma No_Elaboration_Code_All; -+ -- Allow the use of that restriction in units that WITH this unit -+ -+ type Name is (SYSTEM_NAME_GNAT); -+ System_Name : constant Name := SYSTEM_NAME_GNAT; -+ -+ -- System-Dependent Named Numbers -+ -+ Min_Int : constant := Long_Long_Integer'First; -+ Max_Int : constant := Long_Long_Integer'Last; -+ -+ Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; -+ Max_Nonbinary_Modulus : constant := Integer'Last; -+ -+ Max_Base_Digits : constant := Long_Long_Float'Digits; -+ Max_Digits : constant := Long_Long_Float'Digits; -+ -+ Max_Mantissa : constant := 63; -+ Fine_Delta : constant := 2.0 ** (-Max_Mantissa); -+ -+ Tick : constant := 0.000_001; -+ -+ -- Storage-related Declarations -+ -+ type Address is private; -+ pragma Preelaborable_Initialization (Address); -+ Null_Address : constant Address; -+ -+ Storage_Unit : constant := 8; -+ Word_Size : constant := 64; -+ Memory_Size : constant := 2 ** 64; -+ -+ -- Address comparison -+ -+ function "<" (Left, Right : Address) return Boolean; -+ function "<=" (Left, Right : Address) return Boolean; -+ function ">" (Left, Right : Address) return Boolean; -+ function ">=" (Left, Right : Address) return Boolean; -+ function "=" (Left, Right : Address) return Boolean; -+ -+ pragma Import (Intrinsic, "<"); -+ pragma Import (Intrinsic, "<="); -+ pragma Import (Intrinsic, ">"); -+ pragma Import (Intrinsic, ">="); -+ pragma Import (Intrinsic, "="); -+ -+ -- Other System-Dependent Declarations -+ -+ type Bit_Order is (High_Order_First, Low_Order_First); -+ Default_Bit_Order : constant Bit_Order := High_Order_First; -+ pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning -+ -+ -- Priority-related Declarations (RM D.1) -+ -+ Max_Priority : constant Positive := 30; -+ Max_Interrupt_Priority : constant Positive := 31; -+ -+ subtype Any_Priority is Integer range 0 .. 31; -+ subtype Priority is Any_Priority range 0 .. 30; -+ subtype Interrupt_Priority is Any_Priority range 31 .. 31; -+ -+ Default_Priority : constant Priority := 15; -+ -+private -+ -+ type Address is mod Memory_Size; -+ Null_Address : constant Address := 0; -+ -+ -------------------------------------- -+ -- System Implementation Parameters -- -+ -------------------------------------- -+ -+ -- These parameters provide information about the target that is used -+ -- by the compiler. They are in the private part of System, where they -+ -- can be accessed using the special circuitry in the Targparm unit -+ -- whose source should be consulted for more detailed descriptions -+ -- of the individual switch values. -+ -+ Backend_Divide_Checks : constant Boolean := False; -+ Backend_Overflow_Checks : constant Boolean := True; -+ Command_Line_Args : constant Boolean := True; -+ Configurable_Run_Time : constant Boolean := False; -+ Denorm : constant Boolean := True; -+ Duration_32_Bits : constant Boolean := False; -+ Exit_Status_Supported : constant Boolean := True; -+ Fractional_Fixed_Ops : constant Boolean := False; -+ Frontend_Layout : constant Boolean := False; -+ Machine_Overflows : constant Boolean := False; -+ Machine_Rounds : constant Boolean := True; -+ Preallocated_Stacks : constant Boolean := False; -+ Signed_Zeros : constant Boolean := True; -+ Stack_Check_Default : constant Boolean := False; -+ Stack_Check_Probes : constant Boolean := True; -+ Stack_Check_Limits : constant Boolean := False; -+ Support_Aggregates : constant Boolean := True; -+ Support_Composite_Assign : constant Boolean := True; -+ Support_Composite_Compare : constant Boolean := True; -+ Support_Long_Shifts : constant Boolean := True; -+ Always_Compatible_Rep : constant Boolean := False; -+ Suppress_Standard_Library : constant Boolean := False; -+ Use_Ada_Main_Program_Name : constant Boolean := False; -+ Frontend_Exceptions : constant Boolean := False; -+ ZCX_By_Default : constant Boolean := True; -+ -+end System; --- -2.15.1 - diff --git a/main/gcc/ada-musl.patch b/main/gcc/ada-musl.patch index 464c3d57d9..7a86ae4afa 100644 --- a/main/gcc/ada-musl.patch +++ b/main/gcc/ada-musl.patch @@ -1,7 +1,8 @@ -diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c ---- gcc-5.1.0/gcc.orig/ada/adaint.c 2015-02-20 11:48:57.000000000 +0000 -+++ gcc-5.1.0/gcc/ada/adaint.c 2015-06-02 10:47:51.672767476 +0000 -@@ -70,6 +70,11 @@ +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 3b0aea9..ee0bb69 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -76,6 +76,11 @@ #include #include #endif @@ -13,16 +14,15 @@ diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c #ifdef __PikeOS__ #define __BSD_VISIBLE 1 -@@ -3057,8 +3062,6 @@ __gnat_lwp_self (void) - return (void *) syscall (__NR_gettid); - } +@@ -3255,7 +3260,6 @@ __gnat_lwp_self (void) + #endif + #if defined (__linux__) -#include -- + /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static - versions. */ -@@ -3067,7 +3070,7 @@ __gnat_lwp_self (void) +@@ -3265,7 +3269,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ @@ -31,7 +31,7 @@ diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); -@@ -3080,33 +3083,33 @@ __gnat_cpu_alloc_size (size_t count) +@@ -3278,33 +3282,33 @@ __gnat_cpu_alloc_size (size_t count) } void @@ -73,7 +73,7 @@ diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c } size_t -@@ -3116,23 +3119,23 @@ __gnat_cpu_alloc_size (size_t count ATTR +@@ -3314,23 +3318,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void @@ -101,11 +101,12 @@ diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c + CPU_SET (cpu - 1, (cpu_set_t *) set); } #endif /* !CPU_ALLOC */ - #endif /* linux */ -diff -rup gcc-5.1.0/gcc.orig/ada/adaint.h gcc-5.1.0/gcc/ada/adaint.h ---- gcc-5.1.0/gcc.orig/ada/adaint.h 2015-01-27 17:20:27.000000000 +0000 -+++ gcc-5.1.0/gcc/ada/adaint.h 2015-06-02 10:47:23.188910894 +0000 -@@ -287,13 +287,11 @@ extern void *__gnat_lwp_self (voi + #endif /* __linux__ */ +diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h +index 0d12f7e..a063b47 100644 +--- a/gcc/ada/adaint.h ++++ b/gcc/ada/adaint.h +@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); /* Routines for interface to required CPU set primitives */ @@ -123,15 +124,94 @@ diff -rup gcc-5.1.0/gcc.orig/ada/adaint.h gcc-5.1.0/gcc/ada/adaint.h #endif #if defined (_WIN32) -diff -rup gcc-5.1.0/gcc.orig/ada/gcc-interface/Makefile.in gcc-5.1.0/gcc/ada/gcc-interface/Makefile.in ---- gcc-5.1.0/gcc.orig/ada/gcc-interface/Makefile.in 2015-04-09 20:29:28.000000000 +0000 -+++ gcc-5.1.0/gcc/ada/gcc-interface/Makefile.in 2015-06-02 10:47:23.188910894 +0000 -@@ -1910,7 +1910,7 @@ ifeq ($(strip $(filter-out powerpc% linu +diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c +index 7025f57..207b50d 100644 +--- a/gcc/ada/terminals.c ++++ b/gcc/ada/terminals.c +@@ -1108,13 +1108,6 @@ __gnat_setup_winsize (void *desc, int rows, int columns) + #include + #include + +-/* On some system termio is either absent or including it will disable termios +- (HP-UX) */ +-#if !defined (__hpux__) && !defined (BSD) && !defined (__APPLE__) \ +- && !defined (__rtems__) && !defined (__QNXNTO__) +-# include +-#endif +- + #include + #include + #include +diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in +index ebb955e..08cfbee 100644 +--- a/gcc/ada/gcc-interface/Makefile.in ++++ b/gcc/ada/gcc-interface/Makefile.in +@@ -1028,7 +1028,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb - # undef __KERNEL__ --# else -+# elif defined(__GLIBC__) - /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */ - /* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */ - /* prototypes, so we have to include the top-level sigcontext.h to */ ---- gcc-4.8.2/boehm-gc/dyn_load.c.orig 2014-02-17 14:13:09.519850231 +0200 -+++ gcc-4.8.2/boehm-gc/dyn_load.c 2014-02-17 14:14:27.906093514 +0200 -@@ -459,9 +459,7 @@ - /* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ - /* versions. Thanks to Jakub Jelinek for most of the code. */ - --# if (defined(LINUX) || defined (__GLIBC__)) /* Are others OK here, too? */ \ -- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ -- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) -+# if (defined(LINUX) || defined (__GLIBC__)) - - /* We have the header files for a glibc that includes dl_iterate_phdr. */ - /* It may still not be available in the library on the target system. */ ---- gcc-4.8.2/boehm-gc/include/private/gcconfig.h.orig 2014-02-17 14:14:36.026049422 +0200 -+++ gcc-4.8.2/boehm-gc/include/private/gcconfig.h 2014-02-17 14:17:11.345207887 +0200 -@@ -684,7 +684,7 @@ - # ifdef __ELF__ - # define DYNAMIC_LOADING - # include --# if defined(__GLIBC__)&& __GLIBC__>=2 -+# if 1 - # define SEARCH_FOR_DATA_START - # else /* !GLIBC2 */ - extern char **__environ; -@@ -1147,7 +1147,7 @@ - # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff)) - # endif - # include --# if defined(__GLIBC__) && __GLIBC__ >= 2 -+# if 1 - # define SEARCH_FOR_DATA_START - # else - extern char **__environ; -@@ -1367,7 +1367,7 @@ - # define HBLKSIZE 4096 - # endif - # define USE_GENERIC_PUSH_REGS --# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2 -+# if 1 - # define LINUX_STACKBOTTOM - # else - # define STACKBOTTOM 0x80000000 -@@ -1858,7 +1858,7 @@ - # ifdef __ELF__ - # define DYNAMIC_LOADING - # include --# if defined(__GLIBC__) && __GLIBC__ >= 2 -+# if 1 - # define SEARCH_FOR_DATA_START - # else - extern char **__environ; diff --git a/main/gcc/fix-gcj-iconv-musl.patch b/main/gcc/fix-gcj-iconv-musl.patch deleted file mode 100644 index b0015751e2..0000000000 --- a/main/gcc/fix-gcj-iconv-musl.patch +++ /dev/null @@ -1,120 +0,0 @@ ---- gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc.orig 2014-02-18 18:46:14.897880526 +0200 -+++ gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc 2014-02-18 18:50:08.766613550 +0200 -@@ -24,6 +24,13 @@ - - #ifdef HAVE_ICONV - #include -+#include -+ -+#if __BYTE_ORDER == __BIG_ENDIAN -+#define UCS2_CHARSET "UCS-2BE" -+#else -+#define UCS2_CHARSET "UCS-2LE" -+#endif - - template - static inline size_t -@@ -45,7 +52,7 @@ - _Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer); - buffer[len] = '\0'; - -- iconv_t h = iconv_open ("UCS-2", buffer); -+ iconv_t h = iconv_open (UCS2_CHARSET, buffer); - if (h == (iconv_t) -1) - throw new ::java::io::UnsupportedEncodingException (encoding); - -@@ -99,18 +106,6 @@ - throw new ::java::io::CharConversionException (); - } - -- if (iconv_byte_swap) -- { -- size_t max = (old_out - outavail) / sizeof (jchar); -- for (size_t i = 0; i < max; ++i) -- { -- // Byte swap. -- jchar c = (((out[outpos + i] & 0xff) << 8) -- | ((out[outpos + i] >> 8) & 0xff)); -- outbuf[i] = c; -- } -- } -- - inpos += old_in - inavail; - return (old_out - outavail) / sizeof (jchar); - #else /* HAVE_ICONV */ -@@ -145,7 +140,7 @@ - _Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer); - buffer[len] = '\0'; - -- iconv_t h = iconv_open (buffer, "UCS-2"); -+ iconv_t h = iconv_open (buffer, UCS2_CHARSET); - if (h == (iconv_t) -1) - throw new ::java::io::UnsupportedEncodingException (encoding); - -@@ -187,20 +182,6 @@ - char *inbuf = (char *) &chars[inpos]; - char *outbuf = (char *) &out[count]; - -- if (iconv_byte_swap) -- { -- // Ugly performance penalty -- don't use losing systems! -- temp_buffer = (jchar *) _Jv_Malloc (inlength * sizeof (jchar)); -- for (int i = 0; i < inlength; ++i) -- { -- // Byte swap. -- jchar c = (((chars[inpos + i] & 0xff) << 8) -- | ((chars[inpos + i] >> 8) & 0xff)); -- temp_buffer[i] = c; -- } -- inbuf = (char *) temp_buffer; -- } -- - size_t loop_old_in = old_in; - while (1) - { -@@ -252,44 +233,7 @@ - jboolean - gnu::gcj::convert::IOConverter::iconv_init (void) - { -- // Some versions of iconv() always return their UCS-2 results in -- // big-endian order, and they also require UCS-2 inputs to be in -- // big-endian order. For instance, glibc 2.1.3 does this. If the -- // UTF-8=>UCS-2 iconv converter has this feature, then we assume -- // that all UCS-2 converters do. (This might not be the best -- // heuristic, but is is all we've got.) -- jboolean result = false; --#ifdef HAVE_ICONV -- iconv_t handle = iconv_open ("UCS-2", "UTF-8"); -- if (handle != (iconv_t) -1) -- { -- jchar c; -- unsigned char in[4]; -- char *inp, *outp; -- size_t inc, outc, r; -- -- // This is the UTF-8 encoding of \ufeff. At least Tru64 UNIX libiconv -- // needs the trailing NUL byte, otherwise iconv fails with EINVAL. -- in[0] = 0xef; -- in[1] = 0xbb; -- in[2] = 0xbf; -- in[3] = 0x00; -- -- inp = (char *) in; -- inc = 4; -- outp = (char *) &c; -- outc = 2; -- -- r = iconv_adapter (iconv, handle, &inp, &inc, &outp, &outc); -- // Conversion must be complete for us to use the result. -- if (r != (size_t) -1 && inc == 0 && outc == 0) -- result = (c != 0xfeff); -- -- // Release iconv handle. -- iconv_close (handle); -- } --#endif /* HAVE_ICONV */ -- return result; -+ return false; - } - - void diff --git a/main/gcc/fix-gcj-musl.patch b/main/gcc/fix-gcj-musl.patch deleted file mode 100644 index d26f510c0b..0000000000 --- a/main/gcc/fix-gcj-musl.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- gcc-4.8.2/libjava/gnu/classpath/natSystemProperties.cc.orig 2014-02-18 10:55:08.617678779 +0200 -+++ gcc-4.8.2/libjava/gnu/classpath/natSystemProperties.cc 2014-02-18 10:56:31.927227453 +0200 -@@ -289,7 +289,7 @@ - // just default to `en_US'. - setlocale (LC_ALL, ""); - char *locale = setlocale (LC_MESSAGES, ""); -- if (locale && strlen (locale) >= 2) -+ if (locale && strlen (locale) >= 2 && (locale[2] == '\0' || locale[2] == '_')) - { - char buf[3]; - buf[2] = '\0'; ---- gcc-4.8.2/libjava/posix-threads.cc.orig 2014-02-18 13:22:01.789933726 +0200 -+++ gcc-4.8.2/libjava/posix-threads.cc 2014-02-18 13:29:50.924058875 +0200 -@@ -657,6 +657,7 @@ - struct sched_param param; - pthread_attr_t attr; - struct starter *info; -+ size_t ss; - - if (data->flags & FLAG_START) - return; -@@ -675,8 +676,25 @@ - // Set stack size if -Xss option was given. - if (gcj::stack_size > 0) - { -- int e = pthread_attr_setstacksize (&attr, gcj::stack_size); -+ ss = gcj::stack_size; -+ } -+ else -+ { -+ int e = pthread_attr_getstacksize (&attr, &ss); -+ if (e != 0) -+ JvFail (strerror (e)); -+ -+ // Request at least 1meg of stack -+ if (ss >= 1024 * 1024) -+ ss = 0; -+ else -+ ss = 1024 * 1024; -+ } -+ -+ if (ss) -+ { -+ int e = pthread_attr_setstacksize (&attr, ss); - if (e != 0) - JvFail (strerror (e)); - } - - info = (struct starter *) _Jv_AllocBytes (sizeof (struct starter)); diff --git a/main/gcc/fix-gcj-stdgnu14-link.patch b/main/gcc/fix-gcj-stdgnu14-link.patch deleted file mode 100644 index 2b2ce0fa59..0000000000 --- a/main/gcc/fix-gcj-stdgnu14-link.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- gcc-6.1.0/libjava/Makefile.am -+++ gcc-6.1.0/libjava/Makefile.am -@@ -488,10 +488,14 @@ - nat_files = $(nat_source_files:.cc=.lo) - xlib_nat_files = $(xlib_nat_source_files:.cc=.lo) - -+libgcj_la_CPPFLAGS = \ -+ $(AM_CPPFLAGS) \ -+ $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -+ - # Include THREADLIBS here to ensure that the correct version of - # certain linuxthread functions get linked: - ## The mysterious backslash in the grep pattern is consumed by make. --libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ -+libgcj_la_LDFLAGS = $(LIBSTDCXX_RAW_CXX_LDFLAGS) -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ - $(LIBLTDL) $(SYS_ZLIBS) $(LIBJAVA_LDFLAGS_NOUNDEF) \ - -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ - $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBGCJ_LD_EXPORT_ALL) ---- gcc-6.1.0/libjava/Makefile.in -+++ gcc-6.1.0/libjava/Makefile.in -@@ -1103,9 +1103,13 @@ - nat_files = $(nat_source_files:.cc=.lo) - xlib_nat_files = $(xlib_nat_source_files:.cc=.lo) - -+libgcj_la_CPPFLAGS = \ -+ $(AM_CPPFLAGS) \ -+ $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -+ - # Include THREADLIBS here to ensure that the correct version of - # certain linuxthread functions get linked: --libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ -+libgcj_la_LDFLAGS = $(LIBSTDCXX_RAW_CXX_LDFLAGS) -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ - $(LIBLTDL) $(SYS_ZLIBS) $(LIBJAVA_LDFLAGS_NOUNDEF) \ - -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ - $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBGCJ_LD_EXPORT_ALL) diff --git a/main/gcc/fix-linux-header-use-in-libgcc.patch b/main/gcc/fix-linux-header-use-in-libgcc.patch deleted file mode 100644 index 6dad1b2cad..0000000000 --- a/main/gcc/fix-linux-header-use-in-libgcc.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 9cd4503714c4e596818c4ea8e15905c249b7a319 Mon Sep 17 00:00:00 2001 -From: nsz -Date: Thu, 25 Aug 2016 14:08:27 +0000 -Subject: [PATCH] [mips] Fix linux header use in libgcc - -libgcc/ - * config/mips/linux-unwind.h: Use sys/syscall.h. - - - -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239759 138bc75d-0d04-0410-961f-82ee72b054a4 ---- - libgcc/ChangeLog | 4 ++++ - libgcc/config/mips/linux-unwind.h | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog -index b78c4b2..99bd2f1 100644 ---- a/libgcc/ChangeLog -+++ b/libgcc/ChangeLog -@@ -1,3 +1,7 @@ -+2016-08-25 Szabolcs Nagy -+ -+ * config/mips/linux-unwind.h: Use sys/syscall.h. -+ - 2016-08-16 Joseph Myers - - PR libgcc/77265 -diff --git a/libgcc/config/mips/linux-unwind.h b/libgcc/config/mips/linux-unwind.h -index bf12de5..4035c121 100644 ---- a/libgcc/config/mips/linux-unwind.h -+++ b/libgcc/config/mips/linux-unwind.h -@@ -27,7 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - state data appropriately. See unwind-dw2.c for the structs. */ - - #include --#include -+#include - - /* The third parameter to the signal handler points to something with - * this structure defined in asm/ucontext.h, but the name clashes with --- -2.9.3 - diff --git a/main/gcc/fix-rs6000-pie.patch b/main/gcc/fix-rs6000-pie.patch deleted file mode 100644 index 1fbc31a56a..0000000000 --- a/main/gcc/fix-rs6000-pie.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- gcc-6.3.0.orig/gcc/config/rs6000/sysv4.h -+++ gcc-6.3.0/gcc/config/rs6000/sysv4.h -@@ -753,23 +753,42 @@ - #endif - - #ifdef HAVE_LD_PIE --#define STARTFILE_LINUX_SPEC "\ --%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ --%{mnewlib:ecrti.o%s;:crti.o%s} \ --%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ --" CRTOFFLOADBEGIN -+#define STARTFILE_LINUX_SPEC \ -+ "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ -+ %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \ -+ crti.o%s %{shared:crtbeginS.o%s;: \ -+ %{" PIE_SPEC ":crtbeginS.o%s} \ -+ %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \ -+ %{fvtable-verify=none:%s; \ -+ fvtable-verify=preinit:vtv_start_preinit.o%s; \ -+ fvtable-verify=std:vtv_start.o%s} \ -+ " CRTOFFLOADBEGIN - #else --#define STARTFILE_LINUX_SPEC "\ --%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ --%{mnewlib:ecrti.o%s;:crti.o%s} \ --%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ --" CRTOFFLOADBEGIN -+#define STARTFILE_LINUX_SPEC \ -+ "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ -+ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ -+ %{fvtable-verify=none:%s; \ -+ fvtable-verify=preinit:vtv_start_preinit.o%s; \ -+ fvtable-verify=std:vtv_start.o%s} \ -+ " CRTOFFLOADBEGIN - #endif - --#define ENDFILE_LINUX_SPEC "\ --%{shared|pie:crtendS.o%s;:crtend.o%s} \ --%{mnewlib:ecrtn.o%s;:crtn.o%s} \ --" CRTOFFLOADEND -+#ifdef HAVE_LD_PIE -+#define ENDFILE_LINUX_SPEC \ -+ "%{fvtable-verify=none:%s; \ -+ fvtable-verify=preinit:vtv_end_preinit.o%s; \ -+ fvtable-verify=std:vtv_end.o%s} \ -+ %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \ -+ %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \ -+ " CRTOFFLOADEND -+#else -+#define ENDFILE_LINUX_SPEC \ -+ "%{fvtable-verify=none:%s; \ -+ fvtable-verify=preinit:vtv_end_preinit.o%s; \ -+ fvtable-verify=std:vtv_end.o%s} \ -+ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \ -+ " CRTOFFLOADEND -+#endif - - #define LINK_START_LINUX_SPEC "" - diff --git a/main/gcc/gcc-4.8-build-args.patch b/main/gcc/gcc-4.8-build-args.patch deleted file mode 100644 index c27e009619..0000000000 --- a/main/gcc/gcc-4.8-build-args.patch +++ /dev/null @@ -1,41 +0,0 @@ -When cross compiling a target gcc, target flags may be used on the host - -Configure identifies a number of warning flags (WARN_CFLAGS and -WARN_CXXFLAGS) from the $CC value. The cross compiler may be different -from the host compiler and may not support the same set of flags. This -leads to problems such as: - -cc1plus: error: unrecognized command line option "-Wno-narrowing" -cc1plus: error: unrecognized command line option "-Wno-overlength-strings" - -Work around this problem by removing the warning flags from the -BUILD_CXXFLAGS value, in a way similar to the BUILD_CFLAGS. - -Upstream-Status: Pending - -Signed-off-by: Mark Hatle - -Index: gcc-4.8.0/gcc/configure -=================================================================== ---- gcc-4.8.0.orig/gcc/configure -+++ gcc-4.8.0/gcc/configure -@@ -11720,6 +10581,7 @@ STMP_FIXINC=stmp-fixinc - if test x$build != x$host || test "x$coverage_flags" != x - then - BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' -+ BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' - BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)' - fi - -Index: gcc-4.8.0/gcc/configure.ac -=================================================================== ---- gcc-4.8.0.orig/gcc/configure.ac -+++ gcc-4.8.0/gcc/configure.ac -@@ -1901,6 +1901,7 @@ STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_F - if test x$build != x$host || test "x$coverage_flags" != x - then - BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' -+ BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' - BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)' - fi - diff --git a/main/gcc/gcc-as-needed-gold.patch b/main/gcc/gcc-as-needed-gold.patch new file mode 100644 index 0000000000..e22e59bce0 --- /dev/null +++ b/main/gcc/gcc-as-needed-gold.patch @@ -0,0 +1,58 @@ +# DP: Use --push-state/--pop-state for gold as well when linking libtsan. + +Index: b/gcc/gcc.c +=================================================================== +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -693,10 +693,10 @@ proper position among the other output f + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ +- " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libasan:--push-state --no-as-needed}" \ + " -lasan " \ + " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libasan:--pop-state}" \ + STATIC_LIBASAN_LIBS + #else + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS +@@ -714,10 +714,10 @@ proper position among the other output f + #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ +- " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libtsan:--push-state --no-as-needed}" \ + " -ltsan " \ + " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libtsan:--pop-state}" \ + STATIC_LIBTSAN_LIBS + #else + #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS +@@ -735,10 +735,10 @@ proper position among the other output f + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ +- " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-liblsan:--push-state --no-as-needed}" \ + " -llsan " \ + " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-liblsan:--pop-state}" \ + STATIC_LIBLSAN_LIBS + #else + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS +@@ -754,10 +754,10 @@ proper position among the other output f + " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" + #ifdef HAVE_LD_STATIC_DYNAMIC + #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ +- " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libubsan:--push-state --no-as-needed}" \ + " -lubsan " \ + " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libubsan:--pop-state}" \ + STATIC_LIBUBSAN_LIBS + #else + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS diff --git a/main/gcc/gcc-as-needed-push-pop.patch b/main/gcc/gcc-as-needed-push-pop.patch new file mode 100644 index 0000000000..a5a4e9d3b4 --- /dev/null +++ b/main/gcc/gcc-as-needed-push-pop.patch @@ -0,0 +1,43 @@ +From: Jakub Jelinek +Subject: [PATCH] Use --push-state --as-needed and --pop-state instead of --as-needed and --no-as-needed for libgcc + +As discussed, using --as-needed and --no-as-needed is dangerous, because +it results in --no-as-needed even for libraries after -lgcc_s, even when the +default is --as-needed or --as-needed has been specified earlier on the +command line. + +If the linker supports --push-state/--pop-state, we should IMHO use it. + +2018-04-11 Jakub Jelinek + + * configure.ac (LD_AS_NEEDED_OPTION, LD_NO_AS_NEEDED_OPTION): Use + --push-state --as-needed and --pop-state instead of --as-needed and + --no-as-needed if ld supports it. + * configure: Regenerated. + +Index: b/gcc/configure.ac +=================================================================== +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -5518,11 +5518,21 @@ if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_ld_as_needed=yes ++ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 28; then ++ gcc_cv_ld_as_needed_option='--push-state --as-needed' ++ gcc_cv_ld_no_as_needed_option='--pop-state' ++ fi + fi + elif test x$gcc_cv_ld != x; then + # Check if linker supports --as-needed and --no-as-needed options + if $gcc_cv_ld --help 2>&1 | grep as-needed > /dev/null; then + gcc_cv_ld_as_needed=yes ++ if $gcc_cv_ld --help 2>&1 | grep push-state > /dev/null; then ++ if $gcc_cv_ld --help 2>&1 | grep pop-state > /dev/null; then ++ gcc_cv_ld_as_needed_option='--push-state --as-needed' ++ gcc_cv_ld_no_as_needed_option='--pop-state' ++ fi ++ fi + fi + case "$target:$gnu_ld" in + *-*-solaris2*:no) -- cgit v1.2.3