aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/Makefile7
-rw-r--r--arch/arm/tools/Makefile5
-rwxr-xr-xarch/arm/tools/toolcheck44
3 files changed, 53 insertions, 3 deletions
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 80351e505fd5..bd4e248a7f8f 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -319,16 +319,19 @@ all: $(notdir $(KBUILD_IMAGE)) $(KBUILD_DTBS)
archheaders:
$(Q)$(MAKE) $(build)=arch/arm/tools uapi
-archprepare:
+archprepare: toolcheck
$(Q)$(MAKE) $(build)=arch/arm/tools kapi
+toolcheck:
+ $(Q)$(MAKE) $(build)=arch/arm/tools $@
+
# Convert bzImage to zImage
bzImage: zImage
BOOT_TARGETS = zImage Image xipImage bootpImage uImage
INSTALL_TARGETS = zinstall uinstall install
-PHONY += bzImage $(BOOT_TARGETS) $(INSTALL_TARGETS)
+PHONY += bzImage $(BOOT_TARGETS) $(INSTALL_TARGETS) toolcheck
bootpImage uImage: zImage
zImage: Image
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index ddb89a7db36f..0a283756f1c5 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -23,12 +23,15 @@ uapi-hdrs-y += $(uapi)/unistd-eabi.h
targets += $(addprefix ../../../,$(gen-y) $(kapi-hdrs-y) $(uapi-hdrs-y))
-PHONY += kapi uapi
+PHONY += kapi uapi toolcheck
kapi: $(kapi-hdrs-y) $(gen-y)
uapi: $(uapi-hdrs-y)
+toolcheck:
+ @'$(srctree)/$(src)/toolcheck'
+
# Create output directory if not already present
_dummy := $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') \
$(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)')
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