#!/bin/sh
if [ $# != 1 ] ; then
	echo 'usage: stackcheck objectfile'
	exit 1
fi
objdump --disassemble -r $1 | awk '
/>:/	{ gsub("[<>:]","",$2); fname=$2 }
{print $0 "," fname}
' | \
grep esp | \
grep subl | grep -v ')' | cut '-d$' -f2- | \
awk -F , '{print $1 " " $3}' | \
while read LEN FNAME ; do
	printf '%4d %s\n' $LEN $FNAME
done | \
sort -n -u -r

