summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-10-22 01:12:47 -0400
committerAustin Foxley <austinf@cetoncorp.com>2009-11-09 15:34:35 -0800
commite219bc7c1b3a82b1c35b61cf07217c084480f752 (patch)
treeb1c8d34883b4deca9df649762451467c8e5fb918 /test
parentc7e4f11335adcdad03e24ad2648b873f116337aa (diff)
test/plt: add a script to find PLT usage
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/plt/check-plt.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/plt/check-plt.sh b/test/plt/check-plt.sh
new file mode 100755
index 000000000..bedc8fd35
--- /dev/null
+++ b/test/plt/check-plt.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+allowed="
+calloc
+free
+malloc
+memalign
+realloc
+"
+
+${OBJDUMP:-objdump} -d ${top_builddir:-../..}/lib/libc.so.? | \
+gawk -v allowed="${allowed}" '
+BEGIN {
+ COUNT = split(" " allowed, ALLOWED);
+}
+
+# Strip away the noise. The name will be like:
+# <brk>:
+# <foo@plt>
+function symstrip(name) {
+ return gensub(/.*<([^>@]*).*/, "\\1", "", name);
+}
+
+{
+# Match the start of the symbol disassembly
+# 00009720 <brk>:
+if ($2 ~ />:$/) {
+ f = symstrip($2);
+
+} else if ($NF ~ /@plt>/) {
+ rf = symstrip($NF);
+ for (a in ALLOWED) {
+ a = ALLOWED[a];
+ if (a == rf)
+ next;
+ }
+ print "Func " f " references " rf;
+}
+}' | sort -u