summaryrefslogtreecommitdiff
path: root/debian/check_nx
blob: 061064d0d73c9e1d3ec3dd543f6f35d2d8831f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#
# Helper script - check if a binary is tagged as NX-compatible or not.

set -e

for FILE in "$@"; do

    if [ ! -f "${FILE}" ]; then
	echo "${FILE} does not exist. ABORT."
	exit 1
    fi

    echo "Checking NX bit on ${FILE}:"
    DLL_CHARACTERISTICS=$(objdump -x "${FILE}" | awk '/DllCharacteristics/ {print $2}')

    echo "  DllCharacteristics $DLL_CHARACTERISTICS"
    case $DLL_CHARACTERISTICS in
	00000000)
	    echo "  NOT tagged as NX-compatible"
	    ;;
	00000100)
	    echo "  tagged as NX-compatible"
	    ;;
	*)
	    echo "  UNRECOGNISED value, ABORT";
	    exit 1
	    ;;
    esac

done