summaryrefslogtreecommitdiff
path: root/debian/check_nx
blob: b3e4d4308d6a7563422e7f28864286db73260a20 (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
33
34
35
36
37
38
39
40
41
#!/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

    # On older toolchains pre-bookworm, objdump on arm64 does not
    # include appropriate support.
    case "$FILE" in
	*aa64*)
	    echo "$0: Ignoring arm64 binary - objdump too old"
	    continue
	    ;;
    esac

    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