3 # Look at /usr/pkg/bin first in case there is an old nm in /usr/bin
4 PATH
=/usr
/pkg
/bin
:$PATH:/usr
/gnu
/bin
6 # Does procfs give us some extra 'symbols'?
9 then EXTRANM
="cat $IPCVECS"
14 then echo "Usage: unstack <executable> [0x... [0x... ] ]"
18 # Check invocation mode
19 case "`basename $0`" in
21 echo "datasizes is obsolete; please use nm --size-sort instead."
37 if ! which gawk
>/dev
/null
2>&1
38 then echo "Please install gawk."
42 # Invoke binutils nm or ack nm?
43 if file $executable |
grep ELF
>/dev
/null
2>&1
48 SYMLIST
=/tmp
/unstack.$$
50 # store sorted, filtered nm output once
51 ( $NM $executable ; $EXTRANM ) |
sed 's/^/0x/' |
sort -x |
grep ' [Tt] [^.]' >$SYMLIST
54 do gawk
<$SYMLIST --non-decimal-data -v symoffset
=$1 '
55 { if($1 > symoffset) { printf "%s+0x%x\n", name, symoffset-prevoffset; exit }
56 name=$3; prevoffset=$1;