about summary refs log tree commit diff
path: root/tools/gen-musl-gcc.sh
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-01-24 00:22:27 -0500
committerRich Felker <dalias@aerifal.cx>2012-01-24 00:22:27 -0500
commitb768c7bc6398e297945b08dd5315cae472279a3a (patch)
treeade9cc39e97c600ff2f101ef02cef192bb4a8959 /tools/gen-musl-gcc.sh
parentd0678b58ab34f9afae099afc839430bdcd91aaac (diff)
downloadmusl-b768c7bc6398e297945b08dd5315cae472279a3a.tar.gz
musl-b768c7bc6398e297945b08dd5315cae472279a3a.tar.xz
musl-b768c7bc6398e297945b08dd5315cae472279a3a.zip
make gcc wrapper support -shared correctly
it was previously attempting to link start files as part of shared
objects. this is definitely wrong and depending on the platform and
linker could range from just adding extraneous junk to introducing
textrels to making linking fail entirely.
Diffstat (limited to 'tools/gen-musl-gcc.sh')
-rw-r--r--tools/gen-musl-gcc.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/gen-musl-gcc.sh b/tools/gen-musl-gcc.sh
index 1ef0550f..edc40846 100644
--- a/tools/gen-musl-gcc.sh
+++ b/tools/gen-musl-gcc.sh
@@ -29,6 +29,7 @@ for i ; do
 case "$skip$i" in
 -I|-L) skip=--- ; continue ;;
 -[cSE]|-M*) nolink=1 ;;
+-shared) nocrt=1 ;;
 -*) ;;
 *) havefile=1 ;;
 esac
@@ -37,13 +38,17 @@ done
 
 [ "$havefile" ] || nolink=1
 
+[ "$nolink" ] && nocrt=1
+
+[ "$nocrt" ] || set -- "$libc_start" "$libc_crt" "$@" "$libc_end" \
+
 [ "$nolink" ] || {
 tmp_specs=$HOME/.specs.tmp.$$
 printf '*link_libgcc:\n\n\n' > "$tmp_specs" || exit 1
 exec 3<"$tmp_specs"
 rm -f "$tmp_specs"
-set -- -specs=/proc/self/fd/3 "$libc_start" "$libc_crt" "$@" "$libc_end" \
-  -Wl,--start-group -lc -lgcc -lgcc_eh -Wl,--end-group \
+set -- -specs=/proc/self/fd/3 "$@" \
+  -Wl,--as-needed -Wl,--start-group -lc -lgcc -lgcc_eh -Wl,--end-group \
   -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
 }