aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2021-07-19 23:30:28 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2021-07-19 23:30:28 +0100
commit5013b9e50a671edefe6b0ce6c103dbeb621344c3 (patch)
tree37b3d2896953f795144b0a51ee47079aba780a72
parent6.5.0: cut 6 patchset (diff)
downloadgcc-patches-5013b9e50a671edefe6b0ce6c103dbeb621344c3.tar.gz
gcc-patches-5013b9e50a671edefe6b0ce6c103dbeb621344c3.tar.bz2
gcc-patches-5013b9e50a671edefe6b0ce6c103dbeb621344c3.zip
8.5.0: apply powerpcspe pie and march patches
Two new patches: + 31_all_powerpcspe-pie-crt.patch + 32_all_powerpcspe-march-PLATFORM.patch Fix-by: Luke McHale Bug: https://bugs.gentoo.org/802930 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r--8.5.0/gentoo/31_all_powerpcspe-pie-crt.patch95
-rw-r--r--8.5.0/gentoo/32_all_powerpcspe-march-PLATFORM.patch153
-rw-r--r--8.5.0/gentoo/README.history4
3 files changed, 252 insertions, 0 deletions
diff --git a/8.5.0/gentoo/31_all_powerpcspe-pie-crt.patch b/8.5.0/gentoo/31_all_powerpcspe-pie-crt.patch
new file mode 100644
index 0000000..bb7354d
--- /dev/null
+++ b/8.5.0/gentoo/31_all_powerpcspe-pie-crt.patch
@@ -0,0 +1,95 @@
+https://bugs.gentoo.org/802930
+
+From 4e542386b97b648fd844e6b9d380c193fd662098 Mon Sep 17 00:00:00 2001
+From: Luke McHale <luke.mchale@protonmail.com>
+Date: Fri, 7 Aug 2020 16:40:11 +0000
+Subject: [PATCH] Bring powerpcspe STARTFILE_LINUX_SPEC up to date with the
+ newer PIE_SPEC decision tree from reference GNU_USER_TARGET_STARTFILE_SPEC.
+ Bring powerpcspe ENDFILE_LINUX_SPEC up to date with the newer PIE_SPEC
+ decision tree from reference GNU_USER_TARGET_STARTFILE_SPEC.
+
+Fixes issue where the incorrect start/end crti files are chosen when gcc is compiled with --enable-default-pie.
+---
+ gcc/config/powerpcspe/sysv4.h | 65 +++++++++++++++++++++++++++--------
+ 1 file changed, 50 insertions(+), 15 deletions(-)
+
+--- a/gcc/config/powerpcspe/sysv4.h
++++ b/gcc/config/powerpcspe/sysv4.h
+@@ -757,24 +757,59 @@ 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
++/* 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. */
++#if defined HAVE_LD_PIE
++#define STARTFILE_LINUX_SPEC \
++ "%{shared:; \
++ pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
++ static:crt1.o%s; \
++ static-pie:rcrt1.o%s; \
++ " PIE_SPEC ":Scrt1.o%s; \
++ :crt1.o%s} \
++ %{mnewlib:ecrti.o%s;:crti.o%s} \
++ %{static:crtbeginT.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; \
++ fvtable-verify=std:vtv_start.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
++#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|static-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
++/* 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. */
++#if defined HAVE_LD_PIE
++#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|static-pie|" PIE_SPEC ":crtendS.o%s; \
++ :crtend.o%s} \
++ %{mnewlib:ecrtn.o%s;:crtn.o%s} \
++ " CRTOFFLOADEND
++#else
++#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|static-pie:crtendS.o%s; \
++ :crtend.o%s} \
++ %{mnewlib:ecrtn.o%s;:crtn.o%s} \
++ " CRTOFFLOADEND
++#endif
+
+ #define LINK_START_LINUX_SPEC ""
+
+--
+2.27.0
+
diff --git a/8.5.0/gentoo/32_all_powerpcspe-march-PLATFORM.patch b/8.5.0/gentoo/32_all_powerpcspe-march-PLATFORM.patch
new file mode 100644
index 0000000..358ae87
--- /dev/null
+++ b/8.5.0/gentoo/32_all_powerpcspe-march-PLATFORM.patch
@@ -0,0 +1,153 @@
+https://bugs.gentoo.org/802930
+
+From 5bf03bd8c8a97fb30bc7e146216396bbe9f6a36d Mon Sep 17 00:00:00 2001
+From: Luke McHale <luke.mchale@protonmail.com>
+Date: Fri, 7 Aug 2020 16:46:16 +0000
+Subject: [PATCH] powerpcspe arch is missing AT_PLATFORM translation table
+ present in the regular powerpc (rs6000) arch. Fixes -mcpu=native when run on
+ e500v2 to correctly drop the ppc from AT_PLATFORM ppc8548 to GCC's canonical
+ 8548.
+
+---
+ gcc/config/powerpcspe/driver-powerpcspe.c | 97 +++++++++++++++++++++--
+ 1 file changed, 89 insertions(+), 8 deletions(-)
+
+--- a/gcc/config/powerpcspe/driver-powerpcspe.c
++++ b/gcc/config/powerpcspe/driver-powerpcspe.c
+@@ -23,6 +23,8 @@ along with GCC; see the file COPYING3. If not see
+ #include "system.h"
+ #include "coretypes.h"
+ #include "tm.h"
++#include "diagnostic.h"
++#include "opts.h"
+ #include <stdlib.h>
+
+ #ifdef _AIX
+@@ -38,6 +40,44 @@ along with GCC; see the file COPYING3. If not see
+ # include <sys/sysctl.h>
+ #endif
+
++#ifdef __linux__
++/* Canonical GCC cpu name table. */
++static const char *rs6000_supported_cpu_names[] =
++{
++#define RS6000_CPU(NAME, CPU, FLAGS) NAME,
++#include "powerpcspe-cpus.def"
++#undef RS6000_CPU
++};
++
++/* This table holds a list of cpus where their Linux AT_PLATFORM name differs
++ from their GCC canonical name. The first column in a row contains the GCC
++ canonical cpu name and the other columns in that row contain AT_PLATFORM
++ names that should be mapped to the canonical name. */
++
++static const char *linux_cpu_translation_table[][4] = {
++ { "403", "ppc403", NULL },
++ { "405", "ppc405", NULL },
++ { "440", "ppc440", "ppc440gp", NULL },
++ { "476", "ppc470", NULL },
++ { "601", "ppc601", NULL },
++ { "603", "ppc603", NULL },
++ { "604", "ppc604", NULL },
++ { "7400", "ppc7400", NULL },
++ { "7450", "ppc7450", NULL },
++ { "750", "ppc750", NULL },
++ { "823", "ppc823", NULL },
++ { "8540", "ppc8540", NULL },
++ { "8548", "ppc8548", NULL },
++ { "970", "ppc970", NULL },
++ { "cell", "ppc-cell-be", NULL },
++ { "e500mc", "ppce500mc", NULL },
++ { "e5500", "ppce5500", NULL },
++ { "e6500", "ppce6500", NULL },
++ { "power7", "power7+", NULL },
++ { NULL } /* End of table sentinel. */
++};
++#endif
++
+ const char *host_detect_local_cpu (int argc, const char **argv);
+
+ #if GCC_VERSION >= 0
+@@ -158,14 +198,19 @@ detect_processor_freebsd (void)
+
+ #ifdef __linux__
+
+-/* Returns AT_PLATFORM if present, otherwise generic PowerPC. */
++/* Returns the canonical AT_PLATFORM if present, otherwise NULL. */
+
+ static const char *
+ elf_platform (void)
+ {
+- int fd;
++ /* Used to cache the result we determine below. */
++ static const char *cpu = NULL;
+
+- fd = open ("/proc/self/auxv", O_RDONLY);
++ /* Use the cached AT_PLATFORM cpu name if we've already determined it. */
++ if (cpu != NULL)
++ return cpu;
++
++ int fd = open ("/proc/self/auxv", O_RDONLY);
+
+ if (fd != -1)
+ {
+@@ -179,15 +224,51 @@ elf_platform (void)
+ if (n > 0)
+ {
+ for (av = (ElfW(auxv_t) *) buf; av->a_type != AT_NULL; ++av)
+- switch (av->a_type)
++ if (av->a_type == AT_PLATFORM)
+ {
+- case AT_PLATFORM:
+- return (const char *) av->a_un.a_val;
+-
+- default:
++ /* Cache the result. */
++ cpu = (const char *) av->a_un.a_val;
+ break;
+ }
+ }
++
++ /* Verify that CPU is either a valid -mcpu=<cpu> option name, or is a
++ valid alternative name. If it is a valid alternative name, then use
++ the canonical name. */
++ if (cpu != NULL)
++ {
++ size_t i, j;
++ char *s;
++
++ /* Check if AT_PLATFORM is a GCC canonical cpu name. */
++ for (i = 0; i < ARRAY_SIZE (rs6000_supported_cpu_names); i++)
++ if (!strcmp (cpu, rs6000_supported_cpu_names[i]))
++ return cpu;
++
++ /* Check if AT_PLATFORM can be translated to a canonical cpu name. */
++ for (i = 0; linux_cpu_translation_table[i][0] != NULL; i++)
++ {
++ const char *canonical = linux_cpu_translation_table[i][0];
++ for (j = 1; linux_cpu_translation_table[i][j] != NULL; j++)
++ if (!strcmp (cpu, linux_cpu_translation_table[i][j]))
++ {
++ /* Cache the result. */
++ cpu = canonical;
++ return cpu;
++ }
++ }
++
++ /* The kernel returned an AT_PLATFORM name we do not support. */
++ auto_vec <const char *> candidates;
++ for (i = 0; i < ARRAY_SIZE (rs6000_supported_cpu_names); i++)
++ candidates.safe_push (rs6000_supported_cpu_names[i]);
++ candidates_list_and_hint (cpu, s, candidates);
++ fatal_error (
++ input_location,
++ "Unsupported cpu name returned from kernel for -mcpu=native: %s\n"
++ "Please use an explicit cpu name. Valid cpu names are: %s",
++ cpu, s);
++ }
+ }
+ return NULL;
+ }
+--
+2.27.0
+
diff --git a/8.5.0/gentoo/README.history b/8.5.0/gentoo/README.history
index ecd2aa8..b2d4c99 100644
--- a/8.5.0/gentoo/README.history
+++ b/8.5.0/gentoo/README.history
@@ -1,3 +1,7 @@
+3 TODO
+ + 31_all_powerpcspe-pie-crt.patch
+ + 32_all_powerpcspe-march-PLATFORM.patch
+
2 05 July 2021
+ 30_all_remove-cyclades.patch