fix musl-gcc wrapper to be compatible with default-pie gcc toolchains
authorRich Felker <dalias@aerifal.cx>
Thu, 2 Aug 2018 23:15:48 +0000 (19:15 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 2 Aug 2018 23:15:48 +0000 (19:15 -0400)
the specfile for the wrapper was written assuming output is pie only
if -pie appears on the command line. recent (and older patched)
versions of gcc can be configured to produce pie output by default,
adn when used with such a toolchain, the wrapper linked the wrong
startfiles (crt*) containing pic-incompatible code.

rather than trying to figure out gcc's default, simply always use the
pic-compatible start files.

tools/musl-gcc.specs.sh

index 294e24f75503be91364dea17c4d0bdbe161c4210..3049257446e113b0fc745f8efeb3e2b101e07798 100644 (file)
@@ -17,10 +17,10 @@ cat <<EOF
 libgcc.a%s %:if-exists(libgcc_eh.a%s)
 
 *startfile:
-%{!shared: $libdir/%{pie:S}crt1.o} $libdir/crti.o %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}
+%{!shared: $libdir/Scrt1.o} $libdir/crti.o crtbeginS.o%s
 
 *endfile:
-%{shared|pie:crtendS.o%s;:crtend.o%s} $libdir/crtn.o
+crtendS.o%s $libdir/crtn.o
 
 *link:
 -dynamic-linker $ldso -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic}