aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/tools/toolcheck
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/tools/toolcheck')
-rwxr-xr-xarch/arm/tools/toolcheck44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/arm/tools/toolcheck b/arch/arm/tools/toolcheck
new file mode 100755
index 000000000000..04fc44b750d2
--- /dev/null
+++ b/arch/arm/tools/toolcheck
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+#
+
+set -e
+
+cleanup() {
+ [[ ! -d $temp ]] || rm -rf "$temp"
+ exit
+}
+trap cleanup INT TERM EXIT
+temp="$(mktemp -d)"
+
+check_thumb2_address() {
+ local disassembly
+
+ $CC $KBUILD_AFLAGS -o "$temp/a.out" -c -xassembler - <<-_EOF
+ .syntax unified
+ .thumb
+ .macro badr, reg, sym
+ adr \reg, \sym + 1
+ .endm
+
+ .type test, %function
+ .thumb_func
+ test:
+ mov r0, #0
+ badr lr, test
+ _EOF
+ disassembly="$($OBJDUMP -d "$temp/a.out")"
+
+ [[ $disassembly =~ 4:[[:space:]]*f2af\ 0e07 ]] && return 0
+
+ echo "Error: your assembler version produces buggy kernels:" >&2
+ read < <($AS --version) && echo "$REPLY" >&2
+ [[ $disassembly =~ 4:[[:space:]].*$ ]] && echo "${BASH_REMATCH[0]}" >&2 || echo "$disassembly" >&2
+ return 1
+}
+
+config="$(< .config)"
+[[ $config == *CONFIG_THUMB2_KERNEL=y* ]] && check_thumb2_address
+
+exit 0