summaryrefslogtreecommitdiff
path: root/test/plt/check-plt.sh
blob: bedc8fd350651a9c75fa6b62b75d18c61ec25ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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