]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/abilist.awk
Ignore absolute symbols in ABI tests.
[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) {
c823a4d2 42 weak = $2;
6e3d59bc 43 type = $3;
56c71d45
RM
44 size = $5;
45 sub(/^0*/, "", size);
c823a4d2 46 size = " 0x" size;
6e3d59bc 47 version = $6;
63f1549e 48 symbol = $NF;
6e3d59bc
RM
49 gsub(/[()]/, "", version);
50
c8f8fa15
RM
51 # binutils versions up through at least 2.23 have some bugs that
52 # caused STV_HIDDEN symbols to appear in .dynsym, though that is useless.
53 if (NF > 7 && $7 == ".hidden") next;
54
6e3d59bc
RM
55 if (version == "GLIBC_PRIVATE") next;
56
7e30918b 57 desc = "";
6e3d59bc 58 if (type == "D" && $4 == ".tbss") {
c823a4d2 59 type = "T";
6e3d59bc 60 }
5d0bbaaf 61 else if (type == "D" && $4 == ".opd") {
d692f3f8 62 type = "F";
c823a4d2 63 size = "";
d692f3f8
RM
64 if (seen_opd < 0)
65 type = "O";
66 seen_opd = 1;
5d0bbaaf 67 }
63f1549e
RH
68 else if (type == "D" && NF == 8 && $7 == "0x80") {
69 # Alpha functions avoiding plt entry in users
70 type = "F";
71 size = "";
72 seen_opd = -1;
73 }
7e30918b 74 else if ($4 == "*ABS*") {
b289cd9d 75 next;
6e3d59bc
RM
76 }
77 else if (type == "DO") {
c823a4d2 78 type = "D";
6e3d59bc
RM
79 }
80 else if (type == "DF") {
d692f3f8
RM
81 if (symbol ~ /^\./ && seen_opd >= 0)
82 next;
83 seen_opd = -1;
c823a4d2
RM
84 type = "F";
85 size = "";
6e3d59bc 86 }
e3c6aa3a 87 else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) {
00bbd29b
UD
88 # Indirect functions.
89 type = "F";
90 size = "";
91 }
6e3d59bc 92 else {
7e30918b 93 desc = symbol " " version " " weak " ? " type " " $4 " " $5;
6e3d59bc 94 }
620656a3 95 if (size == " 0x") {
7e30918b 96 desc = symbol " " version " " weak " ? " type " " $4 " " $5;
620656a3 97 }
6e3d59bc 98
44aeb486
RM
99 # Disabled -- weakness should not matter to shared library ABIs any more.
100 #if (weak == "w") type = tolower(type);
7e30918b 101 if (desc == "")
8c77b6ad 102 desc = symbol " " type size;
c823a4d2 103
f0248ca5
RM
104 if (combine)
105 version = soname " " version (combine_fullname ? " " sofullname : "");
106
8c77b6ad
FW
107 # Append to the string which collects the results.
108 descs = descs version " " desc "\n";
6e3d59bc
RM
109 next;
110}
111
112# Header crapola.
113NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
114
115{
7e30918b 116 print "Don't grok this line:", $0
6e3d59bc 117}
c823a4d2 118
f0248ca5 119function emit(end) {
a9448c54 120 if (!end && (combine || ! parse_names || soname == ""))
f0248ca5 121 return;
a9448c54 122 tofile = parse_names && !combine;
f0248ca5 123
374d9002
RM
124 if (tofile) {
125 out = prefix soname ".symlist";
126 if (soname in outfiles)
127 out = out "." ++outfiles[soname];
128 else
129 outfiles[soname] = 1;
8c77b6ad
FW
130 outpipe = "LC_ALL=C sort -u > " out;
131 } else {
132 outpipe = "LC_ALL=C sort -u";
374d9002
RM
133 }
134
8c77b6ad
FW
135 printf "%s", descs | outpipe;
136
137 descs = "";
15a686af
RM
138
139 if (tofile)
140 print "wrote", out, "for", sofullname;
141}
142
143END {
f0248ca5 144 emit(1);
c823a4d2 145}