diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2015-04-09 22:16:35 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2015-04-09 22:16:35 +0000 |
commit | 96f50dff77712c7c6569f3faf89eddf52096a7ba (patch) | |
tree | 7d28e557bd42b7628c05609248506d8b5ea80f36 /tools | |
parent | 1f2f31e87dcc5bcc096965d4837cbacf151addb4 (diff) | |
download | FreeBSD-src-96f50dff77712c7c6569f3faf89eddf52096a7ba.zip FreeBSD-src-96f50dff77712c7c6569f3faf89eddf52096a7ba.tar.gz |
- Fix support with new elftoolchain readelf(1)
- Fix not finding global symbols by checking for D and R.
- Follow symlinks
- Show which matching symbol was used to consider the library needed.
Discussed with: bapt
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/build/check-links.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/build/check-links.sh b/tools/build/check-links.sh index 28e52b5..2a09b1e 100755 --- a/tools/build/check-links.sh +++ b/tools/build/check-links.sh @@ -1,7 +1,7 @@ #!/bin/sh # $FreeBSD$ -mime=$(file --mime-type $1) +mime=$(file -L --mime-type $1) case $mime in *application/x-executable);; *application/x-sharedlib);; @@ -10,16 +10,17 @@ esac # Check for useful libs list_libs="" -for lib in $(readelf -d $1 | awk '$2 == "(NEEDED)" { sub(/\[/,"",$NF); sub(/\]/,"",$NF); print $NF }'); do +for lib in $(readelf -d $1 | awk '$2 ~ /\(?NEEDED\)?/ { sub(/\[/,"",$NF); sub(/\]/,"",$NF); print $NF }'); do echo -n "checking if $lib is needed: " libpath=$(ldd $1 | awk -v lib=$lib '$1 == lib { print $3 }') list_libs="$list_libs $libpath" foundone=0 - for fct in $(nm -D $libpath | awk '$2 == "T" || $2 == "W" || $2 == "B" { print $3 }'); do + for fct in $(nm -D $libpath | awk '$2 == "R" || $2 == "D" || $2 == "T" || $2 == "W" || $2 == "B" { print $3 }'); do nm -D $1 | awk -v s=$fct '$1 == "U" && $2 == s { found=1 ; exit } END { if (found != 1) { exit 1 } }' && foundone=1 && break done if [ $foundone -eq 1 ]; then - echo "yes" + echo -n "yes... " + nm -D $1 | awk -v s=$fct '$1 == "U" && $2 == s { print $2 ; exit }' else echo "no" fi @@ -28,10 +29,9 @@ done for sym in $(nm -D $1 | awk '$1 == "U" { print $2 }'); do found=0 for l in ${list_libs} ; do - nm -D $l | awk -v s=$sym '($2 == "T" || $2 == "W" || $2 == "B") && $3 == s { found=1 ; exit } END { if (found != 1) { exit 1 } }' && found=1 && break + nm -D $l | awk -v s=$sym '($2 == "R" || $2 == "D" || $2 == "T" || $2 == "W" || $2 == "B") && $3 == s { found=1 ; exit } END { if (found != 1) { exit 1 } }' && found=1 && break done if [ $found -eq 0 ]; then echo "Unresolved symbol $sym" fi done - |