Fix -Wundef warning in SHLIB_COMPAT
[glibc.git] / scripts / localplt.awk
blobf55c41a03739a96c4f0d372fb3baadcffe9df012
1 # This awk script expects to get command-line files that are each
2 # the output of 'readelf -WSdr' on a single shared object, and named
3 # .../NAME.jmprel where NAME is the unadorned file name of the shared object.
4 # It writes "NAME: SYMBOL" for each PLT entry in NAME that refers to a
5 # symbol defined in the same object.
7 BEGIN { result = 0 }
9 FILENAME != lastfile {
10 if (lastfile && jmprel_offset == 0) {
11 print FILENAME ": *** failed to find expected output (readelf -WSdr)";
12 result = 2;
14 lastfile = FILENAME;
15 jmprel_offset = 0;
16 delete section_offset_by_address;
19 /^Section Headers:/ { in_shdrs = 1; next }
20 in_shdrs && !/^ +\[/ { in_shdrs = 0 }
22 in_shdrs && /^ +\[/ { sub(/\[ +/, "[") }
23 in_shdrs {
24 address = strtonum("0x" $4);
25 offset = strtonum("0x" $5);
26 section_offset_by_address[address] = offset;
29 in_shdrs { next }
31 $1 == "Offset" && $2 == "Info" { in_relocs = 1; next }
32 NF == 0 { in_relocs = 0 }
34 in_relocs && relocs_offset == jmprel_offset && NF >= 5 {
35 # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
36 # value, but rather as the resolver symbol followed by ().
37 if ($4 ~ /\(\)/) {
38 print whatfile, $5
39 } else {
40 symval = strtonum("0x" $4);
41 if (symval != 0)
42 print whatfile, $5
46 in_relocs { next }
48 $1 == "Relocation" && $2 == "section" && $5 == "offset" {
49 relocs_offset = strtonum($6);
50 whatfile = gensub(/^.*\/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME);
51 next
54 $2 == "(JMPREL)" {
55 jmprel_addr = strtonum($3);
56 if (jmprel_addr in section_offset_by_address) {
57 jmprel_offset = section_offset_by_address[jmprel_addr];
58 } else {
59 print FILENAME ": *** DT_JMPREL does not match any section's address";
60 result = 2;
62 next
65 END { exit(result) }