diff options
Diffstat (limited to 'extra')
-rwxr-xr-x | extra/scripts/get-needed-libgcc-objects.sh | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/extra/scripts/get-needed-libgcc-objects.sh b/extra/scripts/get-needed-libgcc-objects.sh index e4fa96a78..4bbbb328b 100755 --- a/extra/scripts/get-needed-libgcc-objects.sh +++ b/extra/scripts/get-needed-libgcc-objects.sh @@ -17,9 +17,9 @@ LIBGCC=`$CC -print-libgcc-file-name` echo Finding missing symbols in libc.a ... echo " partial linking..." rm -f libc.ldr -ld -r -o libc.ldr ../crt0.o *.o +ld -r -o libc.ldr ../crt0.o --whole-archive ../libc.a -if nm -s libc.ldr | grep -v " main$" | grep " U " > sym.need ; then +if nm --undefined-only libc.ldr | grep -v "^main$" > sym.need ; then rm -f obj.need touch obj.need for SYM in `cat sym.need | sed -e 's/ U //g'` ; do @@ -37,7 +37,7 @@ fi rm -rf tmp-gcc mkdir tmp-gcc (cd tmp-gcc ; ar -x $LIBGCC) -rm libgcc.ldr +rm -f libgcc.ldr echo Extracting referenced libgcc.a objects ... @@ -46,7 +46,7 @@ touch obj.need.0 while [ -s obj.need ] && ! cmp -s obj.need obj.need.0 ; do (cd tmp-gcc ; cat ../obj.need | xargs ld -r -o ../libgcc.ldr) cp obj.need obj.need.0 - if nm -s libgcc.ldr | grep " U " > sym.need ; then + if nm --undefined-only libgcc.ldr > sym.need ; then for SYM in `cat sym.need | sed -e 's/ U //g'` ; do if nm -s $LIBGCC | grep -q $SYM" in " ; then nm -s $LIBGCC | grep $SYM" in " | cut -d' ' -f3 >> obj.need @@ -58,8 +58,13 @@ done cat obj.need | sort | uniq > obj.need.0 (cd tmp-gcc ; cp `cat ../obj.need` ..) -echo Objects added from $LIBGCC: -cat obj.need.0 +if [ -s obj.need.0 ] ; then + echo Objects added from $LIBGCC: + cat obj.need.0 + (cd tmp-gcc ; cat ../obj.need | xargs ar r ../libgcc-need.a) +else + echo No objects added from $LIBGCC. +fi if [ -s sym.need ] ; then echo Symbols missing from libgcc.a: |