* scripts/abilist.awk: Avoid strtonum function, not there in mawk.
[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 = $5;
19   sub(/^0*/, "", size);
20   size = "0x" size;
21   version = $6;
22   symbol = $7;
23   gsub(/[()]/, "", version);
24
25   if (version == "GLIBC_PRIVATE") next;
26
27   if (type == "D" && $4 == ".tbss") {
28     print symbol, version, weak, "TLS", size | outpipe;
29   }
30   else if (type == "D" && $4 == ".opd") {
31     print symbol, version, weak, "FDESC" | outpipe;
32   }
33   else if (type == "DO" && $4 == "*ABS*") {
34     print symbol, version, weak, "ABS" | outpipe;
35   }
36   else if (type == "DO") {
37     print symbol, version, weak, "DATA", size | outpipe;
38   }
39   else if (type == "DF") {
40     print symbol, version, weak, "FUNC" | outpipe;
41   }
42   else {
43     print symbol, version, weak, "UNEXPECTED", type, $4, $5;
44   }
45
46   next;
47 }
48
49 # Header crapola.
50 NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
51
52 {
53   print "Don't grok this line:", $0
54 }