summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-16 18:50:56 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-16 18:50:56 +0000
commite755e827f7c8ecb21787a4369d7afdeda54d112b (patch)
tree007b1506e69ffcc25bc6ba3b0e6686d806a34264 /scripts
parented6ac53104d811ee88c71aff45c7cad666aaee46 (diff)
downloadbusybox-w32-1_7_1.tar.gz
busybox-w32-1_7_1.tar.bz2
busybox-w32-1_7_1.zip
apply post 1.7.0 patches, set version to 1.7.11_7_1
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/trylink58
1 files changed, 23 insertions, 35 deletions
diff --git a/scripts/trylink b/scripts/trylink
index 4eaa334d5..0b8f6c062 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -14,37 +14,30 @@ try() {
14BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` 14BBOX_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
17l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'`
18echo "Trying libraries: $BBOX_LIB_LIST" 17echo "Trying libraries: $BBOX_LIB_LIST"
19try "-Wl,--start-group $l_list -Wl,--end-group" "$@" \ 18l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
19test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
20try "$l_list" "$@" \
20|| { 21|| {
21 echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group" 22 echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group"
22 cat busybox_ld.err 23 cat busybox_ld.err
23 exit 1 24 exit 1
24} 25}
25 26
26#### Hack disabled: conflicts with ld --verbose flag in last link phase
27
28##### Hack: we are not supposed to know executable name,
29##### but this hack cuts down link time
30####mv busybox_unstripped busybox_unstripped.tmp
31####mv busybox.map busybox.map.tmp
32
33# Now try to remove each lib and build without it. 27# Now try to remove each lib and build without it.
34# Stop when no lib can be removed. 28# Stop when no lib can be removed.
35####ever_discarded=false
36while test "$BBOX_LIB_LIST"; do 29while test "$BBOX_LIB_LIST"; do
37 $debug && echo "Trying libraries: $BBOX_LIB_LIST" 30 $debug && echo "Trying libraries: $BBOX_LIB_LIST"
38 all_needed=true 31 all_needed=true
39 for one in $BBOX_LIB_LIST; do 32 for one in $BBOX_LIB_LIST; do
40 without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs` 33 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/'` 34 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
42 $debug && echo "Trying -l options: $l_list" 35 test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
43 if try "-Wl,--start-group $l_list -Wl,--end-group" "$@"; then 36 $debug && echo "Trying -l options: '$l_list'"
37 if try "$l_list" "$@"; then
44 echo "Library $one is not needed" 38 echo "Library $one is not needed"
45 BBOX_LIB_LIST="$without_one" 39 BBOX_LIB_LIST="$without_one"
46 all_needed=false 40 all_needed=false
47#### ever_discarded=true
48 else 41 else
49 echo "Library $one is needed" 42 echo "Library $one is needed"
50 fi 43 fi
@@ -57,24 +50,19 @@ while test "$BBOX_LIB_LIST"; do
57 #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break 50 #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break
58done 51done
59 52
60####mv busybox_unstripped.tmp busybox_unstripped 53# Make the binary with final, minimal list of libs
61####mv busybox.map.tmp busybox.map 54echo "Final link with: $BBOX_LIB_LIST"
62####$ever_discarded && { 55l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
63 # Make the binary with final, minimal list of libs 56test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose"
64 echo "Final link with: $BBOX_LIB_LIST" 57# --verbose gives us gobs of info to stdout (e.g. linker script used)
65 l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'` 58if ! test -f busybox_ldscript; then
66 # --verbose gives us gobs of info to stdout (e.g. linker script used) 59 try "$l_list -Wl,--verbose" "$@" >busybox_ld.out
67 if ! test -f busybox_ldscript; then 60else
68 try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" "$@" >busybox_ld.out ####|| exit 1 61 echo "Custom linker script 'busybox_ldscript' found, using it"
69 else 62 # Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out):
70 echo "Custom linker script 'busybox_ldscript' found, using it" 63 # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) }
71 # Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out): 64 # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*)
72 # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } 65 # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*)
73 # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) 66 # This will eliminate most of the data padding (~3kb).
74 # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) 67 try "$l_list -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out
75 # This will eliminate most of the data padding (~3kb). 68fi
76 try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out
77 fi
78####}
79####rm busybox_ld.err
80####exit 0 # Ensure "success" exit code