]> git.ipfire.org Git - thirdparty/glibc.git/blob - scripts/abilist.awk
abilist.awk: Treat .tdata like .tbss and reject unknown combinations.
[thirdparty/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 {
5 if (combine_fullname)
6 combine = 1;
7 if (combine)
8 parse_names = 1;
9 }
10
11 # Per-file header.
12 /[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ {
13 emit(0);
14
15 seen_opd = 0;
16
17 sofullname = $1;
18 sub(/:$/, "", sofullname);
19 soname = sofullname;
20 sub(/^.*\//, "", soname);
21 sub(/\.so\.[0-9.]+$/, "", soname);
22
23 suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \
24 || (libname_regexp != "" && soname !~ libname_regexp));
25
26 next
27 }
28
29 suppress { next }
30
31 # Normalize columns.
32 /^[0-9a-fA-F]+ / { sub(/ /, " - ") }
33
34 # Skip undefineds.
35 $4 == "*UND*" { next }
36
37 # Skip locals.
38 $2 == "l" { next }
39
40 # If the target uses ST_OTHER, it will be output before the symbol name.
41 $2 == "g" || $2 == "w" && (NF == 7 || NF == 8) {
42 type = $3;
43 size = $5;
44 sub(/^0*/, "", size);
45 size = " 0x" size;
46 version = $6;
47 symbol = $NF;
48 gsub(/[()]/, "", version);
49
50 # binutils versions up through at least 2.23 have some bugs that
51 # caused STV_HIDDEN symbols to appear in .dynsym, though that is useless.
52 if (NF > 7 && $7 == ".hidden") next;
53
54 if (version == "GLIBC_PRIVATE") next;
55
56 desc = "";
57 if (type == "D" && ($4 == ".tbss" || $4 == ".tdata")) {
58 type = "T";
59 }
60 else if (type == "D" && $4 == ".opd") {
61 type = "F";
62 size = "";
63 if (seen_opd < 0)
64 type = "O";
65 seen_opd = 1;
66 }
67 else if (type == "D" && NF == 8 && $7 == "0x80") {
68 # Alpha functions avoiding plt entry in users
69 type = "F";
70 size = "";
71 seen_opd = -1;
72 }
73 else if ($4 == "*ABS*") {
74 next;
75 }
76 else if (type == "DO") {
77 type = "D";
78 }
79 else if (type == "DF") {
80 if (symbol ~ /^\./ && seen_opd >= 0)
81 next;
82 seen_opd = -1;
83 type = "F";
84 size = "";
85 }
86 else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) {
87 # Indirect functions.
88 type = "F";
89 size = "";
90 }
91 else {
92 print "ERROR: Unable to handle this type of symbol."
93 exit 1
94 }
95
96 if (desc == "")
97 desc = symbol " " type size;
98
99 if (combine)
100 version = soname " " version (combine_fullname ? " " sofullname : "");
101
102 # Append to the string which collects the results.
103 descs = descs version " " desc "\n";
104 next;
105 }
106
107 # Header crapola.
108 NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
109
110 {
111 print "ERROR: Unable to interpret this line:", $0
112 exit 1
113 }
114
115 function emit(end) {
116 if (!end && (combine || ! parse_names || soname == ""))
117 return;
118 tofile = parse_names && !combine;
119
120 if (tofile) {
121 out = prefix soname ".symlist";
122 if (soname in outfiles)
123 out = out "." ++outfiles[soname];
124 else
125 outfiles[soname] = 1;
126 outpipe = "LC_ALL=C sort -u > " out;
127 } else {
128 outpipe = "LC_ALL=C sort -u";
129 }
130
131 printf "%s", descs | outpipe;
132
133 descs = "";
134
135 if (tofile)
136 print "wrote", out, "for", sofullname;
137 }
138
139 END {
140 emit(1);
141 }