3 # Wrapper to addr2line.
5 # $0 gets a code line for a shared library. It checks where the
6 # library is linked to the binary and subtracts that from
7 # supplied list of addresses in the binary.
9 # This requires stack randomization to be disabled.
15 echo "Error: file $1 not found"
19 if [ `cat /proc/sys/kernel/randomize_va_space` != 0 ];
21 echo "Error: stack randomization enabled: use echo 0 > /proc/sys/kernel/randomize_va_space"
25 LINK=`ldd $1 | grep $LIBNAME | awk '{print toupper($4) }' | sed -e "s/0X//g"`
26 LIB=`ldd $1 | grep $LIBNAME | awk '{print $3 }'`
31 LEAK=`echo "$1" | sed -e "s/0x//g" | awk '{print toupper($1)}'`
32 RES=`echo "ibase=16; obase=10; $LEAK - $LINK;" | bc | sed -e "s/ //g" | awk '{print tolower($1) }'`
34 addr2line -e $LIB $RES