]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/abilist.awk
test-container: Fix "unused code" warnings on HURD
[thirdparty/glibc.git] / scripts / abilist.awk
CommitLineData
6e3d59bc
RM
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
15a686af 4BEGIN {
7e30918b
RM
5 if (combine_fullname)
6 combine = 1;
7 if (combine)
8 parse_names = 1;
15a686af
RM
9}
10
11# Per-file header.
a9448c54 12/[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ {
f0248ca5 13 emit(0);
15a686af 14
d692f3f8
RM
15 seen_opd = 0;
16
15a686af
RM
17 sofullname = $1;
18 sub(/:$/, "", sofullname);
19 soname = sofullname;
20 sub(/^.*\//, "", soname);
a9448c54 21 sub(/\.so\.[0-9.]+$/, "", soname);
15a686af 22
f0248ca5
RM
23 suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \
24 || (libname_regexp != "" && soname !~ libname_regexp));
25
15a686af
RM
26 next
27}
28
f0248ca5
RM
29suppress { next }
30
6e3d59bc
RM
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
63f1549e
RH
40# If the target uses ST_OTHER, it will be output before the symbol name.
41$2 == "g" || $2 == "w" && (NF == 7 || NF == 8) {
6e3d59bc 42 type = $3;
56c71d45
RM
43 size = $5;
44 sub(/^0*/, "", size);
5e63c240
FW
45 if (size == "") {
46 size = " 0x0";
47 } else {
48 size = " 0x" size;
49 }
6e3d59bc 50 version = $6;
63f1549e 51 symbol = $NF;
6e3d59bc
RM
52 gsub(/[()]/, "", version);
53
c8f8fa15
RM
54 # binutils versions up through at least 2.23 have some bugs that
55 # caused STV_HIDDEN symbols to appear in .dynsym, though that is useless.
56 if (NF > 7 && $7 == ".hidden") next;
57
36406545 58 if (version == "GLIBC_PRIVATE" && !include_private) next;
6e3d59bc 59
7e30918b 60 desc = "";
ce035c6e 61 if (type == "D" && ($4 == ".tbss" || $4 == ".tdata")) {
c823a4d2 62 type = "T";
6e3d59bc 63 }
5d0bbaaf 64 else if (type == "D" && $4 == ".opd") {
d692f3f8 65 type = "F";
c823a4d2 66 size = "";
d692f3f8
RM
67 if (seen_opd < 0)
68 type = "O";
69 seen_opd = 1;
5d0bbaaf 70 }
63f1549e
RH
71 else if (type == "D" && NF == 8 && $7 == "0x80") {
72 # Alpha functions avoiding plt entry in users
73 type = "F";
74 size = "";
75 seen_opd = -1;
76 }
7e30918b 77 else if ($4 == "*ABS*") {
b289cd9d 78 next;
6e3d59bc 79 }
5e63c240
FW
80 else if (type == "D") {
81 # Accept unchanged.
82 }
6e3d59bc 83 else if (type == "DO") {
c823a4d2 84 type = "D";
6e3d59bc
RM
85 }
86 else if (type == "DF") {
d692f3f8
RM
87 if (symbol ~ /^\./ && seen_opd >= 0)
88 next;
89 seen_opd = -1;
c823a4d2
RM
90 type = "F";
91 size = "";
6e3d59bc 92 }
e3c6aa3a 93 else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) {
00bbd29b
UD
94 # Indirect functions.
95 type = "F";
96 size = "";
97 }
6e3d59bc 98 else {
5e63c240 99 print "ERROR: Unable to handle this type of symbol:", $0
ce035c6e 100 exit 1
620656a3 101 }
6e3d59bc 102
7e30918b 103 if (desc == "")
8c77b6ad 104 desc = symbol " " type size;
c823a4d2 105
f0248ca5
RM
106 if (combine)
107 version = soname " " version (combine_fullname ? " " sofullname : "");
108
8c77b6ad
FW
109 # Append to the string which collects the results.
110 descs = descs version " " desc "\n";
6e3d59bc
RM
111 next;
112}
113
114# Header crapola.
115NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
116
117{
ce035c6e
CD
118 print "ERROR: Unable to interpret this line:", $0
119 exit 1
6e3d59bc 120}
c823a4d2 121
f0248ca5 122function emit(end) {
a9448c54 123 if (!end && (combine || ! parse_names || soname == ""))
f0248ca5 124 return;
a9448c54 125 tofile = parse_names && !combine;
f0248ca5 126
374d9002
RM
127 if (tofile) {
128 out = prefix soname ".symlist";
129 if (soname in outfiles)
130 out = out "." ++outfiles[soname];
131 else
132 outfiles[soname] = 1;
8c77b6ad
FW
133 outpipe = "LC_ALL=C sort -u > " out;
134 } else {
135 outpipe = "LC_ALL=C sort -u";
374d9002
RM
136 }
137
8c77b6ad
FW
138 printf "%s", descs | outpipe;
139
140 descs = "";
15a686af
RM
141
142 if (tofile)
143 print "wrote", out, "for", sofullname;
144}
145
146END {
f0248ca5 147 emit(1);
c823a4d2 148}