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.
10 if (lastfile
&& jmprel_offset ==
0) {
11 print FILENAME ": *** failed to find expected output (readelf -WSdr)";
16 delete section_offset_by_address
;
19 /^Section Headers
:/ { in_shdrs =
1; next }
20 in_shdrs
&& !
/^
+\
[/ { in_shdrs =
0 }
22 in_shdrs
&& /^
+\
[/ { sub(/\
[ +/, "[") }
24 address = strtonum
("0x" $
4);
25 offset = strtonum
("0x" $
5);
26 section_offset_by_address
[address
] = offset
;
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 ().
38 print whatfile
, gensub
(/@.
*/, "", "g", $
5)
40 symval = strtonum
("0x" $
4);
42 print whatfile
, gensub
(/@.
*/, "", "g", $
5)
48 $
1 ==
"Relocation" && $
2 ==
"section" && $
5 ==
"offset" {
49 relocs_offset = strtonum
($
6);
50 whatfile = gensub
(/^.
*\
/([^
/]+)\.jmprel$
/, "\\1:", 1, FILENAME);
55 jmprel_addr = strtonum
($
3);
56 if (jmprel_addr in section_offset_by_address
) {
57 jmprel_offset = section_offset_by_address
[jmprel_addr
];
59 print FILENAME ": *** DT_JMPREL does not match any section's address";