]>
Commit | Line | Data |
---|---|---|
90fe4186 RM |
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. | |
6 | ||
7 | BEGIN { result = 0 } | |
8 | ||
9 | FILENAME != lastfile { | |
10 | if (lastfile && jmprel_offset == 0) { | |
11 | print FILENAME ": *** failed to find expected output (readelf -WSdr)"; | |
12 | result = 2; | |
13 | } | |
14 | lastfile = FILENAME; | |
15 | jmprel_offset = 0; | |
16 | delete section_offset_by_address; | |
17 | } | |
18 | ||
19 | /^Section Headers:/ { in_shdrs = 1; next } | |
20 | in_shdrs && !/^ +\[/ { in_shdrs = 0 } | |
21 | ||
22 | in_shdrs && /^ +\[/ { sub(/\[ +/, "[") } | |
23 | in_shdrs { | |
24 | address = strtonum("0x" $4); | |
25 | offset = strtonum("0x" $5); | |
26 | section_offset_by_address[address] = offset; | |
27 | } | |
28 | ||
29 | in_shdrs { next } | |
30 | ||
31 | $1 == "Offset" && $2 == "Info" { in_relocs = 1; next } | |
32 | NF == 0 { in_relocs = 0 } | |
33 | ||
34 | in_relocs && relocs_offset == jmprel_offset && NF >= 5 { | |
35 | symval = strtonum("0x" $4); | |
36 | if (symval != 0) | |
37 | print whatfile, $5 | |
38 | } | |
39 | ||
40 | in_relocs { next } | |
41 | ||
42 | $1 == "Relocation" && $2 == "section" && $5 == "offset" { | |
43 | relocs_offset = strtonum($6); | |
44 | whatfile = gensub(/^.*\/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME); | |
45 | next | |
46 | } | |
47 | ||
48 | $2 == "(JMPREL)" { | |
49 | jmprel_addr = strtonum($3); | |
50 | if (jmprel_addr in section_offset_by_address) { | |
51 | jmprel_offset = section_offset_by_address[jmprel_addr]; | |
52 | } else { | |
53 | print FILENAME ": *** DT_JMPREL does not match any section's address"; | |
54 | result = 2; | |
55 | } | |
56 | next | |
57 | } | |
58 | ||
59 | END { exit(result) } |