aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.flags13
-rwxr-xr-xscripts/trylink28
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)
59LDFLAGS += -static 59LDFLAGS += -static
60endif 60endif
61 61
62BBOX_LIB_LIST = m crypt 62LDLIBS = m crypt
63 63
64ifeq ($(CONFIG_PAM),y) 64ifeq ($(CONFIG_PAM),y)
65BBOX_LIB_LIST += pam pam_misc 65LDLIBS += pam pam_misc
66endif 66endif
67 67
68ifeq ($(CONFIG_SELINUX),y) 68ifeq ($(CONFIG_SELINUX),y)
69BBOX_LIB_LIST += selinux sepol 69LDLIBS += selinux sepol
70endif 70endif
71 71
72ifeq ($(CONFIG_EFENCE),y) 72ifeq ($(CONFIG_EFENCE),y)
73BBOX_LIB_LIST += efence 73LDLIBS += efence
74endif 74endif
75 75
76ifeq ($(CONFIG_DMALLOC),y) 76ifeq ($(CONFIG_DMALLOC),y)
77BBOX_LIB_LIST += dmalloc 77LDLIBS += dmalloc
78endif 78endif
79 79
80# For scripts/trylink
81export BBOX_LIB_LIST
82
83#LDFLAGS += -nostdlib 80#LDFLAGS += -nostdlib
84 81
85LDFLAGS_ELF2FLT = -Wl,-elf2flt 82LDFLAGS_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"
21LDLIBS="$6" 21LDLIBS="$6"
22 22
23# Sanitize lib list (dups, extra spaces etc) 23# Sanitize lib list (dups, extra spaces etc)
24BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` 24LDLIBS=`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
27echo "Trying libraries: $BBOX_LIB_LIST" 27echo "Trying libraries: $LDLIBS"
28# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 28# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
29l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 29l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
30test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 30test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
31try $CC $LDFLAGS \ 31try $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.
45while test "$BBOX_LIB_LIST"; do 45while 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
74done 74done
75 75
76# Make the binary with final, minimal list of libs 76# Make the binary with final, minimal list of libs
77echo "Final link with: $BBOX_LIB_LIST" 77echo "Final link with: $LDLIBS"
78l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 78l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
79test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" 79test "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)
81if ! test -f busybox_ldscript; then 81if ! test -f busybox_ldscript; then
@@ -87,11 +87,11 @@ if ! test -f busybox_ldscript; then
87 >/dev/null 87 >/dev/null
88else 88else
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}
121strip -s --remove-section=.note --remove-section=.comment $EXE
121 122
122EXE="0lib/busybox" 123EXE="0lib/busybox"
123try $CC $LDFLAGS \ 124try $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}
135strip -s --remove-section=.note --remove-section=.comment $EXE