From b49456e19acd33bc4fc40e6125812fb82d66619d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 10 Feb 2020 12:18:24 -0500 Subject: [PATCH] fix gcc 8+ static pie patches to make -static-pie pass -static to ld previously this was missed because there's target-specific spec magic for a few targets to do it, but many including arm don't have it. without this, use of -static-pie produces broken binaries which lack an interpreter but link to shared libraries on the targets affected. use of -static -pie (preferred form) is not affected. gcc versions prior to 8.x did not have -static-pie (because there was no upstream static pie support) so this patch is only needed for 8+, and only to prevent breakage if someone uses the -static-pie option instead of -static with -pie. --- patches/gcc-8.3.0/0012-static-pie.diff | 2 +- patches/gcc-9.2.0/0012-static-pie.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/gcc-8.3.0/0012-static-pie.diff b/patches/gcc-8.3.0/0012-static-pie.diff index acd5eb8..c0fcf07 100644 --- a/patches/gcc-8.3.0/0012-static-pie.diff +++ b/patches/gcc-8.3.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|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}" #endif #else #define LD_PIE_SPEC "" diff --git a/patches/gcc-9.2.0/0012-static-pie.diff b/patches/gcc-9.2.0/0012-static-pie.diff index ec3a4e6..400d7a1 100644 --- a/patches/gcc-9.2.0/0012-static-pie.diff +++ b/patches/gcc-9.2.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|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}" #endif #else #define LD_PIE_SPEC ""