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
8 then echo "Usage: unstack <executable> [0x... [0x... ] ]"
9 echo " datasizes <executable>"
13 # Check invocation mode
14 case "`basename $0`" in
31 # gnu nm can be gnm or nm
32 if which gnm
>/dev
/null
2>&1
37 # Invoke gnu nm or ack nm?
38 if file $executable |
grep NSYM
>/dev
/null
2>&1
39 then NM
="$GNM --radix=d"
40 elif file $executable |
grep ELF
>/dev
/null
2>&1
41 then NM
="$GNM --radix=d"
49 do dec
="`printf %d $1`"
50 $NM -n $executable |
grep ' [Tt] [^.]' |
awk '
51 { if($1 > '$dec') { printf "%s+0x%x\n", name, '$dec'-offset; exit }
60 # Invoked as datasizes?
64 grep ' [bBdD] [^.]' |
awk '{ if (lastpos) printf "%10ld kB %s\n", ($1-lastpos)/1024, lastname; lastpos=$1; lastname=$3 }' |
sort -n
70 echo "Impossible invocation."