aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2007-10-11 13:40:52 +0000
committerMartin Willi <martin@strongswan.org>2007-10-11 13:40:52 +0000
commit04685885f5c5e283fe7a69a67484abe6dc72fde5 (patch)
tree7e462d47568f7b89fc5d7a7fc98eba678b99d962 /scripts
parent86150b684d38bebda2b763ea077a1dc83d4fa27d (diff)
downloadstrongswan-04685885f5c5e283fe7a69a67484abe6dc72fde5.tar.bz2
strongswan-04685885f5c5e283fe7a69a67484abe6dc72fde5.tar.xz
added addr2strongline script which helps to resolve leaking symbols in libstrongswan
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/addr2strongline35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/addr2strongline b/scripts/addr2strongline
new file mode 100755
index 000000000..695ddd42a
--- /dev/null
+++ b/scripts/addr2strongline
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# Wrapper to addr2line.
+#
+# $0 gets a code line for a shared library. It checks where the
+# library is linked to the binary and subtracts that from
+# supplied list of addresses in the binary.
+#
+# This requires stack randomization to be disabled.
+
+LIBNAME=libstrongswan
+
+if [ ! -e $1 ];
+then
+ echo "Error: file $1 not found"
+ exit 1
+fi
+
+if [ `cat /proc/sys/kernel/randomize_va_space` != 0 ];
+then
+ echo "Error: stack randomization enabled: use echo 0 > /proc/sys/kernel/randomize_va_space"
+ exit 1
+fi
+
+LINK=`ldd $1 | grep $LIBNAME | awk '{print toupper($4) }' | sed -e "s/0X//g"`
+LIB=`ldd $1 | grep $LIBNAME | awk '{print $3 }'`
+
+until [ -z "$2" ]
+do
+ shift
+ LEAK=`echo "$1" | sed -e "s/0x//g" | awk '{print toupper($1)}'`
+ RES=`echo "ibase=16; obase=10; $LEAK - $LINK;" | bc | sed -e "s/ //g" | awk '{print tolower($1) }'`
+ RES="0x$RES"
+ addr2line -e $LIB $RES
+done