Skip to content

Instantly share code, notes, and snippets.

@nemasu
Last active November 8, 2016 04:47
Show Gist options
  • Save nemasu/97b3bc67e73e7b0ac02aba9ba090f595 to your computer and use it in GitHub Desktop.
Save nemasu/97b3bc67e73e7b0ac02aba9ba090f595 to your computer and use it in GitHub Desktop.
Find a library method.
function getExportsFromLib() {
readelf -W -s $1 2> /dev/null |
egrep "FUNC[ ]+GLOBAL[ ]+DEFAULT[ ]+[0-9]+" |
sed '/@@*/d;/[0-9][0-9]* _fini/d;/[0-9][0-9]* _init/d;' |
c++filt |
awk '{print substr($0, index($0,$8));}' |
sort |
uniq;
}
function findMethod() {
method=$1
deep=$2
if [ -n "$deep" ]; then
for i in `find /usr/lib -type f ! -type l | sed -e '/.*\.so$\|.*[0-9]$/!d'`; do
found=`getExportsFromLib $i | grep $method`
if [ -n "$found" ]; then
echo "Found in $i"
fi
done
return
fi
for i in `find /usr/lib -maxdepth 1 -type f ! -type l | sed -e '/.*\.so$\|.*[0-9]$/!d'`; do
found=`getExportsFromLib $i | grep $method`
if [ -n "$found" ]; then
echo "Found in $i"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment