blob: bedc8fd350651a9c75fa6b62b75d18c61ec25ba8 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/bin/sh
2allowed="
3calloc
4free
5malloc
6memalign
7realloc
8"
9
10${OBJDUMP:-objdump} -d ${top_builddir:-../..}/lib/libc.so.? | \
11gawk -v allowed="${allowed}" '
12BEGIN {
13 COUNT = split(" " allowed, ALLOWED);
14}
15
16# Strip away the noise. The name will be like:
17# <brk>:
18# <foo@plt>
19function symstrip(name) {
20 return gensub(/.*<([^>@]*).*/, "\\1", "", name);
21}
22
23{
24# Match the start of the symbol disassembly
25# 00009720 <brk>:
26if ($2 ~ />:$/) {
27 f = symstrip($2);
28
29} else if ($NF ~ /@plt>/) {
30 rf = symstrip($NF);
31 for (a in ALLOWED) {
32 a = ALLOWED[a];
33 if (a == rf)
34 next;
35 }
36 print "Func " f " references " rf;
37}
38}' | sort -u