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 1c5b812..5a6a211 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 c45fc1d..2103344 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 c109b07..29ff1d9 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 e15013e..2f2a185 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 0e484d4..534af9a 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 6236b98..bdea132 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 a272455..e7ea423 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 8983dc9..07f64c8 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 6fc9eae..46434a8 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 55d0365..aebef88 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 f96ead0..aafce9f 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 1048e31..ed7837b 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 de38629..f86ad11 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 739df00..76f994a 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 bf5203b..f6c2fef 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