1 # This is an awk script to process the output of elf/check-localplt.
2 # The first file argument is the file of expected results.
3 # Each line is either a comment starting with # or it looks like:
6 # libfoo.so: function + {RELA|REL} RELOC
8 # libfoo.so: function ?
9 # The first entry means that one is required.
10 # The second entry means that one is required and relocation may also be
12 # The third entry means that a PLT entry for function is optional in
14 # The second file argument is - and this (stdin) receives the output
15 # of the check-localplt program.
19 FILENAME != "-" && /^
#/ { next }
22 if (NF ==
5 && $
3 ==
"+" && ($
4 ==
"RELA" || $
4 ==
"REL")) {
23 accept_type
[$
1 " " $
2] = $
4;
24 accept_reloc
[$
1 " " $
2] = $
5;
25 } else if (NF != 2 && !
(NF ==
3 && $
3 ==
"?")) {
26 printf "%s:%d: bad data line: %s\n", FILENAME, FNR, $
0 > "/dev/stderr";
29 accept
[$
1 " " $
2] =
NF ==
2;
34 NF != 2 && !
(NF ==
4 && ($
3 ==
"RELA" || $
3 ==
"REL")) {
35 print "Unexpected output from check-localplt:", $
0 > "/dev/stderr";
42 if ($
3 ==
"RELA" || $
3 ==
"REL") {
44 # libc.so: free + RELA R_X86_64_GLOB_DAT
46 if (key in accept_type
&& accept_type
[key
] == $
3 && accept_reloc
[key
] == $
4) {
48 # libc.so: free + RELA R_X86_64_GLOB_DAT
49 delete accept_type
[key
]
51 } else if (NF ==
2 && key in accept_reloc
) {
55 # libc.so: free + RELA R_X86_64_GLOB_DAT
56 if (key in accept_type
)
57 delete accept_type
[key
]
58 } else if (key in accept
) {
61 print "Extra PLT reference:", $
0;
71 print "Missing required PLT reference:", key
;
76 for (key in accept_type
) {
78 print "Missing required PLT or " accept_reloc
[key
] " reference:", key
;