mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-13 11:19:50 +03:00
main/gcc: support static-pie on all arches
gcc doesn't enable static-pie for all arches. As of this writing arm 32-bit is missing. musl supports static-pie on all arches so this should be allowed on all arches. Without this patch binaries with (only) -static-pie are broken on some arches. Fixes https://gitlab.alpinelinux.org/alpine/aports/-/issues/16942
This commit is contained in:
parent
1fcba2f610
commit
2013d4208b
2 changed files with 104 additions and 1 deletions
101
main/gcc/0037-static-pie.patch
Normal file
101
main/gcc/0037-static-pie.patch
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
Patch-Source: https://github.com/richfelker/musl-cross-make/blob/6f3701d08137496d5aac479e3a3977b5ae993c1f/patches/gcc-14.2.0/0004-static-pie.diff
|
||||||
|
|
||||||
|
gcc doesn't enable static-pie for all arches. As of this writing arm
|
||||||
|
32-bit is missing. musl supports static-pie on all arches so this
|
||||||
|
should be allowed on all arches.
|
||||||
|
|
||||||
|
Without this patch binaries with (only) -static-pie are broken on some
|
||||||
|
arches.
|
||||||
|
|
||||||
|
diff --git a/gcc/common.opt b/gcc/common.opt
|
||||||
|
index a75b44ee47e..7c564818b49 100644
|
||||||
|
--- a/gcc/common.opt
|
||||||
|
+++ b/gcc/common.opt
|
||||||
|
@@ -3473,11 +3473,11 @@ Driver
|
||||||
|
|
||||||
|
no-pie
|
||||||
|
Driver RejectNegative Negative(shared)
|
||||||
|
-Don't create a dynamically linked position independent executable.
|
||||||
|
+Don't create a position independent executable.
|
||||||
|
|
||||||
|
pie
|
||||||
|
Driver RejectNegative Negative(no-pie)
|
||||||
|
-Create a dynamically linked position independent executable.
|
||||||
|
+Create a position independent executable.
|
||||||
|
|
||||||
|
static-pie
|
||||||
|
Driver RejectNegative Negative(pie)
|
||||||
|
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
|
||||||
|
index 5ebbf42a13d..bb907d8e89a 100644
|
||||||
|
--- a/gcc/config/gnu-user.h
|
||||||
|
+++ b/gcc/config/gnu-user.h
|
||||||
|
@@ -51,13 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
#define GNU_USER_TARGET_STARTFILE_SPEC \
|
||||||
|
"%{shared:; \
|
||||||
|
pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
|
||||||
|
- static:crt1.o%s; \
|
||||||
|
- static-pie:rcrt1.o%s; \
|
||||||
|
+ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
|
||||||
|
" PIE_SPEC ":Scrt1.o%s; \
|
||||||
|
:crt1.o%s} " \
|
||||||
|
GNU_USER_TARGET_CRTI " \
|
||||||
|
- %{static:crtbeginT.o%s; \
|
||||||
|
- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
|
||||||
|
+ %{shared|" PIE_SPEC ":crtbeginS.o%s; \
|
||||||
|
+ static:crtbeginT.o%s; \
|
||||||
|
:crtbegin.o%s} \
|
||||||
|
%{fvtable-verify=none:%s; \
|
||||||
|
fvtable-verify=preinit:vtv_start_preinit.o%s; \
|
||||||
|
@@ -73,11 +72,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
GNU userspace "finalizer" file, `crtn.o'. */
|
||||||
|
|
||||||
|
#define GNU_USER_TARGET_ENDFILE_SPEC \
|
||||||
|
- "%{!static:%{fvtable-verify=none:%s; \
|
||||||
|
+ "%{static|static-pie:; \
|
||||||
|
+ 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; \
|
||||||
|
+ fvtable-verify=std:vtv_end.o%s} \
|
||||||
|
+ %{shared|" PIE_SPEC ":crtendS.o%s; \
|
||||||
|
:crtend.o%s} " \
|
||||||
|
GNU_USER_TARGET_CRTN " " \
|
||||||
|
CRTOFFLOADEND
|
||||||
|
@@ -106,7 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
|
||||||
|
|
||||||
|
#if defined(HAVE_LD_EH_FRAME_HDR)
|
||||||
|
-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
|
||||||
|
+#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
|
||||||
|
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
|
||||||
|
index 3c81c5798d8..cd96eac5d12 100644
|
||||||
|
--- a/gcc/gcc.cc
|
||||||
|
+++ b/gcc/gcc.cc
|
||||||
|
@@ -1010,7 +1010,7 @@ proper position among the other output files. */
|
||||||
|
#define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
|
||||||
|
#define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
|
||||||
|
#else
|
||||||
|
-#define PIE_SPEC "pie"
|
||||||
|
+#define PIE_SPEC "pie|static-pie"
|
||||||
|
#define FPIE1_SPEC "fpie"
|
||||||
|
#define NO_FPIE1_SPEC FPIE1_SPEC ":;"
|
||||||
|
#define FPIE2_SPEC "fPIE"
|
||||||
|
@@ -1034,12 +1034,12 @@ proper position among the other output files. */
|
||||||
|
#ifndef LINK_PIE_SPEC
|
||||||
|
#ifdef HAVE_LD_PIE
|
||||||
|
#ifndef LD_PIE_SPEC
|
||||||
|
-#define LD_PIE_SPEC "-pie"
|
||||||
|
+#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define LD_PIE_SPEC ""
|
||||||
|
#endif
|
||||||
|
-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
|
||||||
|
+#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LINK_BUILDID_SPEC
|
|
@ -11,7 +11,7 @@ _pkgsnap="${pkgver##*_git}"
|
||||||
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
|
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
|
||||||
|
|
||||||
pkgname="$pkgname$_target"
|
pkgname="$pkgname$_target"
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
pkgdesc="The GNU Compiler Collection"
|
pkgdesc="The GNU Compiler Collection"
|
||||||
url="https://gcc.gnu.org"
|
url="https://gcc.gnu.org"
|
||||||
arch="all"
|
arch="all"
|
||||||
|
@ -256,6 +256,7 @@ source="https://gcc.gnu.org/pub/gcc/releases/gcc-$_pkgbase/gcc-$_pkgbase.tar.xz
|
||||||
0034-libgo-fix-lfs64-use.patch
|
0034-libgo-fix-lfs64-use.patch
|
||||||
0035-loongarch-disable-multilib-support.patch
|
0035-loongarch-disable-multilib-support.patch
|
||||||
0036-libphobos-add-riscv64-and-loongarch64-support.patch
|
0036-libphobos-add-riscv64-and-loongarch64-support.patch
|
||||||
|
0037-static-pie.patch
|
||||||
"
|
"
|
||||||
|
|
||||||
# secfixes:
|
# secfixes:
|
||||||
|
@ -764,4 +765,5 @@ c474f34e6f9a4239d486a65141a133dbe8ce91427d502a57a9fd6eb403478a2b5715ba74f24c1cc0
|
||||||
c4482ffc36e7894b2140800159f4cbc9a3e9011e43a69b69f4fa92d5a11e2ee645c7e21df4423dd1e0636e8890849a5719647bfbdf84f951d638f8f488cb718c 0034-libgo-fix-lfs64-use.patch
|
c4482ffc36e7894b2140800159f4cbc9a3e9011e43a69b69f4fa92d5a11e2ee645c7e21df4423dd1e0636e8890849a5719647bfbdf84f951d638f8f488cb718c 0034-libgo-fix-lfs64-use.patch
|
||||||
65df1d489e8d07a811f39e27fd29e3b2b4164fbc2c5fdc16a5142886d94a96e3fb28ccf4f20dd297ba6540ef8ea1ac3eb65a4279494639bf2f0f8376a3896cc3 0035-loongarch-disable-multilib-support.patch
|
65df1d489e8d07a811f39e27fd29e3b2b4164fbc2c5fdc16a5142886d94a96e3fb28ccf4f20dd297ba6540ef8ea1ac3eb65a4279494639bf2f0f8376a3896cc3 0035-loongarch-disable-multilib-support.patch
|
||||||
06f64544fd8bc4b6c8b06410c5198aa8fb4e82c232afc0cad83b2c69ac5d39399968206defa78297222700cd18e7fd7e8244afa76d343406a01f657c86306453 0036-libphobos-add-riscv64-and-loongarch64-support.patch
|
06f64544fd8bc4b6c8b06410c5198aa8fb4e82c232afc0cad83b2c69ac5d39399968206defa78297222700cd18e7fd7e8244afa76d343406a01f657c86306453 0036-libphobos-add-riscv64-and-loongarch64-support.patch
|
||||||
|
8870baf56550f7359d262f68904558bf9f95674a50324e86d121d0ca2cca7155e45fb023f467a46c96c30f4943f66ce104608c642b5378d1c4311a0959c444ed 0037-static-pie.patch
|
||||||
"
|
"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue