* scripts/abilist.awk: Grok function descriptor symbols.
[platform/upstream/glibc.git] / scripts / abilist.awk
1 # This awk script processes the output of objdump --dynamic-syms
2 # into a simple format that should not change when the ABI is not changing.
3
4 BEGIN { outpipe = "sort" }
5
6 # Normalize columns.
7 /^[0-9a-fA-F]+      / { sub(/      /, "  -   ") }
8
9 # Skip undefineds.
10 $4 == "*UND*" { next }
11
12 # Skip locals.
13 $2 == "l" { next }
14
15 $2 == "g" || $2 == "w" && NF == 7 {
16   weak = ($2 == "w") ? "weak" : "strong";
17   type = $3;
18   size = strtonum("0x" $5);
19   version = $6;
20   symbol = $7;
21   gsub(/[()]/, "", version);
22
23   if (version == "GLIBC_PRIVATE") next;
24
25   if (type == "D" && $4 == ".tbss") {
26     print symbol, version, weak, "TLS", size | outpipe;
27   }
28   else if (type == "D" && $4 == ".opd") {
29     print symbol, version, weak, "FDESC" | outpipe;
30   }
31   else if (type == "DO" && $4 == "*ABS*") {
32     print symbol, version, weak, "ABS" | outpipe;
33   }
34   else if (type == "DO") {
35     print symbol, version, weak, "DATA", size | outpipe;
36   }
37   else if (type == "DF") {
38     print symbol, version, weak, "FUNC" | outpipe;
39   }
40   else {
41     print symbol, version, weak, "UNEXPECTED", type, $4, $5;
42   }
43
44   next;
45 }
46
47 # Header crapola.
48 NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
49
50 {
51   print "Don't grok this line:", $0
52 }