git: e1d2967ba630 - main - sys/conf: Support building kasan with gcc on arm64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Oct 2024 17:25:08 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=e1d2967ba6309bba5a3d73ad637f43d0e33f71ec
commit e1d2967ba6309bba5a3d73ad637f43d0e33f71ec
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-09-27 15:23:57 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-10-15 17:24:41 +0000
sys/conf: Support building kasan with gcc on arm64
- Remove -mllvm flags that don't exist in gcc
- Set the shadow offset with -fasan-shadow-offset
- Remove this when kasan is disabled as it's an error to use this
when not building for kasan under gcc
This allows the arm64 GENERIC-KASAN kernel to build with gcc13.
Reviewed by: brooks
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D45300
---
sys/conf/kern.pre.mk | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 50a81a29d18d..d0a66ceceae2 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -95,13 +95,15 @@ COMPAT_FREEBSD32_ENABLED!= grep COMPAT_FREEBSD32 opt_global.h || true ; echo
KASAN_ENABLED!= grep KASAN opt_global.h || true ; echo
.if !empty(KASAN_ENABLED)
SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kasan \
- -fsanitize=kernel-address \
- -mllvm -asan-stack=true \
+ -fsanitize=kernel-address
+.if ${COMPILER_TYPE} == "clang"
+SAN_CFLAGS+= -mllvm -asan-stack=true \
-mllvm -asan-instrument-dynamic-allocas=true \
-mllvm -asan-globals=true \
-mllvm -asan-use-after-scope=true \
-mllvm -asan-instrumentation-with-call-threshold=0 \
-mllvm -asan-instrument-byval=false
+.endif
.if ${MACHINE_CPUARCH} == "aarch64"
# KASAN/ARM64 TODO: -asan-mapping-offset is calculated from:
@@ -111,7 +113,11 @@ SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kasan \
# KASAN_MIN_ADDRESS, and this offset value should eventually be
# upstreamed similar to: https://reviews.llvm.org/D98285
#
+.if ${COMPILER_TYPE} == "clang"
SAN_CFLAGS+= -mllvm -asan-mapping-offset=0xdfff208000000000
+.else
+SAN_CFLAGS+= -fasan-shadow-offset=0xdfff208000000000
+.endif
.elif ${MACHINE_CPUARCH} == "amd64" && \
${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000
# Work around https://github.com/llvm/llvm-project/issues/87923, which leads to