Fix typo in comment
[glibc.git] / scripts / abilist.awk
blob6d58f6663b325803e6ff3382bc9933c466cb0260
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.
4 BEGIN {
5 if (combine_fullname)
6 combine = 1;
7 if (combine)
8 parse_names = 1;
11 # Per-file header.
12 /[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ {
13 emit(0);
15 seen_opd = 0;
17 sofullname = $1;
18 sub(/:$/, "", sofullname);
19 soname = sofullname;
20 sub(/^.*\//, "", soname);
21 sub(/\.so\.[0-9.]+$/, "", soname);
23 suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \
24 || (libname_regexp != "" && soname !~ libname_regexp));
26 next
29 suppress { next }
31 # Normalize columns.
32 /^[0-9a-fA-F]+ / { sub(/ /, " - ") }
34 # Skip undefineds.
35 $4 == "*UND*" { next }
37 # Skip locals.
38 $2 == "l" { next }
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 weak = $2;
43 type = $3;
44 size = $5;
45 sub(/^0*/, "", size);
46 size = " 0x" size;
47 version = $6;
48 symbol = $NF;
49 gsub(/[()]/, "", version);
51 if (version == "GLIBC_PRIVATE") next;
53 desc = "";
54 if (type == "D" && $4 == ".tbss") {
55 type = "T";
57 else if (type == "D" && $4 == ".opd") {
58 type = "F";
59 size = "";
60 if (seen_opd < 0)
61 type = "O";
62 seen_opd = 1;
64 else if (type == "D" && NF == 8 && $7 == "0x80") {
65 # Alpha functions avoiding plt entry in users
66 type = "F";
67 size = "";
68 seen_opd = -1;
70 else if ($4 == "*ABS*") {
71 type = "A";
72 size = "";
74 else if (type == "DO") {
75 type = "D";
77 else if (type == "DF") {
78 if (symbol ~ /^\./ && seen_opd >= 0)
79 next;
80 seen_opd = -1;
81 type = "F";
82 size = "";
84 else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) {
85 # Indirect functions.
86 type = "F";
87 size = "";
89 else {
90 desc = symbol " " version " " weak " ? " type " " $4 " " $5;
92 if (size == " 0x") {
93 desc = symbol " " version " " weak " ? " type " " $4 " " $5;
96 # Disabled -- weakness should not matter to shared library ABIs any more.
97 #if (weak == "w") type = tolower(type);
98 if (desc == "")
99 desc = " " symbol " " type size;
101 if (combine)
102 version = soname " " version (combine_fullname ? " " sofullname : "");
104 if (version in versions) {
105 versions[version] = versions[version] "\n" desc;
107 else {
108 versions[version] = desc;
110 next;
113 # Header crapola.
114 NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next }
117 print "Don't grok this line:", $0
120 function emit(end) {
121 if (!end && (combine || ! parse_names || soname == ""))
122 return;
123 tofile = parse_names && !combine;
125 nverslist = 0;
126 for (version in versions) {
127 if (nverslist == 0) {
128 verslist = version;
129 nverslist = 1;
130 continue;
132 split(verslist, s, "\n");
133 if (version < s[1]) {
134 verslist = version;
135 for (i = 1; i <= nverslist; ++i) {
136 verslist = verslist "\n" s[i];
139 else {
140 verslist = s[1];
141 for (i = 2; i <= nverslist; ++i) {
142 if (version < s[i]) break;
143 verslist = verslist "\n" s[i];
145 verslist = verslist "\n" version;
146 for (; i <= nverslist; ++i) {
147 verslist = verslist "\n" s[i];
150 ++nverslist;
153 if (tofile) {
154 out = prefix soname ".symlist";
155 if (soname in outfiles)
156 out = out "." ++outfiles[soname];
157 else
158 outfiles[soname] = 1;
159 printf "" > out;
162 split(verslist, order, "\n");
163 for (i = 1; i <= nverslist; ++i) {
164 version = order[i];
166 if (tofile) {
167 print version >> out;
168 close(out);
169 outpipe = "sort >> " out;
171 else {
172 if (combine)
173 print "";
174 print prefix version;
175 outpipe = "sort";
177 print versions[version] | outpipe;
178 close(outpipe);
180 delete versions[version];
182 for (version in versions)
183 delete versions[version];
185 if (tofile)
186 print "wrote", out, "for", sofullname;
189 END {
190 emit(1);