diff options
Diffstat (limited to 'scripts/trylink')
-rwxr-xr-x | scripts/trylink | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/scripts/trylink b/scripts/trylink index 164f5274c..5994a757b 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
@@ -85,6 +85,10 @@ LDLIBS="$7" | |||
85 | # The --sort-section option is not supported by older versions of ld | 85 | # The --sort-section option is not supported by older versions of ld |
86 | SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""` | 86 | SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""` |
87 | 87 | ||
88 | START_GROUP="-Wl,--start-group" | ||
89 | END_GROUP="-Wl,--end-group" | ||
90 | INFO_OPTS="-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose" | ||
91 | |||
88 | # gold may not support --sort-common (yet) | 92 | # gold may not support --sort-common (yet) |
89 | SORT_COMMON=`check_cc "-Wl,--sort-common" ""` | 93 | SORT_COMMON=`check_cc "-Wl,--sort-common" ""` |
90 | 94 | ||
@@ -114,13 +118,13 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` | |||
114 | echo "Trying libraries: $LDLIBS" | 118 | echo "Trying libraries: $LDLIBS" |
115 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 119 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
116 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 120 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
117 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 121 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" |
118 | try $CC $CFLAGS $LDFLAGS \ | 122 | try $CC $CFLAGS $LDFLAGS \ |
119 | -o $EXE \ | 123 | -o $EXE \ |
120 | $SORT_COMMON \ | 124 | $SORT_COMMON \ |
121 | $SORT_SECTION \ | 125 | $SORT_SECTION \ |
122 | $GC_SECTIONS \ | 126 | $GC_SECTIONS \ |
123 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 127 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
124 | $l_list \ | 128 | $l_list \ |
125 | || { | 129 | || { |
126 | echo "Failed: $l_list" | 130 | echo "Failed: $l_list" |
@@ -138,14 +142,14 @@ while test "$LDLIBS"; do | |||
138 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` | 142 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` |
139 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 143 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
140 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 144 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
141 | test x"$l_list" != x"" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 145 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" |
142 | $debug && echo "Trying -l options: '$l_list'" | 146 | $debug && echo "Trying -l options: '$l_list'" |
143 | try $CC $CFLAGS $LDFLAGS \ | 147 | try $CC $CFLAGS $LDFLAGS \ |
144 | -o $EXE \ | 148 | -o $EXE \ |
145 | $SORT_COMMON \ | 149 | $SORT_COMMON \ |
146 | $SORT_SECTION \ | 150 | $SORT_SECTION \ |
147 | $GC_SECTIONS \ | 151 | $GC_SECTIONS \ |
148 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 152 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
149 | $l_list | 153 | $l_list |
150 | if test $? = 0; then | 154 | if test $? = 0; then |
151 | echo " Library $one is not needed, excluding it" | 155 | echo " Library $one is not needed, excluding it" |
@@ -169,7 +173,7 @@ done | |||
169 | # Make the binary with final, minimal list of libs | 173 | # Make the binary with final, minimal list of libs |
170 | echo "Final link with: ${LDLIBS:-<none>}" | 174 | echo "Final link with: ${LDLIBS:-<none>}" |
171 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 175 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
172 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 176 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" |
173 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 177 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
174 | if ! test -f busybox_ldscript; then | 178 | if ! test -f busybox_ldscript; then |
175 | try $CC $CFLAGS $LDFLAGS \ | 179 | try $CC $CFLAGS $LDFLAGS \ |
@@ -177,11 +181,9 @@ if ! test -f busybox_ldscript; then | |||
177 | $SORT_COMMON \ | 181 | $SORT_COMMON \ |
178 | $SORT_SECTION \ | 182 | $SORT_SECTION \ |
179 | $GC_SECTIONS \ | 183 | $GC_SECTIONS \ |
180 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 184 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
181 | $l_list \ | 185 | $l_list \ |
182 | -Wl,--warn-common \ | 186 | $INFO_OPTS \ |
183 | -Wl,-Map,$EXE.map \ | ||
184 | -Wl,--verbose \ | ||
185 | || { | 187 | || { |
186 | cat $EXE.out | 188 | cat $EXE.out |
187 | exit 1 | 189 | exit 1 |
@@ -200,11 +202,9 @@ else | |||
200 | $SORT_SECTION \ | 202 | $SORT_SECTION \ |
201 | $GC_SECTIONS \ | 203 | $GC_SECTIONS \ |
202 | -Wl,-T,busybox_ldscript \ | 204 | -Wl,-T,busybox_ldscript \ |
203 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 205 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
204 | $l_list \ | 206 | $l_list \ |
205 | -Wl,--warn-common \ | 207 | $INFO_OPTS \ |
206 | -Wl,-Map,$EXE.map \ | ||
207 | -Wl,--verbose \ | ||
208 | || { | 208 | || { |
209 | cat $EXE.out | 209 | cat $EXE.out |
210 | exit 1 | 210 | exit 1 |
@@ -233,11 +233,9 @@ if test "$CONFIG_BUILD_LIBBUSYBOX" = y; then | |||
233 | -Wl,--undefined=lbb_main \ | 233 | -Wl,--undefined=lbb_main \ |
234 | $SORT_COMMON \ | 234 | $SORT_COMMON \ |
235 | $SORT_SECTION \ | 235 | $SORT_SECTION \ |
236 | -Wl,--start-group $A_FILES -Wl,--end-group \ | 236 | $START_GROUP $A_FILES $END_GROUP \ |
237 | $l_list \ | 237 | $l_list \ |
238 | -Wl,--warn-common \ | 238 | $INFO_OPTS \ |
239 | -Wl,-Map,$EXE.map \ | ||
240 | -Wl,--verbose \ | ||
241 | || { | 239 | || { |
242 | echo "Linking $EXE failed" | 240 | echo "Linking $EXE failed" |
243 | cat $EXE.out | 241 | cat $EXE.out |
@@ -255,11 +253,9 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then | |||
255 | $SORT_COMMON \ | 253 | $SORT_COMMON \ |
256 | $SORT_SECTION \ | 254 | $SORT_SECTION \ |
257 | $GC_SECTIONS \ | 255 | $GC_SECTIONS \ |
258 | -Wl,--start-group $O_FILES -Wl,--end-group \ | 256 | $START_GROUP $O_FILES $END_GROUP \ |
259 | -L"$sharedlib_dir" -lbusybox \ | 257 | -L"$sharedlib_dir" -lbusybox \ |
260 | -Wl,--warn-common \ | 258 | $INFO_OPTS \ |
261 | -Wl,-Map,$EXE.map \ | ||
262 | -Wl,--verbose \ | ||
263 | || { | 259 | || { |
264 | echo "Linking $EXE failed" | 260 | echo "Linking $EXE failed" |
265 | cat $EXE.out | 261 | cat $EXE.out |