merge datasizes and unstack
This commit is contained in:
parent
8da0925650
commit
56770462c2
@ -7,7 +7,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \
|
|||||||
binpackages binsizes bzip2 bzip2recover cal calendar \
|
binpackages binsizes bzip2 bzip2recover cal calendar \
|
||||||
cat cawf cd cdprobe checkhier chmem \
|
cat cawf cd cdprobe checkhier chmem \
|
||||||
chmod chown chroot ci cksum cleantmp clear cmp co \
|
chmod chown chroot ci cksum cleantmp clear cmp co \
|
||||||
comm compress cp crc cron crontab cut datasizes date \
|
comm compress cp crc cron crontab cut date \
|
||||||
dd de decomp16 DESCRIBE dev2name devsize df dhcpd \
|
dd de decomp16 DESCRIBE dev2name devsize df dhcpd \
|
||||||
dhrystone diff dirname dis88 du dumpcore easypack \
|
dhrystone diff dirname dis88 du dumpcore easypack \
|
||||||
ed eject elle elvis env expand factor file \
|
ed eject elle elvis env expand factor file \
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
SCRIPTS= datasizes.sh
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
@ -1,14 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ $# -ne 1 ]
|
|
||||||
then echo "Usage: $0 <executable>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if file $1 | grep NSYM >/dev/null 2>&1; then
|
|
||||||
NM="gnm --radix=d"
|
|
||||||
else
|
|
||||||
NM="acknm -d"
|
|
||||||
fi
|
|
||||||
|
|
||||||
$NM -n $1 | grep ' [bBdD] [^.]' | awk '{ if (lastpos) printf "%10ld kB %s\n", ($1-lastpos)/1024, lastname; lastpos=$1; lastname=$3 }' | sort -n
|
|
@ -1,4 +1,6 @@
|
|||||||
SCRIPTS= unstack.sh
|
SCRIPTS= unstack.sh
|
||||||
MAN=
|
MAN=
|
||||||
|
|
||||||
|
LINKS+=$(BINDIR)/unstack $(BINDIR)/datasizes
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -1,26 +1,71 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Look at /usr/pkg/bin first in case there is an old nm in /usr/bin
|
||||||
|
PATH=/usr/pkg/bin:$PATH:/usr/gnu/bin
|
||||||
|
|
||||||
|
# Check usage
|
||||||
if [ $# -lt 1 ]
|
if [ $# -lt 1 ]
|
||||||
then echo "Usage: $0 <executable> [0x... [0x... ] ]"
|
then echo "Usage: unstack <executable> [0x... [0x... ] ]"
|
||||||
|
echo " datasizes <executable>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$PATH:/usr/gnu/bin:/usr/pkg/bin
|
# Check invocation mode
|
||||||
|
case "`basename $0`" in
|
||||||
if file $1 | grep NSYM >/dev/null 2>&1; then
|
datasizes)
|
||||||
NM="gnm --radix=d"
|
mode=data
|
||||||
else
|
;;
|
||||||
NM="acknm -d"
|
unstack)
|
||||||
fi
|
mode=stack
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invoked as $0?"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Get executable name
|
||||||
executable=$1
|
executable=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
while [ $# -gt 0 ]
|
# gnu nm can be gnm or nm
|
||||||
do dec="`printf %d $1`"
|
if which gnm >/dev/null 2>&1
|
||||||
|
then GNM=gnm
|
||||||
|
else GNM=nm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Invoke gnu nm or ack nm?
|
||||||
|
if file $executable | grep NSYM >/dev/null 2>&1
|
||||||
|
then NM="$GNM --radix=d"
|
||||||
|
else NM="acknm -d"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Invoked as unstack?
|
||||||
|
if [ $mode = stack ]
|
||||||
|
then
|
||||||
|
while [ $# -gt 0 ]
|
||||||
|
do dec="`printf %d $1`"
|
||||||
$NM -n $executable | grep ' [Tt] [^.]' | awk '
|
$NM -n $executable | grep ' [Tt] [^.]' | awk '
|
||||||
{ if($1 > '$dec') { printf "%s+0x%x\n", name, '$dec'-offset; exit }
|
{ if($1 > '$dec') { printf "%s+0x%x\n", name, '$dec'-offset; exit }
|
||||||
name=$3; offset=$1
|
name=$3; offset=$1
|
||||||
}'
|
}'
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Invoked as datasizes?
|
||||||
|
if [ $mode = data ]
|
||||||
|
then
|
||||||
|
$NM -n $executable |
|
||||||
|
grep ' [bBdD] [^.]' | awk '{ if (lastpos) printf "%10ld kB %s\n", ($1-lastpos)/1024, lastname; lastpos=$1; lastname=$3 }' | sort -n
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Can't happen.
|
||||||
|
echo "Impossible invocation."
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user