Skip to content

Instantly share code, notes, and snippets.

@masami256
Created December 19, 2013 07:30
Show Gist options
  • Select an option

  • Save masami256/8035633 to your computer and use it in GitHub Desktop.

Select an option

Save masami256/8035633 to your computer and use it in GitHub Desktop.
nmとgrepでシンボル探し
#!/bin/bash
target_dir=/lib/modules/`uname -r`/
target_type="ko"
func_name=""
function usage()
{
echo "usage: $1 -d [directory] -t [objecdt type(e.g. so, ko)] -f [function name]"
exit -1
}
while getopts d:t:f: option
do
case $option in
d)
target_dir=$OPTARG
;;
t)
target_type=$OPTARG
;;
f)
func_name=$OPTARG
;;
\?)
usage $0
;;
esac
done
if [ "$func_name" = "" ]; then
usage $0
fi
echo "[-]Directory: $target_dir"
echo "[-]File type: $target_type"
echo "[-]Function : $func_name"
files=`find -L "$target_dir" -name "*.$target_type"`
for f in $files
do
nm --defined-only $f 2>&1 | grep "$func_name" > /dev/null
if [ $? -eq 0 ]; then
echo $f
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment