diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-09-02 15:28:30 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-09-02 15:28:30 +0000 |
commit | d2bb2d39181d8d8b5d54e83456e1e7c8b1821a8d (patch) | |
tree | cbe07b7c735433a73907ed80acb1013580fd8db3 | |
parent | 8d91c13df5ecd4e2e2f7e4bea6bf5bec9495e1ca (diff) | |
download | busybox-w32-d2bb2d39181d8d8b5d54e83456e1e7c8b1821a8d.tar.gz busybox-w32-d2bb2d39181d8d8b5d54e83456e1e7c8b1821a8d.tar.bz2 busybox-w32-d2bb2d39181d8d8b5d54e83456e1e7c8b1821a8d.zip |
- Generally strip off -l that does not pull in a lib.
If l_list is non-empty then add the group flags.
-rwxr-xr-x | scripts/trylink | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/scripts/trylink b/scripts/trylink index 69473076b..cede22be2 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
@@ -14,9 +14,11 @@ try() { | |||
14 | BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` | 14 | BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` |
15 | 15 | ||
16 | # First link with all libs. If it fails, bail out | 16 | # First link with all libs. If it fails, bail out |
17 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'` | 17 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
18 | |||
18 | echo "Trying libraries: $BBOX_LIB_LIST" | 19 | echo "Trying libraries: $BBOX_LIB_LIST" |
19 | try "-Wl,--start-group $l_list -Wl,--end-group" "$@" \ | 20 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
21 | try "$l_list" "$@" \ | ||
20 | || { | 22 | || { |
21 | echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group" | 23 | echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group" |
22 | cat busybox_ld.err | 24 | cat busybox_ld.err |
@@ -38,16 +40,8 @@ while test "$BBOX_LIB_LIST"; do | |||
38 | all_needed=true | 40 | all_needed=true |
39 | for one in $BBOX_LIB_LIST; do | 41 | for one in $BBOX_LIB_LIST; do |
40 | without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs` | 42 | without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs` |
41 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/'` | 43 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
42 | # If l_list is just "-l" without a lib, then make sure to test the | 44 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
43 | # correct thing to fail: just using -l will fail, so the last lib | ||
44 | # (usually m in my case) will incorrectly be added as needed. | ||
45 | if test "x$without_one" != "x"; then | ||
46 | l_list="-Wl,--start-group $l_list -Wl,--end-group" | ||
47 | else | ||
48 | # without_one is empty, so l_list has to be empty too | ||
49 | l_list="" | ||
50 | fi | ||
51 | $debug && echo "Trying -l options: '$l_list'" | 45 | $debug && echo "Trying -l options: '$l_list'" |
52 | if try "$l_list" "$@"; then | 46 | if try "$l_list" "$@"; then |
53 | echo "Library $one is not needed" | 47 | echo "Library $one is not needed" |
@@ -71,10 +65,12 @@ done | |||
71 | ####$ever_discarded && { | 65 | ####$ever_discarded && { |
72 | # Make the binary with final, minimal list of libs | 66 | # Make the binary with final, minimal list of libs |
73 | echo "Final link with: $BBOX_LIB_LIST" | 67 | echo "Final link with: $BBOX_LIB_LIST" |
74 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'` | 68 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
75 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 69 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
70 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" | ||
76 | if ! test -f busybox_ldscript; then | 71 | if ! test -f busybox_ldscript; then |
77 | try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" "$@" >busybox_ld.out ####|| exit 1 | 72 | |
73 | try "$l_list" "$@" >busybox_ld.out ####|| exit 1 | ||
78 | else | 74 | else |
79 | echo "Custom linker script 'busybox_ldscript' found, using it" | 75 | echo "Custom linker script 'busybox_ldscript' found, using it" |
80 | # Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out): | 76 | # Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out): |
@@ -82,7 +78,7 @@ done | |||
82 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) | 78 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) |
83 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) | 79 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) |
84 | # This will eliminate most of the data padding (~3kb). | 80 | # This will eliminate most of the data padding (~3kb). |
85 | try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out | 81 | try "$l_list -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out |
86 | fi | 82 | fi |
87 | ####} | 83 | ####} |
88 | ####rm busybox_ld.err | 84 | ####rm busybox_ld.err |