sparc: refactor sparc64 __mpn_addmul_1 selector to C
[glibc.git] / scripts / localplt.awk
blobbeaa342922e7fd466224e5c08a9b88430cd7f59d
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 && rela_offset == 0 && rel_offset == 0) {
11 print FILENAME ": *** failed to find expected output (readelf -WSdr)";
12 result = 2;
14 lastfile = FILENAME;
15 jmprel_offset = 0;
16 rela_offset = 0;
17 rel_offset = 0;
18 delete section_offset_by_address;
21 /^Section Headers:/ { in_shdrs = 1; next }
22 in_shdrs && !/^ +\[/ { in_shdrs = 0 }
24 in_shdrs && /^ +\[/ { sub(/\[ +/, "[") }
25 in_shdrs {
26 address = strtonum("0x" $4);
27 offset = strtonum("0x" $5);
28 section_offset_by_address[address] = offset;
31 in_shdrs { next }
33 $1 == "Offset" && $2 == "Info" { in_relocs = 1; next }
34 NF == 0 { in_relocs = 0 }
36 in_relocs && relocs_offset == jmprel_offset && NF >= 5 {
37 # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
38 # value, but rather as the resolver symbol followed by ().
39 if ($4 ~ /\(\)/) {
40 print whatfile, gensub(/@.*/, "", "g", $5)
41 } else {
42 symval = strtonum("0x" $4);
43 if (symval != 0)
44 print whatfile, gensub(/@.*/, "", "g", $5)
48 in_relocs && relocs_offset == rela_offset && NF >= 5 {
49 # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
50 # value, but rather as the resolver symbol followed by ().
51 if ($4 ~ /\(\)/) {
52 print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
53 } else {
54 symval = strtonum("0x" $4);
55 if (symval != 0)
56 print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
60 in_relocs && relocs_offset == rel_offset && NF >= 5 {
61 # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
62 # value, but rather as the resolver symbol followed by ().
63 if ($4 ~ /\(\)/) {
64 print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
65 } else {
66 symval = strtonum("0x" $4);
67 if (symval != 0)
68 print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
72 in_relocs { next }
74 $1 == "Relocation" && $2 == "section" && $5 == "offset" {
75 relocs_offset = strtonum($6);
76 whatfile = gensub(/^.*\/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME);
77 next
80 $2 == "(JMPREL)" {
81 jmprel_addr = strtonum($3);
82 if (jmprel_addr in section_offset_by_address) {
83 jmprel_offset = section_offset_by_address[jmprel_addr];
84 } else {
85 print FILENAME ": *** DT_JMPREL does not match any section's address";
86 result = 2;
88 next
91 $2 == "(RELA)" {
92 rela_addr = strtonum($3);
93 if (rela_addr in section_offset_by_address) {
94 rela_offset = section_offset_by_address[rela_addr];
95 } else {
96 print FILENAME ": *** DT_RELA does not match any section's address";
97 result = 2;
99 next
102 $2 == "(REL)" {
103 rel_addr = strtonum($3);
104 if (rel_addr in section_offset_by_address) {
105 rel_offset = section_offset_by_address[rel_addr];
106 } else {
107 print FILENAME ": *** DT_REL does not match any section's address";
108 result = 2;
110 next
112 END { exit(result) }