3 # $0 <module> <offset> <sym> <hit>
5 # ie. $0 iffparse.library 0x080e34b0: SeekStream 0x80e5257
8 if [ "$#" -eq 0 ]; then
9 echo "$0 module offset sym hit"
10 echo "Example: $0 iffparse.library 0x080e34b0: SeekStream 0x80e5257"
20 if [ ! -f "$module" ]; then
21 echo "$0: $module: no such file"
25 entry
=`nm "$module" | egrep " $sym\$"`
27 if [ -z "$entry" ]; then
28 echo "$0: Can't find symbol $sym in $module"
34 offset
=`echo "0x$entry" | cut "-d " -f1`
35 offset
=`$path/strtoint $offset`
37 symoffset
=`echo $symoffset | gawk ' { if (!match($1,/^0x/)) print "0x"$1; else print $1; }'`
38 hitaddr
=`echo $hitaddr | gawk ' { if (!match($1,/^0x/)) print "0x"$1; else print $1; }'`
40 symoffset
=`$path/strtoint $symoffset`
41 hitaddr
=`$path/strtoint $hitaddr`
43 baseaddr
=`expr $symoffset - $offset`
45 hitoffset
=`expr $hitaddr - $baseaddr`
47 echo "baseaddr=`printf "%x
" $baseaddr`"
48 echo "hitoffset=`printf "%x
" $hitoffset`"
50 if [ $hitoffset -lt 0 ]; then
51 echo "Hit is not in $module"
55 objdump
--source --line-numbers "$module" | \
58 hitoffset='$hitoffset'; \
67 /^[-a-zA-Z0-9_./]+:[0-9]+$/ { \
73 /^[ \t]*[0-9a-f]+:?/ { \
74 asmline[0]=asmline[1]; \
75 asmline[1]=asmline[2]; \
76 asmline[2]=asmline[3]; \
80 if (lastoff <= hitoffset && off > hitoffset) \
83 printf ("Hit is at line %d in file %s\n", line, file); \
85 printf ("Hit is 0x%x bytes in %s\n", hitoffset-lastoff, symbol); \
97 while (getline > 0); \
114 print "Hit is not in '$module'"; \
119 function hex2int(str ,x,n) { \
124 d=index("0123456789abcdef",tolower(substr(x,1,1)))-1; \
129 #print "str="str" n="n; \