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.
This commit is contained in:
Rich Felker 2020-02-10 12:18:24 -05:00
parent d7f31bde7e
commit b49456e19a
2 changed files with 2 additions and 2 deletions

View File

@ -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 ""

View File

@ -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 ""