minix/commands/unstack/unstack.sh
Ben Gras 453be3b530 rename nm and strip to acknm and ackstrip
this is to force invocations of these utils for ack to be
explicitly named such, so in the future binutils can be installed
in /usr/pkg without the g- prefix.
2010-08-02 16:09:19 +00:00

26 lines
448 B
Bash

#!/bin/sh
if [ $# -lt 1 ]
then echo "Usage: $0 <executable> [0x... [0x... ] ]"
exit 1
fi
PATH=$PATH:/usr/gnu/bin:/usr/pkg/bin
if file $1 | grep NSYM >/dev/null 2>&1; then
NM="gnm --radix=d"
else
NM="acknm -d"
fi
executable=$1
shift
while [ $# -gt 0 ]
do dec="`printf %d $1`"
$NM -n $executable | grep ' [Tt] [^.]' | awk '
{ if($1 > '$dec') { printf "%s+0x%x\n", name, '$dec'-offset; exit }
name=$3; offset=$1
}'
shift
done