| 1 | #! /bin/sh -e |
| 2 | |
| 3 | echo "1..1" |
| 4 | env | sort | sed 's/^/# /' |
| 5 | |
| 6 | check_exe () { |
| 7 | tid=$1 exe=$2 |
| 8 | if ! [ -f $exe ]; then |
| 9 | echo "ok $tid # skip executable not found"; return; fi |
| 10 | objty=$(objdump -f $exe | sed -n '/^.*: *file format \(.*\)/s//\1/p') |
| 11 | echo "# $exe object type $objty" |
| 12 | case $objty in |
| 13 | elf32-* | elf64-*) |
| 14 | if f=$(objdump -p $exe | |
| 15 | sed -n '/^ *STACK / { n; s/^.*flags *\([-rwx]*\).*/\1/p; }') |
| 16 | then |
| 17 | echo "# STACK segment flags $f" |
| 18 | case $f in |
| 19 | rw-) echo "ok $tid stack not executable" ;; |
| 20 | rwx) echo "not ok $tid executable stack" ;; |
| 21 | *) echo "not ok $tid unexpected stack-segment flags" ;; |
| 22 | esac |
| 23 | else |
| 24 | echo "not ok $tid failed to find stack-segment flags" |
| 25 | fi |
| 26 | ;; |
| 27 | pei-x86-64) |
| 28 | if nm $exe | grep __enable_execute_stack; then |
| 29 | echo "not ok $tid # found call to __enable_execute_stack" |
| 30 | else |
| 31 | echo "ok $tid # stack maybe not executable" |
| 32 | fi |
| 33 | ;; |
| 34 | esac |
| 35 | } |
| 36 | |
| 37 | check_exe 1 finally-test |