1 # This awk script expects to get command-line files that are each
2 # the output of 'readelf -l' on a single shared object.
3 # But the first file should contain just "execstack-no" or "execstack-yes",
4 # indicating what the default is in the absence of PT_GNU_STACK.
5 # It exits successfully (0) if none indicated executable stack.
6 # It fails (1) if any did indicate executable stack.
7 # It fails (2) if the input did not take the expected form.
10 result = sanity =
0; default_exec =
-1;
11 split(xfail
, xfails
, " ");
13 expected_fails
[xfails
[x
] ".phdr"] =
1;
16 /^execstack
-no$
/ { default_exec =
0; next }
17 /^execstack
-yes$
/ { default_exec =
1; next }
19 function check_one
(name
) {
20 if (default_exec ==
-1) {
21 print "*** missing execstack-default file?";
25 n =
split(name
, parts
, "/");
27 expected_fail = basename in expected_fails
;
30 print name
": *** input did not look like readelf -l output";
32 } else if (stack_line
) {
33 if (stack_line ~
/^.
*RW .
*$
/) {
35 } else if (stack_line ~
/^.
*E.
*$
/) {
37 print name
": *** executable stack signaled, expected";
39 print name
": *** executable stack signaled";
40 result = result ? result
: 1;
43 } else if (default_exec
) {
45 print name
": *** no PT_GNU_STACK entry, expected";
47 print name
": *** no PT_GNU_STACK entry";
48 result = result ? result
: 1;
51 print name
": no PT_GNU_STACK but default is OK";
57 FILENAME != lastfile
{
63 $
1 ==
"Type" && $
7 ==
"Flg" { sanity =
1; stack_line =
"" }
64 $
1 ==
"GNU_STACK" { stack_line = $
0 }