Created
May 30, 2020 06:08
-
-
Save hiracchi/9216d2205241c7192330de0c34052f84 to your computer and use it in GitHub Desktop.
search-sym.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage='search-sym SYMBOL' | |
if [ $# -ne 1 ];then | |
echo "invalid arguments!" | |
echo $usage | |
exit 1 | |
fi | |
sym=$1 | |
egrep_pattern="^[0-9a-f]*[[:space:]]*[^U[:space:]].*$sym" | |
static_lib_pattern='*.a *.o' | |
shared_lib_pattern='*.so*' | |
function search_file() # filename nm-opt | |
{ | |
local f=$1 | |
shift | |
local nmopt=$@ | |
local res | |
if [ -f $f ];then | |
res=`nm $nmopt $f 2>&1 | grep $sym` | |
if [ -n "$res" ];then | |
res=`printf -- "$res\n" | grep -E $egrep_pattern` | |
if [ -n "$res" ];then | |
echo "$f:" | |
echo "$res" | |
fi | |
fi | |
fi | |
} | |
echo "symbol $sym is included in..." | |
for f in $static_lib_pattern;do | |
search_file $f -f bsd -C | |
done | |
for f in $shared_lib_pattern;do | |
search_file $f -f bsd -C -D | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment