sysv4.h (STARTFILE_LINUX_SPEC): Add -static-pie support.
authorJakub Jelinek <jakub@redhat.com>
Wed, 13 Sep 2017 21:22:33 +0000 (23:22 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 13 Sep 2017 21:22:33 +0000 (23:22 +0200)
* config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Add -static-pie
support.
(ENDFILE_LINUX_SPEC): Likewise.
(LINK_EH_SPEC): Likewise.
* config/rs6000/linux64.h (LINK_SHLIB_SPEC): Likewise.
(LINK_OS_LINUX_SPEC32): Likewise.
(LINK_OS_LINUX_SPEC64): Likewise.
* config/rs6000/linux.h (LINK_SHLIB_SPEC): Likewise.
(LINK_OS_LINUX_SPEC): Likewise.

From-SVN: r252735

gcc/ChangeLog
gcc/config/rs6000/linux.h
gcc/config/rs6000/linux64.h
gcc/config/rs6000/sysv4.h

index 959e04e895ae2ccd1913b8514360486710d39dab..1c5b812d62870e7d569b078866c0c5a24de4a699 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-13  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Add -static-pie
+       support.
+       (ENDFILE_LINUX_SPEC): Likewise.
+       (LINK_EH_SPEC): Likewise.
+       * config/rs6000/linux64.h (LINK_SHLIB_SPEC): Likewise.
+       (LINK_OS_LINUX_SPEC32): Likewise.
+       (LINK_OS_LINUX_SPEC64): Likewise.
+       * config/rs6000/linux.h (LINK_SHLIB_SPEC): Likewise.
+       (LINK_OS_LINUX_SPEC): Likewise.
+
 2017-09-13  Martin Liska  <mliska@suse.cz>
 
        PR middle-end/82154
index 684afd6c1901fb06c8631e70848eff4cf587739f..e4158d26abb383557029602729cefcea10f21f59 100644 (file)
@@ -61,7 +61,8 @@
 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
 
 #undef  LINK_SHLIB_SPEC
-#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
+#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}} \
+  %{static-pie:-static -pie --no-dynamic-linker -z text}"
 
 #undef LIB_DEFAULT_SPEC
 #define LIB_DEFAULT_SPEC "%(lib_linux)"
@@ -93,8 +94,9 @@
 
 #undef LINK_OS_LINUX_SPEC
 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
-  %{rdynamic:-export-dynamic} \
-  -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
+  %{!static-pie: \
+    %{rdynamic:-export-dynamic} \
+    -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}}"
 
 /* For backward compatibility, we must continue to use the AIX
    structure return convention.  */
index 1dbb3d94a739c0752972e801dfb1e13227fd9e94..13b769211b1130a5b2fa6b86d138273bc6fac96b 100644 (file)
@@ -395,7 +395,8 @@ extern int dot_symbols;
 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux) %(include_extra)"
 
 #undef  LINK_SHLIB_SPEC
-#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
+#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}} \
+  %{static-pie:-static -pie --no-dynamic-linker -z text}"
 
 #undef  LIB_DEFAULT_SPEC
 #define LIB_DEFAULT_SPEC "%(lib_linux)"
@@ -470,13 +471,15 @@ extern int dot_symbols;
 #endif
 
 #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!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: \
-  %{rdynamic:-export-dynamic} \
-  -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}} \
+  %{!static-pie: \
+    %{rdynamic:-export-dynamic} \
+    -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
   %(link_os_extra_spec64)"
 
 #undef  TOC_SECTION_ASM_OP
index 03726b434bdd3c02ad0f21717d7a7106c1c1ae4b..e381ce90a8c764fe11ecfcfeabfaeda8fd1e0cb9 100644 (file)
@@ -764,11 +764,11 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
   "%{shared:; \
      pg|p|profile:gcrt1.o%s; \
      static:crt1.o%s; \
-     " PIE_SPEC ":Scrt1.o%s; \
+     static-pie|" PIE_SPEC ":Scrt1.o%s; \
      :crt1.o%s} \
    %{mnewlib:ecrti.o%s;:crti.o%s} \
    %{static:crtbeginT.o%s; \
-     shared|" PIE_SPEC ":crtbeginS.o%s; \
+     shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
      :crtbegin.o%s} \
    %{fvtable-verify=none:%s; \
      fvtable-verify=preinit:vtv_start_preinit.o%s; \
@@ -782,7 +782,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
      fvtable-verify=preinit:vtv_end_preinit.o%s; \
      fvtable-verify=std:vtv_end.o%s} \
    %{static:crtend.o%s; \
-     shared|" PIE_SPEC ":crtendS.o%s; \
+     shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
      :crtend.o%s} \
    %{mnewlib:ecrtn.o%s;:crtn.o%s} \
    " CRTOFFLOADEND
@@ -816,7 +816,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__ \