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 symval = strtonum
("0x" $
4);
42 $
1 ==
"Relocation" && $
2 ==
"section" && $
5 ==
"offset" {
43 relocs_offset = strtonum
($
6);
44 whatfile = gensub
(/^.
*\
/([^
/]+)\.jmprel$
/, "\\1:", 1, FILENAME);
49 jmprel_addr = strtonum
($
3);
50 if (jmprel_addr in section_offset_by_address
) {
51 jmprel_offset = section_offset_by_address
[jmprel_addr
];
53 print FILENAME ": *** DT_JMPREL does not match any section's address";