From 8c6562e12bf7d1406474cbba832073a4afe5687c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 14 Sep 2017 09:56:23 +0200 Subject: [PATCH] elf.h (LINK_EH_SPEC): Add -static-pie support. * config/alpha/elf.h (LINK_EH_SPEC): Add -static-pie support. * config/alpha/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. * config/netbsd.h (LINK_EH_SPEC): Likewise. * config/sol2.h (LINK_EH_SPEC): Likewise. * config/arm/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. * config/s390/linux.h (LINK_SPEC): Likewise. * config/freebsd.h (LINK_EH_SPEC): Likewise. * config/openbsd.h (LINK_EH_SPEC): Likewise. * config/lm32/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. * config/aarch64/aarch64-linux.h (LINUX_TARGET_LINK_SPEC): Likewise. * config/powerpcspe/sysv4.h (LINK_EH_SPEC): Likewise. * config/bfin/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. * config/i386/gnu-user64.h (GNU_USER_TARGET_LINK_SPEC): Fix a typo. * config/i386/gnu-user.h (GNU_USER_TARGET_LINK_SPEC): Formatting fix. From-SVN: r252750 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/config/aarch64/aarch64-linux.h | 5 +++-- gcc/config/alpha/elf.h | 2 +- gcc/config/alpha/linux.h | 3 ++- gcc/config/arm/uclinux-elf.h | 3 ++- gcc/config/bfin/linux.h | 5 +++-- gcc/config/freebsd.h | 2 +- gcc/config/i386/gnu-user.h | 2 +- gcc/config/i386/gnu-user64.h | 2 +- gcc/config/lm32/uclinux-elf.h | 3 ++- gcc/config/netbsd.h | 2 +- gcc/config/openbsd.h | 2 +- gcc/config/powerpcspe/sysv4.h | 2 +- gcc/config/s390/linux.h | 5 +++-- gcc/config/sol2.h | 2 +- 15 files changed, 40 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1c5b812d628..5a6a211982d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2017-09-14 Jakub Jelinek + + * config/alpha/elf.h (LINK_EH_SPEC): Add -static-pie support. + * config/alpha/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. + * config/netbsd.h (LINK_EH_SPEC): Likewise. + * config/sol2.h (LINK_EH_SPEC): Likewise. + * config/arm/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. + * config/s390/linux.h (LINK_SPEC): Likewise. + * config/freebsd.h (LINK_EH_SPEC): Likewise. + * config/openbsd.h (LINK_EH_SPEC): Likewise. + * config/lm32/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. + * config/aarch64/aarch64-linux.h (LINUX_TARGET_LINK_SPEC): Likewise. + * config/powerpcspe/sysv4.h (LINK_EH_SPEC): Likewise. + * config/bfin/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise. + * config/i386/gnu-user64.h (GNU_USER_TARGET_LINK_SPEC): Fix a typo. + * config/i386/gnu-user.h (GNU_USER_TARGET_LINK_SPEC): Formatting fix. + 2017-09-13 Jakub Jelinek * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Add -static-pie diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h index c45fc1d35d1..2103344a47c 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -38,9 +38,10 @@ %{static:-Bstatic} \ %{shared:-shared} \ %{symbolic:-Bsymbolic} \ - %{!static: \ + %{!static:%{!static-pie: \ %{rdynamic:-export-dynamic} \ - %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \ + %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \ -X \ %{mbig-endian:-EB} %{mlittle-endian:-EL} \ -maarch64linux%{mabi=ilp32:32}%{mbig-endian:b}" diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index c109b07c515..29ff1d9c0d1 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -168,5 +168,5 @@ extern int alpha_this_gpdisp_sequence_number; I imagine that other systems will catch up. In the meantime, it doesn't harm to make sure that the data exists to be used later. */ #if defined(HAVE_LD_EH_FRAME_HDR) -#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h index e15013eb96a..2f2a185d780 100644 --- a/gcc/config/alpha/linux.h +++ b/gcc/config/alpha/linux.h @@ -79,7 +79,8 @@ along with GCC; see the file COPYING3. If not see #define TARGET_POSIX_IO #define LINK_GCC_C_SEQUENCE_SPEC \ - "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" + "%{static|static-pie:--start-group} %G %L \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" /* Use --as-needed -lgcc_s for eh support. */ #ifdef HAVE_LD_AS_NEEDED diff --git a/gcc/config/arm/uclinux-elf.h b/gcc/config/arm/uclinux-elf.h index 0e484d4eb53..534af9a1e97 100644 --- a/gcc/config/arm/uclinux-elf.h +++ b/gcc/config/arm/uclinux-elf.h @@ -70,7 +70,8 @@ #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ - "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G %L}" + "%{static|static-pie:--start-group} %G %L \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G %L}}" /* Use --as-needed -lgcc_s for eh support. */ #ifdef HAVE_LD_AS_NEEDED diff --git a/gcc/config/bfin/linux.h b/gcc/config/bfin/linux.h index 6236b987a72..bdea1320f18 100644 --- a/gcc/config/bfin/linux.h +++ b/gcc/config/bfin/linux.h @@ -35,8 +35,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ - "%{static:--start-group} %{mfast-fp:-lbffastfp} %G %L %{static:--end-group} \ - %{!static:%{mfast-fp:-lbffastfp} %G}" + "%{static|static-pie:--start-group} %{mfast-fp:-lbffastfp} %G %L \ + %{static|static-pie:--end-group} \ + %{!static:%{!static-pie:%{mfast-fp:-lbffastfp} %G}}" #undef CPP_SPEC #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h index a2724556925..e7ea42370c5 100644 --- a/gcc/config/freebsd.h +++ b/gcc/config/freebsd.h @@ -45,7 +45,7 @@ along with GCC; see the file COPYING3. If not see #define LIB_SPEC FBSD_LIB_SPEC #if defined(HAVE_LD_EH_FRAME_HDR) -#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif #ifdef TARGET_LIBC_PROVIDES_SSP diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h index 8983dc9ecd7..07f64c8aa93 100644 --- a/gcc/config/i386/gnu-user.h +++ b/gcc/config/i386/gnu-user.h @@ -80,7 +80,7 @@ along with GCC; see the file COPYING3. If not see %{!static-pie: \ %{rdynamic:-export-dynamic} \ -dynamic-linker %(dynamic_linker)}} \ - %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" + %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" #undef LINK_SPEC #define LINK_SPEC GNU_USER_TARGET_LINK_SPEC diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index 6fc9eae6f6b..46434a84011 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -59,7 +59,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see %{shared:-shared} \ %{!shared: \ %{!static: \ - %{!static-static: \ + %{!static-pie: \ %{rdynamic:-export-dynamic} \ %{" SPEC_32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \ %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \ diff --git a/gcc/config/lm32/uclinux-elf.h b/gcc/config/lm32/uclinux-elf.h index 55d03659309..aebef889a50 100644 --- a/gcc/config/lm32/uclinux-elf.h +++ b/gcc/config/lm32/uclinux-elf.h @@ -72,7 +72,8 @@ #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS() #define LINK_GCC_C_SEQUENCE_SPEC \ - "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" + "%{static|static-pie:--start-group} %G %L \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" #undef CC1_SPEC #define CC1_SPEC "%{G*} %{!fno-PIC:-fPIC}" diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index f96ead05468..aafce9f9f5e 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -125,7 +125,7 @@ along with GCC; see the file COPYING3. If not see #define LIBGCC_SPEC NETBSD_LIBGCC_SPEC #if defined(HAVE_LD_EH_FRAME_HDR) -#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif #undef TARGET_LIBC_HAS_FUNCTION diff --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h index 1048e31f77f..ed7837b3a1a 100644 --- a/gcc/config/openbsd.h +++ b/gcc/config/openbsd.h @@ -136,7 +136,7 @@ while (0) #define LIB_SPEC OBSD_LIB_SPEC #if defined(HAVE_LD_EH_FRAME_HDR) -#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif #undef LIB_SPEC diff --git a/gcc/config/powerpcspe/sysv4.h b/gcc/config/powerpcspe/sysv4.h index de386291a51..f86ad11ec4f 100644 --- a/gcc/config/powerpcspe/sysv4.h +++ b/gcc/config/powerpcspe/sysv4.h @@ -805,7 +805,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" #if defined(HAVE_LD_EH_FRAME_HDR) -# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +# define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif #define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \ diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h index 739df00f62d..76f994a6807 100644 --- a/gcc/config/s390/linux.h +++ b/gcc/config/s390/linux.h @@ -82,10 +82,11 @@ along with GCC; see the file COPYING3. If not see %{shared:-shared} \ %{!shared: \ %{static:-static} \ - %{!static: \ + %{!static:%{!static-pie: \ %{rdynamic:-export-dynamic} \ %{m31:-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \ - %{m64:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}}" + %{m64:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}}} \ + %{static-pie:-static -pie --no-dynamic-linker -z text}" #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index bf5203b8c16..f6c2fefbbc1 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -372,7 +372,7 @@ along with GCC; see the file COPYING3. If not see /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs --eh-frame-hdr to create the required .eh_frame_hdr sections. */ #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR) -#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */ #endif -- 2.30.2