summaryrefslogtreecommitdiff
path: root/tools/ld.musl-clang.in
blob: 93763d6b2cff585323477b30193cb933e0101623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
cc="@CC@"
libc_lib="@LIBDIR@"
ldso="@LDSO@"
cleared=
shared=
userlinkdir=
userlink=

for x ; do
    test "$cleared" || set -- ; cleared=1

    case "$x" in
        -L-user-start)
            userlinkdir=1
            ;;
        -L-user-end)
            userlinkdir=
            ;;
        -L*)
            test "$userlinkdir" && set -- "$@" "$x"
            ;;
        -l-user-start)
            userlink=1
            ;;
        -l-user-end)
            userlink=
            ;;
        crtbegin*.o|crtend*.o)
            set -- "$@" $($cc -print-file-name=$x)
            ;;
        -lgcc|-lgcc_eh)
            file=lib${x#-l}.a
            set -- "$@" $($cc -print-file-name=$file)
            ;;
        -l*)
            test "$userlink" && set -- "$@" "$x"
            ;;
        -shared)
            shared=1
            set -- "$@" -shared
            ;;
        -sysroot=*|--sysroot=*)
            ;;
        *)
            set -- "$@" "$x"
            ;;
    esac
done

exec $($cc -print-prog-name=ld) -nostdlib "$@" -lc -dynamic-linker "$ldso"