From 971f9abb96c8250c0b1f8cb310b8237067f141c4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Mon, 18 Dec 2017 10:00:39 +0000 Subject: gcc/6.4.0, gcc/7.2.0: fix --default-pie to use proper startup files, bug #641474 The change adds two patches to patchset: - gentoo/95_all_static_override_pie.patch - gentoo/96_all_powerpc_pie.patch First fixes -static handling for --default-pie compiler. Second fixes to use proper startup files for --default-pie on powerpc. Otherwise binutils-2.27 and upper generates invalid ELF files. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22626 Bug: https://bugs.gentoo.org/641474 --- 6.4.0/gentoo/95_all_static_override_pie.patch | 188 ++++++++++++++++++++++++++ 6.4.0/gentoo/96_all_powerpc_pie.patch | 84 ++++++++++++ 6.4.0/gentoo/README.history | 3 + 7.2.0/gentoo/95_all_static_override_pie.patch | 188 ++++++++++++++++++++++++++ 7.2.0/gentoo/96_all_powerpc_pie.patch | 84 ++++++++++++ 7.2.0/gentoo/README.history | 3 + 6 files changed, 550 insertions(+) create mode 100644 6.4.0/gentoo/95_all_static_override_pie.patch create mode 100644 6.4.0/gentoo/96_all_powerpc_pie.patch create mode 100644 7.2.0/gentoo/95_all_static_override_pie.patch create mode 100644 7.2.0/gentoo/96_all_powerpc_pie.patch diff --git a/6.4.0/gentoo/95_all_static_override_pie.patch b/6.4.0/gentoo/95_all_static_override_pie.patch new file mode 100644 index 0000000..13c06a1 --- /dev/null +++ b/6.4.0/gentoo/95_all_static_override_pie.patch @@ -0,0 +1,188 @@ +https://bugs.gentoo.org/641474 + +From d59d277cd2562766313583261750a3d84863a27d Mon Sep 17 00:00:00 2001 +From: amodra +Date: Tue, 29 Aug 2017 08:25:17 +0000 +Subject: [PATCH] PR driver/81523: Make -static override -pie + +-static and -pie together behave differently depending on whether GCC is +configured with --enable-default-pie. On x86, "-static -pie" fails to +create executable when --enable-default-pie isn't used, but creates a +static executable when --enable-default-pie is used. This patch makes +-static completely override -pie to create a static executable, regardless +if --enable-default-pie is used to configure GCC. + + PR target/81170 + PR target/81295 + PR driver/81523 + * gcc.c (NO_PIE_SPEC): Delete. + (PIE_SPEC): Define as !no-pie/pie. Move static|shared|r + exclusion.. + (LINK_PIE_SPEC): ..to here. + (LINK_COMMAND_SPEC): Support -no-pie. + * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Correct + chain of crtbegin*.o selection, update for PIE_SPEC changes and + format. + (GNU_USER_TARGET_ENDFILE_SPEC): Similarly. + * config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Similarly. + (ENDFILE_CRTEND_SPEC): Similarly. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@251404 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 20 ++++++++++++++++++++ + gcc/config/gnu-user.h | 34 ++++++++++++++++++++++++---------- + gcc/config/sol2.h | 12 ++++++------ + gcc/gcc.c | 14 +++++++------- + 4 files changed, 57 insertions(+), 23 deletions(-) + +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index b0bf40a954f..8c579aac3f6 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -50,19 +50,28 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #if defined HAVE_LD_PIE + #define GNU_USER_TARGET_STARTFILE_SPEC \ +- "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ +- %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \ +- crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \ +- %{" PIE_SPEC ":crtbeginS.o%s} \ +- %{" NO_PIE_SPEC ":crtbegin.o%s}} \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ static:crt1.o%s; \ ++ " PIE_SPEC ":Scrt1.o%s; \ ++ :crt1.o%s} \ ++ crti.o%s \ ++ %{static:crtbeginT.o%s; \ ++ shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ + fvtable-verify=std:vtv_start.o%s} \ + " CRTOFFLOADBEGIN + #else + #define GNU_USER_TARGET_STARTFILE_SPEC \ +- "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ +- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ :crt1.o%s} \ ++ crti.o%s \ ++ %{static:crtbeginT.o%s; \ ++ shared|pie:crtbeginS.o%s; \ ++ :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ + fvtable-verify=std:vtv_start.o%s} \ +@@ -82,15 +91,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \ +- %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \ ++ %{static:crtend.o%s; \ ++ shared|" PIE_SPEC ":crtendS.o%s; \ ++ :crtend.o%s} \ ++ crtn.o%s \ + " CRTOFFLOADEND + #else + #define GNU_USER_TARGET_ENDFILE_SPEC \ + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \ ++ %{static:crtend.o%s; \ ++ shared|pie:crtendS.o%s; \ ++ :crtend.o%s} \ ++ crtn.o%s \ + " CRTOFFLOADEND + #endif + #undef ENDFILE_SPEC +diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h +index 5160e1fda18..78764c4e556 100644 +--- a/gcc/config/sol2.h ++++ b/gcc/config/sol2.h +@@ -159,9 +159,9 @@ along with GCC; see the file COPYING3. If not see + %{!ansi:values-Xa.o%s}" + + #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS) +-#define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \ +- %{" PIE_SPEC ":crtbeginS.o%s} \ +- %{" NO_PIE_SPEC ":crtbegin.o%s}" ++#define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \ ++ shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ :crtbegin.o%s}" + #else + #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s" + #endif +@@ -204,9 +204,9 @@ along with GCC; see the file COPYING3. If not see + #endif + + #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS) +-#define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \ +- %{" PIE_SPEC ":crtendS.o%s} \ +- %{" NO_PIE_SPEC ":crtend.o%s}}" ++#define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \ ++ shared|" PIE_SPEC ":crtendS.o%s; \ ++ :crtend.o%s}" + #else + #define ENDFILE_CRTEND_SPEC "crtend.o%s" + #endif +diff --git a/gcc/gcc.c b/gcc/gcc.c +index cfa074d4e43..896d9af4acb 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -869,8 +869,7 @@ proper position among the other output files. */ + #endif + + #ifdef ENABLE_DEFAULT_PIE +-#define NO_PIE_SPEC "no-pie|static" +-#define PIE_SPEC NO_PIE_SPEC "|r|shared:;" ++#define PIE_SPEC "!no-pie" + #define NO_FPIE1_SPEC "fno-pie" + #define FPIE1_SPEC NO_FPIE1_SPEC ":;" + #define NO_FPIE2_SPEC "fno-PIE" +@@ -891,7 +890,6 @@ proper position among the other output files. */ + #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;" + #else + #define PIE_SPEC "pie" +-#define NO_PIE_SPEC PIE_SPEC "|r|shared:;" + #define FPIE1_SPEC "fpie" + #define NO_FPIE1_SPEC FPIE1_SPEC ":;" + #define FPIE2_SPEC "fPIE" +@@ -920,7 +918,7 @@ proper position among the other output files. */ + #else + #define LD_PIE_SPEC "" + #endif +-#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} " ++#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " + #endif + + #ifndef LINK_BUILDID_SPEC +@@ -999,8 +997,10 @@ proper position among the other output files. */ + #endif + + /* -u* was put back because both BSD and SysV seem to support it. */ +-/* %{static:} simply prevents an error message if the target machine +- doesn't handle -static. */ ++/* %{static|no-pie:} simply prevents an error message: ++ 1. If the target machine doesn't handle -static. ++ 2. If PIE isn't enabled by default. ++ */ + /* We want %{T*} after %{L*} and %D so that it can be used to specify linker + scripts which exist in user specified directories, or in standard + directories. */ +@@ -1017,7 +1017,7 @@ proper position among the other output files. */ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ +- %{static:} %{L*} %(mfwrap) %(link_libgcc) " \ ++ %{static|no-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ + %:include(libgomp.spec)%(link_gomp)}\ +-- +2.15.1 + diff --git a/6.4.0/gentoo/96_all_powerpc_pie.patch b/6.4.0/gentoo/96_all_powerpc_pie.patch new file mode 100644 index 0000000..55cf5d6 --- /dev/null +++ b/6.4.0/gentoo/96_all_powerpc_pie.patch @@ -0,0 +1,84 @@ +https://bugs.gentoo.org/641474 + +From e764842a5c6ae3aa81be7c8c2b710d92404b9590 Mon Sep 17 00:00:00 2001 +From: amodra +Date: Tue, 29 Aug 2017 08:27:02 +0000 +Subject: [PATCH] [RS6000] linux startfile/endfile + +These need to match the gnu-user.h definitions to support +--enable-default-pie. Otherwise we end up linking the wrong startup +files when defaulting to PIE. + + PR target/81170 + PR target/81295 + * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Upgrade to + match gnu-user.h startfile. + (ENDFILE_LINUX_SPEC): Similarly. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@251405 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 7 +++++++ + gcc/config/rs6000/sysv4.h | 46 ++++++++++++++++++++++++++++------------------ + 2 files changed, 35 insertions(+), 18 deletions(-) + +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index ba35fd27d0f..f81ba6d1514 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -752,24 +752,34 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) + #define CRTOFFLOADEND "" + #endif + +-#ifdef HAVE_LD_PIE +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN +-#else +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN +-#endif +- +-#define ENDFILE_LINUX_SPEC "\ +-%{shared|pie:crtendS.o%s;:crtend.o%s} \ +-%{mnewlib:ecrtn.o%s;:crtn.o%s} \ +-" CRTOFFLOADEND ++/* STARTFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_STARTFILE_SPEC ++ but with the mnewlib ecrti.o%s selection substituted for crti.o%s. */ ++#define STARTFILE_LINUX_SPEC \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ static:crt1.o%s; \ ++ " 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; \ ++ :crtbegin.o%s} \ ++ %{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_start_preinit.o%s; \ ++ fvtable-verify=std:vtv_start.o%s} \ ++ " CRTOFFLOADBEGIN ++ ++/* ENDFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_ENDFILE_SPEC ++ but with the mnewlib ecrtn.o%s selection substituted for crtn.o%s. */ ++#define ENDFILE_LINUX_SPEC \ ++ "%{fvtable-verify=none:%s; \ ++ 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; \ ++ :crtend.o%s} \ ++ %{mnewlib:ecrtn.o%s;:crtn.o%s} \ ++ " CRTOFFLOADEND + + #define LINK_START_LINUX_SPEC "" + +-- +2.15.1 + diff --git a/6.4.0/gentoo/README.history b/6.4.0/gentoo/README.history index 181f356..832f7cd 100644 --- a/6.4.0/gentoo/README.history +++ b/6.4.0/gentoo/README.history @@ -1,3 +1,6 @@ +1.2 TODO + + 95_all_static_override_pie.patch + + 96_all_powerpc_pie.patch 1.1 27 Nov 2017 + 92_all_asan-signal_h.patch + 93_all_ucontext-to-ucontext_t.patch diff --git a/7.2.0/gentoo/95_all_static_override_pie.patch b/7.2.0/gentoo/95_all_static_override_pie.patch new file mode 100644 index 0000000..13c06a1 --- /dev/null +++ b/7.2.0/gentoo/95_all_static_override_pie.patch @@ -0,0 +1,188 @@ +https://bugs.gentoo.org/641474 + +From d59d277cd2562766313583261750a3d84863a27d Mon Sep 17 00:00:00 2001 +From: amodra +Date: Tue, 29 Aug 2017 08:25:17 +0000 +Subject: [PATCH] PR driver/81523: Make -static override -pie + +-static and -pie together behave differently depending on whether GCC is +configured with --enable-default-pie. On x86, "-static -pie" fails to +create executable when --enable-default-pie isn't used, but creates a +static executable when --enable-default-pie is used. This patch makes +-static completely override -pie to create a static executable, regardless +if --enable-default-pie is used to configure GCC. + + PR target/81170 + PR target/81295 + PR driver/81523 + * gcc.c (NO_PIE_SPEC): Delete. + (PIE_SPEC): Define as !no-pie/pie. Move static|shared|r + exclusion.. + (LINK_PIE_SPEC): ..to here. + (LINK_COMMAND_SPEC): Support -no-pie. + * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Correct + chain of crtbegin*.o selection, update for PIE_SPEC changes and + format. + (GNU_USER_TARGET_ENDFILE_SPEC): Similarly. + * config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Similarly. + (ENDFILE_CRTEND_SPEC): Similarly. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@251404 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 20 ++++++++++++++++++++ + gcc/config/gnu-user.h | 34 ++++++++++++++++++++++++---------- + gcc/config/sol2.h | 12 ++++++------ + gcc/gcc.c | 14 +++++++------- + 4 files changed, 57 insertions(+), 23 deletions(-) + +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index b0bf40a954f..8c579aac3f6 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -50,19 +50,28 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #if defined HAVE_LD_PIE + #define GNU_USER_TARGET_STARTFILE_SPEC \ +- "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ +- %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \ +- crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \ +- %{" PIE_SPEC ":crtbeginS.o%s} \ +- %{" NO_PIE_SPEC ":crtbegin.o%s}} \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ static:crt1.o%s; \ ++ " PIE_SPEC ":Scrt1.o%s; \ ++ :crt1.o%s} \ ++ crti.o%s \ ++ %{static:crtbeginT.o%s; \ ++ shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ + fvtable-verify=std:vtv_start.o%s} \ + " CRTOFFLOADBEGIN + #else + #define GNU_USER_TARGET_STARTFILE_SPEC \ +- "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ +- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ :crt1.o%s} \ ++ crti.o%s \ ++ %{static:crtbeginT.o%s; \ ++ shared|pie:crtbeginS.o%s; \ ++ :crtbegin.o%s} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ + fvtable-verify=std:vtv_start.o%s} \ +@@ -82,15 +91,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \ +- %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \ ++ %{static:crtend.o%s; \ ++ shared|" PIE_SPEC ":crtendS.o%s; \ ++ :crtend.o%s} \ ++ crtn.o%s \ + " CRTOFFLOADEND + #else + #define GNU_USER_TARGET_ENDFILE_SPEC \ + "%{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_end_preinit.o%s; \ + fvtable-verify=std:vtv_end.o%s} \ +- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \ ++ %{static:crtend.o%s; \ ++ shared|pie:crtendS.o%s; \ ++ :crtend.o%s} \ ++ crtn.o%s \ + " CRTOFFLOADEND + #endif + #undef ENDFILE_SPEC +diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h +index 5160e1fda18..78764c4e556 100644 +--- a/gcc/config/sol2.h ++++ b/gcc/config/sol2.h +@@ -159,9 +159,9 @@ along with GCC; see the file COPYING3. If not see + %{!ansi:values-Xa.o%s}" + + #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS) +-#define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \ +- %{" PIE_SPEC ":crtbeginS.o%s} \ +- %{" NO_PIE_SPEC ":crtbegin.o%s}" ++#define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \ ++ shared|" PIE_SPEC ":crtbeginS.o%s; \ ++ :crtbegin.o%s}" + #else + #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s" + #endif +@@ -204,9 +204,9 @@ along with GCC; see the file COPYING3. If not see + #endif + + #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS) +-#define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \ +- %{" PIE_SPEC ":crtendS.o%s} \ +- %{" NO_PIE_SPEC ":crtend.o%s}}" ++#define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \ ++ shared|" PIE_SPEC ":crtendS.o%s; \ ++ :crtend.o%s}" + #else + #define ENDFILE_CRTEND_SPEC "crtend.o%s" + #endif +diff --git a/gcc/gcc.c b/gcc/gcc.c +index cfa074d4e43..896d9af4acb 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -869,8 +869,7 @@ proper position among the other output files. */ + #endif + + #ifdef ENABLE_DEFAULT_PIE +-#define NO_PIE_SPEC "no-pie|static" +-#define PIE_SPEC NO_PIE_SPEC "|r|shared:;" ++#define PIE_SPEC "!no-pie" + #define NO_FPIE1_SPEC "fno-pie" + #define FPIE1_SPEC NO_FPIE1_SPEC ":;" + #define NO_FPIE2_SPEC "fno-PIE" +@@ -891,7 +890,6 @@ proper position among the other output files. */ + #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;" + #else + #define PIE_SPEC "pie" +-#define NO_PIE_SPEC PIE_SPEC "|r|shared:;" + #define FPIE1_SPEC "fpie" + #define NO_FPIE1_SPEC FPIE1_SPEC ":;" + #define FPIE2_SPEC "fPIE" +@@ -920,7 +918,7 @@ proper position among the other output files. */ + #else + #define LD_PIE_SPEC "" + #endif +-#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} " ++#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " + #endif + + #ifndef LINK_BUILDID_SPEC +@@ -999,8 +997,10 @@ proper position among the other output files. */ + #endif + + /* -u* was put back because both BSD and SysV seem to support it. */ +-/* %{static:} simply prevents an error message if the target machine +- doesn't handle -static. */ ++/* %{static|no-pie:} simply prevents an error message: ++ 1. If the target machine doesn't handle -static. ++ 2. If PIE isn't enabled by default. ++ */ + /* We want %{T*} after %{L*} and %D so that it can be used to specify linker + scripts which exist in user specified directories, or in standard + directories. */ +@@ -1017,7 +1017,7 @@ proper position among the other output files. */ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ +- %{static:} %{L*} %(mfwrap) %(link_libgcc) " \ ++ %{static|no-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ + %:include(libgomp.spec)%(link_gomp)}\ +-- +2.15.1 + diff --git a/7.2.0/gentoo/96_all_powerpc_pie.patch b/7.2.0/gentoo/96_all_powerpc_pie.patch new file mode 100644 index 0000000..55cf5d6 --- /dev/null +++ b/7.2.0/gentoo/96_all_powerpc_pie.patch @@ -0,0 +1,84 @@ +https://bugs.gentoo.org/641474 + +From e764842a5c6ae3aa81be7c8c2b710d92404b9590 Mon Sep 17 00:00:00 2001 +From: amodra +Date: Tue, 29 Aug 2017 08:27:02 +0000 +Subject: [PATCH] [RS6000] linux startfile/endfile + +These need to match the gnu-user.h definitions to support +--enable-default-pie. Otherwise we end up linking the wrong startup +files when defaulting to PIE. + + PR target/81170 + PR target/81295 + * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Upgrade to + match gnu-user.h startfile. + (ENDFILE_LINUX_SPEC): Similarly. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@251405 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 7 +++++++ + gcc/config/rs6000/sysv4.h | 46 ++++++++++++++++++++++++++++------------------ + 2 files changed, 35 insertions(+), 18 deletions(-) + +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index ba35fd27d0f..f81ba6d1514 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -752,24 +752,34 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) + #define CRTOFFLOADEND "" + #endif + +-#ifdef HAVE_LD_PIE +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN +-#else +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN +-#endif +- +-#define ENDFILE_LINUX_SPEC "\ +-%{shared|pie:crtendS.o%s;:crtend.o%s} \ +-%{mnewlib:ecrtn.o%s;:crtn.o%s} \ +-" CRTOFFLOADEND ++/* STARTFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_STARTFILE_SPEC ++ but with the mnewlib ecrti.o%s selection substituted for crti.o%s. */ ++#define STARTFILE_LINUX_SPEC \ ++ "%{shared:; \ ++ pg|p|profile:gcrt1.o%s; \ ++ static:crt1.o%s; \ ++ " 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; \ ++ :crtbegin.o%s} \ ++ %{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_start_preinit.o%s; \ ++ fvtable-verify=std:vtv_start.o%s} \ ++ " CRTOFFLOADBEGIN ++ ++/* ENDFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_ENDFILE_SPEC ++ but with the mnewlib ecrtn.o%s selection substituted for crtn.o%s. */ ++#define ENDFILE_LINUX_SPEC \ ++ "%{fvtable-verify=none:%s; \ ++ 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; \ ++ :crtend.o%s} \ ++ %{mnewlib:ecrtn.o%s;:crtn.o%s} \ ++ " CRTOFFLOADEND + + #define LINK_START_LINUX_SPEC "" + +-- +2.15.1 + diff --git a/7.2.0/gentoo/README.history b/7.2.0/gentoo/README.history index 20b95f6..239e4fd 100644 --- a/7.2.0/gentoo/README.history +++ b/7.2.0/gentoo/README.history @@ -1,3 +1,6 @@ +1.1 TODO + + 95_all_static_override_pie.patch + + 96_all_powerpc_pie.patch 1.0 08 May 2017 + 10_all_default-fortify-source.patch + 11_all_default-warn-format-security.patch -- cgit v1.2.3-65-gdbad