diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-08-12 20:58:27 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-08-12 20:58:27 +0000 |
| commit | 6ca409e0e4c198fe3081346eebbae3f068fe605a (patch) | |
| tree | 060cb05d99220a1eda399194d1209c269f0e8cd8 /scripts/trylink | |
| parent | 4185548984357df91311f30c8e43d95f33922576 (diff) | |
| download | busybox-w32-6ca409e0e4c198fe3081346eebbae3f068fe605a.tar.gz busybox-w32-6ca409e0e4c198fe3081346eebbae3f068fe605a.tar.bz2 busybox-w32-6ca409e0e4c198fe3081346eebbae3f068fe605a.zip | |
trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts
size saving: 0.5k
Diffstat (limited to 'scripts/trylink')
| -rwxr-xr-x | scripts/trylink | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/scripts/trylink b/scripts/trylink index 74acb4cdd..9b67deb49 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
| @@ -6,7 +6,7 @@ try() { | |||
| 6 | added="$1" | 6 | added="$1" |
| 7 | shift | 7 | shift |
| 8 | $debug && echo "Trying: $* $added" | 8 | $debug && echo "Trying: $* $added" |
| 9 | "$@" $added >busybox.map 2>busybox_ld.err | 9 | "$@" $added 2>busybox_ld.err |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | # Sanitize lib list (dups, extra spaces etc) | 12 | # Sanitize lib list (dups, extra spaces etc) |
| @@ -22,14 +22,17 @@ try "-Wl,--start-group $l_list -Wl,--end-group" "$@" \ | |||
| 22 | cat busybox_ld.err | 22 | cat busybox_ld.err |
| 23 | exit 1 | 23 | exit 1 |
| 24 | } | 24 | } |
| 25 | # Hack: we are not supposed to know executable name, | 25 | |
| 26 | # but this hack cuts down link time | 26 | #### Hack disabled: conflicts with ld --verbose flag in last link phase |
| 27 | mv busybox_unstripped busybox_unstripped.tmp | 27 | |
| 28 | mv busybox.map busybox.map.tmp | 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 | ||
| 29 | 32 | ||
| 30 | # Now try to remove each lib and build without it. | 33 | # Now try to remove each lib and build without it. |
| 31 | # Stop when no lib can be removed. | 34 | # Stop when no lib can be removed. |
| 32 | ever_discarded=false | 35 | ####ever_discarded=false |
| 33 | while test "$BBOX_LIB_LIST"; do | 36 | while test "$BBOX_LIB_LIST"; do |
| 34 | $debug && echo "Trying libraries: $BBOX_LIB_LIST" | 37 | $debug && echo "Trying libraries: $BBOX_LIB_LIST" |
| 35 | all_needed=true | 38 | all_needed=true |
| @@ -41,7 +44,7 @@ while test "$BBOX_LIB_LIST"; do | |||
| 41 | echo "Library $one is not needed" | 44 | echo "Library $one is not needed" |
| 42 | BBOX_LIB_LIST="$without_one" | 45 | BBOX_LIB_LIST="$without_one" |
| 43 | all_needed=false | 46 | all_needed=false |
| 44 | ever_discarded=true | 47 | #### ever_discarded=true |
| 45 | else | 48 | else |
| 46 | echo "Library $one is needed" | 49 | echo "Library $one is needed" |
| 47 | fi | 50 | fi |
| @@ -54,13 +57,23 @@ while test "$BBOX_LIB_LIST"; do | |||
| 54 | #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break | 57 | #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break |
| 55 | done | 58 | done |
| 56 | 59 | ||
| 57 | mv busybox_unstripped.tmp busybox_unstripped | 60 | ####mv busybox_unstripped.tmp busybox_unstripped |
| 58 | mv busybox.map.tmp busybox.map | 61 | ####mv busybox.map.tmp busybox.map |
| 59 | $ever_discarded && { | 62 | ####$ever_discarded && { |
| 60 | # Make the binary with final, minimal list of libs | 63 | # Make the binary with final, minimal list of libs |
| 61 | echo "Final link with: $BBOX_LIB_LIST" | 64 | echo "Final link with: $BBOX_LIB_LIST" |
| 62 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'` | 65 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'` |
| 63 | try "-Wl,--start-group $l_list -Wl,--end-group" "$@" || exit 1 | 66 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
| 64 | } | 67 | try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" "$@" >busybox_ld.out ####|| exit 1 |
| 65 | rm busybox_ld.err | 68 | # |
| 66 | exit 0 # Ensure "success" exit code | 69 | # Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out): |
| 70 | # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } | ||
| 71 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) | ||
| 72 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) | ||
| 73 | # This will eliminate most of the data padding. Use linker script | ||
| 74 | # by commenting "try" above and uncommenting this one (tested on i386): | ||
| 75 | #try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out | ||
| 76 | # | ||
| 77 | ####} | ||
| 78 | ####rm busybox_ld.err | ||
| 79 | ####exit 0 # Ensure "success" exit code | ||
