elf.h (LINK_EH_SPEC): Add -static-pie support.
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Sep 2017 07:56:23 +0000 (09:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Sep 2017 07:56:23 +0000 (09:56 +0200)
* 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

15 files changed:
gcc/ChangeLog
gcc/config/aarch64/aarch64-linux.h
gcc/config/alpha/elf.h
gcc/config/alpha/linux.h
gcc/config/arm/uclinux-elf.h
gcc/config/bfin/linux.h
gcc/config/freebsd.h
gcc/config/i386/gnu-user.h
gcc/config/i386/gnu-user64.h
gcc/config/lm32/uclinux-elf.h
gcc/config/netbsd.h
gcc/config/openbsd.h
gcc/config/powerpcspe/sysv4.h
gcc/config/s390/linux.h
gcc/config/sol2.h

index 1c5b812d62870e7d569b078866c0c5a24de4a699..5a6a211982dd3ff2d5f56cbf5cd11bf7fd0cbb09 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-14  Jakub Jelinek  <jakub@redhat.com>
+
+       * 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  <jakub@redhat.com>
 
        * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Add -static-pie
index c45fc1d35d1d9e6ce2fcb477fe5ab13137a2ccb7..2103344a47c88da976de570ee1f009567b4c167f 100644 (file)
    %{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}"
index c109b07c5156524a952d727652acd9e95c9cbd42..29ff1d9c0d138e558baccd3583dbc648106d5d72 100644 (file)
@@ -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
index e15013eb96a6307f958d7172622ab821878bcc27..2f2a185d7802a243781487e627debe8f9a76bf48 100644 (file)
@@ -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
index 0e484d4eb538b9b93435151d1ddadfbe01c20250..534af9a1e97fecb5c904b998f7ab2da878e04e39 100644 (file)
@@ -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
index 6236b987a72170a29a1d80f16555f8429d2b4a12..bdea1320f185d83a94d661c48008026106111ec7 100644 (file)
@@ -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}"
index a2724556925bbdea067bbc1c1f523baf1d972a38..e7ea42370c5ba06303c9bfddb47ab9e35118769d 100644 (file)
@@ -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
index 8983dc9ecd74e25dd348bae8cc7302ed17290fe8..07f64c8aa93a303d75031967980c0bf02fd55502 100644 (file)
@@ -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
index 6fc9eae6f6b9ffeaf1b290e610dec832b8804d8d..46434a84011ddbdcf290c7e3ae76788709211fa4 100644 (file)
@@ -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 "} \
index 55d036593093a2b49b034f92f3edd59b748a8ea2..aebef889a503ab135343052aa7bfd6b998eccd5a 100644 (file)
@@ -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}"
index f96ead054682952dfdd8c386a54c36d0d9cb361c..aafce9f9f5eb92433eaf485b41e86ff9d5ddea35 100644 (file)
@@ -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
index 1048e31f77f5cf055c233cbf186a92af822cda50..ed7837b3a1a2afdfa0743e2ad9e01cf49aeadcf9 100644 (file)
@@ -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
index de386291a5100d1803eb32364125c9ff9c3c1cac..f86ad11ec4f3e5301a764d37550c776742a2e42e 100644 (file)
@@ -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__ \
index 739df00f62d808712f36c9c54230af7c84eec671..76f994a6807e9017fb765b29bebcb943b0935b8e 100644 (file)
@@ -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}"
 
index bf5203b8c163783fae3e83d87c723c52d49bae35..f6c2fefbbc17d3c46376ed8eda15a311572a2cf5 100644 (file)
@@ -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