From 14fef000947916e55e5aa1bdd6d78a04ed78dde4 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Wed, 19 Jun 2019 19:16:17 +0000 Subject: [PATCH] [Darwin, specs] Tidy some more linker options. pie, no-pie and rdynamic are driver options, we can process them in the relevant place and drop them once dealt with. There's no need to generate a new header to process the "no_compact_unwind" which is applied on the basis of the target system. Support for the -pie, -no_pie and -no_compact_unwind options should ideally be checked at configure time, however the status quo is to assert that linkers capable of targeting the relevant systems support these options (i.e. we trust that the user doesn't attempt to configure inappropriately). TODO: check the availability of the linker opts in configure rather than trusting to the user. This will fix the fail of pie-7.c, which is a result of failing to handle the no-pie driver option. 2019-06-19 Iain Sandoe * config/darwin.h (DRIVER_SELF_SPECS): Add RDYNAMIC, DARWIN_PIE_SPEC and DARWIN_NOPIE_SPEC. (RDYNAMIC): New, modified from DARWIN_EXPORT_DYNAMIC. (DARWIN_PIE_SPEC): Collate from darwin.h and darwin9.h. (DARWIN_NOPIE_SPEC): Collate from darwin10.h. (DARWIN_NOCOMPACT_UNWIND): New from darwin10.h (DARWIN_EXPORT_DYNAMIC): Delete. * config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move no_compact_unwind and pie options processing to darwin.h. * config/darwin9.h (DARWIN_PIE_SPEC): Move pie processing to darwin.h From-SVN: r272484 --- gcc/ChangeLog | 17 +++++++++++++-- gcc/config/darwin.h | 49 ++++++++++++++++++++++++++++++++----------- gcc/config/darwin10.h | 9 ++------ gcc/config/darwin9.h | 6 ------ 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 919ceafd3a3..6e9ecedf96c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,7 +1,20 @@ 2019-06-19 Iain Sandoe - * config/darwin-driver.c (darwin_driver_init): Fix off-by-one errors - in computing the number of options to be moved. + * config/darwin.h (DRIVER_SELF_SPECS): Add RDYNAMIC, DARWIN_PIE_SPEC + and DARWIN_NOPIE_SPEC. + (RDYNAMIC): New, modified from DARWIN_EXPORT_DYNAMIC. + (DARWIN_PIE_SPEC): Collate from darwin.h and darwin9.h. + (DARWIN_NOPIE_SPEC): Collate from darwin10.h. + (DARWIN_NOCOMPACT_UNWIND): New from darwin10.h + (DARWIN_EXPORT_DYNAMIC): Delete. + * config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move no_compact_unwind + and pie options processing to darwin.h. + * config/darwin9.h (DARWIN_PIE_SPEC): Move pie processing to darwin.h + +2019-06-19 Iain Sandoe + + * config/darwin-driver.c (darwin_driver_init): Fix off-by-one errors + in computing the number of options to be moved. 2019-06-19 Maya Rashish diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index bf44b106940..ae324f194de 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -124,7 +124,30 @@ extern GTY(()) int darwin_ms_struct; "%{fapple-kext|mkernel:-static}", \ "%{shared:-Zdynamiclib} %= 10.5 mmacosx-version-min= -Xlinker) \ + %:version-compare(>= 10.5 mmacosx-version-min= -pie) }} %= 10.7 mmacosx-version-min= -Xlinker ) \ + %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %= 10.6 mmacosx-version-min= -no_compact_unwind) " + /* This is mostly a clone of the standard LINK_COMMAND_SPEC, plus precomp, libtool, and fat build additions. @@ -164,12 +197,6 @@ extern GTY(()) int darwin_ms_struct; specifying the handling of options understood by generic Unix linkers, and for positional arguments like libraries. */ -#if LD64_HAS_EXPORT_DYNAMIC -#define DARWIN_EXPORT_DYNAMIC " %{rdynamic:-export_dynamic}" -#else -#define DARWIN_EXPORT_DYNAMIC " %{rdynamic: %nrdynamic is not supported}" -#endif - #define LINK_COMMAND_SPEC_A \ "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ %(linker)" \ @@ -190,10 +217,11 @@ extern GTY(()) int darwin_ms_struct; %{%:sanitize(address): -lasan } \ %{%:sanitize(undefined): -lubsan } \ %(link_ssp) \ - " DARWIN_EXPORT_DYNAMIC " %. */ -/* Fix PR41260 by passing -no_compact_unwind on darwin10 and later until - unwinder in libSystem is fixed to digest new epilog unwinding notes. +/* Fix PR47558 by linking against libSystem ahead of libgcc_ext. */ - Fix PR47558 by linking against libSystem ahead of libgcc_ext. */ #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ -"%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ - %{!static:%{!static-libgcc: \ +"%{!static:%{!static-libgcc: \ %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ - %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ - %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } \ %{!nostdlib:%:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef.o)} \ %G %{!nolibc:%L}" diff --git a/gcc/config/darwin9.h b/gcc/config/darwin9.h index ca5c51718c8..1fd1604aed8 100644 --- a/gcc/config/darwin9.h +++ b/gcc/config/darwin9.h @@ -35,12 +35,6 @@ along with GCC; see the file COPYING3. If not see /* Tell collect2 to run dsymutil for us as necessary. */ #define COLLECT_RUN_DSYMUTIL 1 -#undef DARWIN_PIE_SPEC -#define DARWIN_PIE_SPEC \ - "%{fpie|pie|fPIE: \ - %{mdynamic-no-pic: %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \ - :-pie}}" - /* Only ask as for debug data if the debug style is stabs (since as doesn't yet generate dwarf.) */ -- 2.30.2