track all live threads in an AS-safe, fully-consistent linked list
[musl.git] / tools / ld.musl-clang.in
blob93763d6b2cff585323477b30193cb933e0101623
1 #!/bin/sh
2 cc="@CC@"
3 libc_lib="@LIBDIR@"
4 ldso="@LDSO@"
5 cleared=
6 shared=
7 userlinkdir=
8 userlink=
10 for x ; do
11 test "$cleared" || set -- ; cleared=1
13 case "$x" in
14 -L-user-start)
15 userlinkdir=1
17 -L-user-end)
18 userlinkdir=
20 -L*)
21 test "$userlinkdir" && set -- "$@" "$x"
23 -l-user-start)
24 userlink=1
26 -l-user-end)
27 userlink=
29 crtbegin*.o|crtend*.o)
30 set -- "$@" $($cc -print-file-name=$x)
32 -lgcc|-lgcc_eh)
33 file=lib${x#-l}.a
34 set -- "$@" $($cc -print-file-name=$file)
36 -l*)
37 test "$userlink" && set -- "$@" "$x"
39 -shared)
40 shared=1
41 set -- "$@" -shared
43 -sysroot=*|--sysroot=*)
46 set -- "$@" "$x"
48 esac
49 done
51 exec $($cc -print-prog-name=ld) -nostdlib "$@" -lc -dynamic-linker "$ldso"