From 4be756d35cb0c603ba9255a9fb187c39e082413b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 21 Jul 2025 02:21:23 +0000 Subject: [PATCH] update all static pie patches to ensure -static reached the linker on some targets, the logic for the compiler option -static seems not to be processed when -pie is present. rather than playing whack-a-mole, just ensure LD_PIE_SPEC specs always pass -static to ld if either -static or -static-pie is present on the compiler driver command line. this may produce redundant -static arguments but it doesn't matter. --- patches/gcc-10.3.0/0004-static-pie.diff | 2 +- patches/gcc-11.2.0/0004-static-pie.diff | 2 +- patches/gcc-11.5.0/0004-static-pie.diff | 2 +- patches/gcc-12.4.0/0004-static-pie.diff | 2 +- patches/gcc-13.3.0/0004-static-pie.diff | 2 +- patches/gcc-14.2.0/0004-static-pie.diff | 2 +- patches/gcc-14.3.0/0004-static-pie.diff | 2 +- patches/gcc-15.1.0/0004-static-pie.diff | 2 +- patches/gcc-6.5.0/0020-static-pie-support.diff | 2 +- patches/gcc-7.5.0/0010-static-pie-support.diff | 2 +- patches/gcc-8.5.0/0012-static-pie.diff | 2 +- patches/gcc-9.4.0/0012-static-pie.diff | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/patches/gcc-10.3.0/0004-static-pie.diff b/patches/gcc-10.3.0/0004-static-pie.diff index b265376..469f8e4 100644 --- a/patches/gcc-10.3.0/0004-static-pie.diff +++ b/patches/gcc-10.3.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index e6887590ae2..df6e3965f13 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-11.2.0/0004-static-pie.diff b/patches/gcc-11.2.0/0004-static-pie.diff index 232dc5d..4295b52 100644 --- a/patches/gcc-11.2.0/0004-static-pie.diff +++ b/patches/gcc-11.2.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-11.5.0/0004-static-pie.diff b/patches/gcc-11.5.0/0004-static-pie.diff index 232dc5d..4295b52 100644 --- a/patches/gcc-11.5.0/0004-static-pie.diff +++ b/patches/gcc-11.5.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-12.4.0/0004-static-pie.diff b/patches/gcc-12.4.0/0004-static-pie.diff index a85a3d7..ec3f06a 100644 --- a/patches/gcc-12.4.0/0004-static-pie.diff +++ b/patches/gcc-12.4.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-13.3.0/0004-static-pie.diff b/patches/gcc-13.3.0/0004-static-pie.diff index a85a3d7..ec3f06a 100644 --- a/patches/gcc-13.3.0/0004-static-pie.diff +++ b/patches/gcc-13.3.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-14.2.0/0004-static-pie.diff b/patches/gcc-14.2.0/0004-static-pie.diff index a85a3d7..ec3f06a 100644 --- a/patches/gcc-14.2.0/0004-static-pie.diff +++ b/patches/gcc-14.2.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-14.3.0/0004-static-pie.diff b/patches/gcc-14.3.0/0004-static-pie.diff index a85a3d7..ec3f06a 100644 --- a/patches/gcc-14.3.0/0004-static-pie.diff +++ b/patches/gcc-14.3.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-15.1.0/0004-static-pie.diff b/patches/gcc-15.1.0/0004-static-pie.diff index a85a3d7..ec3f06a 100644 --- a/patches/gcc-15.1.0/0004-static-pie.diff +++ b/patches/gcc-15.1.0/0004-static-pie.diff @@ -80,7 +80,7 @@ index 3c81c5798d8..cd96eac5d12 100644 #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}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-6.5.0/0020-static-pie-support.diff b/patches/gcc-6.5.0/0020-static-pie-support.diff index e2a9b9c..44b6c85 100644 --- a/patches/gcc-6.5.0/0020-static-pie-support.diff +++ b/patches/gcc-6.5.0/0020-static-pie-support.diff @@ -34,7 +34,7 @@ index 0576ea7..0a280e0 100644 #ifdef HAVE_LD_PIE #ifndef LD_PIE_SPEC -#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic}" ++#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-7.5.0/0010-static-pie-support.diff b/patches/gcc-7.5.0/0010-static-pie-support.diff index 02ae751..8e73efe 100644 --- a/patches/gcc-7.5.0/0010-static-pie-support.diff +++ b/patches/gcc-7.5.0/0010-static-pie-support.diff @@ -53,7 +53,7 @@ index 91eb0534722..74a390e6005 100644 #ifdef HAVE_LD_PIE #ifndef LD_PIE_SPEC -#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic}" ++#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-8.5.0/0012-static-pie.diff b/patches/gcc-8.5.0/0012-static-pie.diff index c0fcf07..0f57c5c 100644 --- a/patches/gcc-8.5.0/0012-static-pie.diff +++ b/patches/gcc-8.5.0/0012-static-pie.diff @@ -105,7 +105,7 @@ index eb1610ba8b0..87560afb03c 100644 #ifdef HAVE_LD_PIE #ifndef LD_PIE_SPEC -#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static-pie:-static} %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}" ++#define LD_PIE_SPEC "-pie %{static-pie:-static} %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-9.4.0/0012-static-pie.diff b/patches/gcc-9.4.0/0012-static-pie.diff index 400d7a1..3e89ebc 100644 --- a/patches/gcc-9.4.0/0012-static-pie.diff +++ b/patches/gcc-9.4.0/0012-static-pie.diff @@ -74,7 +74,7 @@ index d185c01b257..5d3f81c5fc5 100644 #ifdef HAVE_LD_PIE #ifndef LD_PIE_SPEC -#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static-pie:-static} %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}" ++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic -static}" #endif #else #define LD_PIE_SPEC ""