Browse Source

fix musl-gcc wrapper to be compatible with default-pie gcc toolchains

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.
Rich Felker 5 years ago
parent
commit
7dad9c2125
1 changed files with 2 additions and 2 deletions
  1. 2 2
      tools/musl-gcc.specs.sh

+ 2 - 2
tools/musl-gcc.specs.sh

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