[git commit nptl_merge] test/plt: add a script to find PLT usage

Mike Frysinger vapier at gentoo.org
Sun Nov 22 08:37:56 UTC 2009


commit: http://git.uclibc.org/uClibc/commit/?id=e30f2a09f1e8e5b368dc8f9210b491a3a4579329
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/nptl_merge

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 Rules.mak             |    1 +
 test/plt/check-plt.sh |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100755 test/plt/check-plt.sh

diff --git a/Rules.mak b/Rules.mak
index ceb1e10..e63f6a4 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -46,6 +46,7 @@ CC         = $(CROSS)gcc
 AR         = $(CROSS)ar
 LD         = $(CROSS)ld
 NM         = $(CROSS)nm
+OBJDUMP    = $(CROSS)objdump
 STRIPTOOL  = $(CROSS)strip
 
 INSTALL    = install
diff --git a/test/plt/check-plt.sh b/test/plt/check-plt.sh
new file mode 100755
index 0000000..bedc8fd
--- /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 at 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
-- 
1.6.3.3



More information about the uClibc-cvs mailing list