diff options
-rw-r--r-- | Makefile.flags | 13 | ||||
-rwxr-xr-x | scripts/trylink | 28 |
2 files changed, 20 insertions, 21 deletions
diff --git a/Makefile.flags b/Makefile.flags index c64a5c838..764ce16e8 100644 --- a/Makefile.flags +++ b/Makefile.flags | |||
@@ -59,27 +59,24 @@ ifeq ($(CONFIG_STATIC),y) | |||
59 | LDFLAGS += -static | 59 | LDFLAGS += -static |
60 | endif | 60 | endif |
61 | 61 | ||
62 | BBOX_LIB_LIST = m crypt | 62 | LDLIBS = m crypt |
63 | 63 | ||
64 | ifeq ($(CONFIG_PAM),y) | 64 | ifeq ($(CONFIG_PAM),y) |
65 | BBOX_LIB_LIST += pam pam_misc | 65 | LDLIBS += pam pam_misc |
66 | endif | 66 | endif |
67 | 67 | ||
68 | ifeq ($(CONFIG_SELINUX),y) | 68 | ifeq ($(CONFIG_SELINUX),y) |
69 | BBOX_LIB_LIST += selinux sepol | 69 | LDLIBS += selinux sepol |
70 | endif | 70 | endif |
71 | 71 | ||
72 | ifeq ($(CONFIG_EFENCE),y) | 72 | ifeq ($(CONFIG_EFENCE),y) |
73 | BBOX_LIB_LIST += efence | 73 | LDLIBS += efence |
74 | endif | 74 | endif |
75 | 75 | ||
76 | ifeq ($(CONFIG_DMALLOC),y) | 76 | ifeq ($(CONFIG_DMALLOC),y) |
77 | BBOX_LIB_LIST += dmalloc | 77 | LDLIBS += dmalloc |
78 | endif | 78 | endif |
79 | 79 | ||
80 | # For scripts/trylink | ||
81 | export BBOX_LIB_LIST | ||
82 | |||
83 | #LDFLAGS += -nostdlib | 80 | #LDFLAGS += -nostdlib |
84 | 81 | ||
85 | LDFLAGS_ELF2FLT = -Wl,-elf2flt | 82 | LDFLAGS_ELF2FLT = -Wl,-elf2flt |
diff --git a/scripts/trylink b/scripts/trylink index 19b0ba715..c621b7c01 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
@@ -21,12 +21,12 @@ A_FILES="$5" | |||
21 | LDLIBS="$6" | 21 | LDLIBS="$6" |
22 | 22 | ||
23 | # Sanitize lib list (dups, extra spaces etc) | 23 | # Sanitize lib list (dups, extra spaces etc) |
24 | BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` | 24 | LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` |
25 | 25 | ||
26 | # First link with all libs. If it fails, bail out | 26 | # First link with all libs. If it fails, bail out |
27 | echo "Trying libraries: $BBOX_LIB_LIST" | 27 | echo "Trying libraries: $LDLIBS" |
28 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 28 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
29 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 29 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
30 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 30 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
31 | try $CC $LDFLAGS \ | 31 | try $CC $LDFLAGS \ |
32 | -o $EXE -Wl,-Map -Wl,$EXE.map \ | 32 | -o $EXE -Wl,-Map -Wl,$EXE.map \ |
@@ -42,11 +42,11 @@ try $CC $LDFLAGS \ | |||
42 | 42 | ||
43 | # Now try to remove each lib and build without it. | 43 | # Now try to remove each lib and build without it. |
44 | # Stop when no lib can be removed. | 44 | # Stop when no lib can be removed. |
45 | while test "$BBOX_LIB_LIST"; do | 45 | while test "$LDLIBS"; do |
46 | $debug && echo "Trying libraries: $BBOX_LIB_LIST" | 46 | $debug && echo "Trying libraries: $LDLIBS" |
47 | all_needed=true | 47 | all_needed=true |
48 | for one in $BBOX_LIB_LIST; do | 48 | for one in $LDLIBS; do |
49 | without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs` | 49 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` |
50 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 50 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
51 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 51 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
52 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 52 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
@@ -59,7 +59,7 @@ while test "$BBOX_LIB_LIST"; do | |||
59 | >/dev/null | 59 | >/dev/null |
60 | if test $? = 0; then | 60 | if test $? = 0; then |
61 | echo "Library $one is not needed" | 61 | echo "Library $one is not needed" |
62 | BBOX_LIB_LIST="$without_one" | 62 | LDLIBS="$without_one" |
63 | all_needed=false | 63 | all_needed=false |
64 | else | 64 | else |
65 | echo "Library $one is needed" | 65 | echo "Library $one is needed" |
@@ -70,12 +70,12 @@ while test "$BBOX_LIB_LIST"; do | |||
70 | # If there is no space char, the list has just one lib. | 70 | # If there is no space char, the list has just one lib. |
71 | # I'm not sure that in this case lib really is 100% needed. | 71 | # I'm not sure that in this case lib really is 100% needed. |
72 | # Let's try linking without it anyway... thus commented out. | 72 | # Let's try linking without it anyway... thus commented out. |
73 | #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break | 73 | #{ echo "$LDLIBS" | grep -q ' '; } || break |
74 | done | 74 | done |
75 | 75 | ||
76 | # Make the binary with final, minimal list of libs | 76 | # Make the binary with final, minimal list of libs |
77 | echo "Final link with: $BBOX_LIB_LIST" | 77 | echo "Final link with: $LDLIBS" |
78 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 78 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
79 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" | 79 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" |
80 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 80 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
81 | if ! test -f busybox_ldscript; then | 81 | if ! test -f busybox_ldscript; then |
@@ -87,11 +87,11 @@ if ! test -f busybox_ldscript; then | |||
87 | >/dev/null | 87 | >/dev/null |
88 | else | 88 | else |
89 | echo "Custom linker script 'busybox_ldscript' found, using it" | 89 | echo "Custom linker script 'busybox_ldscript' found, using it" |
90 | # Add SORT_BY_ALIGNMENT to linker script (found in ${EXE}_ld.out): | 90 | # Add SORT_BY_ALIGNMENT to linker script (found in $EXE.out): |
91 | # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } | 91 | # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } |
92 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) | 92 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) |
93 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) | 93 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) |
94 | # This will eliminate most of the data padding (~3kb). | 94 | # This will eliminate most of the padding (~3kb). |
95 | try $CC $LDFLAGS \ | 95 | try $CC $LDFLAGS \ |
96 | -o $EXE -Wl,-Map -Wl,$EXE.map \ | 96 | -o $EXE -Wl,-Map -Wl,$EXE.map \ |
97 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | 97 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ |
@@ -118,6 +118,7 @@ try $CC $LDFLAGS \ | |||
118 | echo "Linking $EXE failed" | 118 | echo "Linking $EXE failed" |
119 | exit 1 | 119 | exit 1 |
120 | } | 120 | } |
121 | strip -s --remove-section=.note --remove-section=.comment $EXE | ||
121 | 122 | ||
122 | EXE="0lib/busybox" | 123 | EXE="0lib/busybox" |
123 | try $CC $LDFLAGS \ | 124 | try $CC $LDFLAGS \ |
@@ -131,3 +132,4 @@ try $CC $LDFLAGS \ | |||
131 | echo "Linking $EXE failed" | 132 | echo "Linking $EXE failed" |
132 | exit 1 | 133 | exit 1 |
133 | } | 134 | } |
135 | strip -s --remove-section=.note --remove-section=.comment $EXE | ||