getaddrinfo: Eliminate another strdup call
[glibc.git] / scripts / check-localplt.awk
blob39652928883063c133181fec1fea2215b819d97b
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:
4 # libfoo.so: function
5 # or
6 # libfoo.so: function + {RELA|REL} RELOC
7 # or
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
11 # {RELA|REL} RELOC.
12 # The third entry means that a PLT entry for function is optional in
13 # libfoo.so.
14 # The second file argument is - and this (stdin) receives the output
15 # of the check-localplt program.
17 BEGIN { result = 0 }
19 FILENAME != "-" && /^#/ { next }
21 FILENAME != "-" {
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";
27 result = 2;
28 } else {
29 accept[$1 " " $2] = NF == 2;
31 next;
34 NF != 2 && !(NF == 4 && ($3 == "RELA" || $3 == "REL")) {
35 print "Unexpected output from check-localplt:", $0 > "/dev/stderr";
36 result = 2;
37 next
41 key = $1 " " $2
42 if ($3 == "RELA" || $3 == "REL") {
43 # Entries like:
44 # libc.so: free + RELA R_X86_64_GLOB_DAT
45 # may be ignored.
46 if (key in accept_type && accept_type[key] == $3 && accept_reloc[key] == $4) {
47 # Match
48 # libc.so: free + RELA R_X86_64_GLOB_DAT
49 delete accept_type[key]
51 } else if (NF == 2 && key in accept_reloc) {
52 # Match
53 # libc.so: free
54 # against
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) {
59 delete accept[key]
60 } else {
61 print "Extra PLT reference:", $0;
62 if (result == 0)
63 result = 1;
67 END {
68 for (key in accept) {
69 if (accept[key]) {
70 # It's mandatory.
71 print "Missing required PLT reference:", key;
72 result = 1;
76 for (key in accept_type) {
77 # It's mandatory.
78 print "Missing required PLT or " accept_reloc[key] " reference:", key;
79 result = 1;
82 exit(result);