Module Name:    src
Committed By:   maxv
Date:           Mon Apr 13 09:34:03 UTC 2020

Modified Files:
        src/sys/arch/amd64/conf: Makefile.amd64

Log Message:
Make KASAN compatible with LLVM. Same as GCC, except that LLVM aggressively
inlines the shadow checks, and this causes problems at boot time; so we
pass -asan-instrumentation-with-call-threshold=0 to force callbacks instead
of inlines.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/amd64/conf/Makefile.amd64

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/conf/Makefile.amd64
diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.82 src/sys/arch/amd64/conf/Makefile.amd64:1.83
--- src/sys/arch/amd64/conf/Makefile.amd64:1.82	Sat Apr  4 07:03:57 2020
+++ src/sys/arch/amd64/conf/Makefile.amd64	Mon Apr 13 09:34:02 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.amd64,v 1.82 2020/04/04 07:03:57 maxv Exp $
+#	$NetBSD: Makefile.amd64,v 1.83 2020/04/13 09:34:02 maxv Exp $
 
 # Makefile for NetBSD
 #
@@ -49,12 +49,21 @@ CFLAGS+=      -mindirect-branch=thunk-in
 CFLAGS+=      -mindirect-branch-register
 .endif
 
-.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
+.if ${KASAN:U0} > 0
+.if ${HAVE_GCC:U0} > 0
 KASANFLAGS=	-fsanitize=kernel-address \
 		--param asan-globals=1 --param asan-stack=1 \
 		--param asan-instrument-allocas=1 \
 		-fsanitize-address-use-after-scope \
 		-fasan-shadow-offset=0xDFFF900000000000
+.elif ${HAVE_LLVM:Uno} == "yes"
+KASANFLAGS=	-fsanitize=kernel-address \
+		-mllvm -asan-globals=1 -mllvm -asan-stack=1 \
+		-mllvm -asan-instrument-dynamic-allocas=1 \
+		-mllvm -asan-use-after-scope=1 \
+		-mllvm -asan-instrumentation-with-call-threshold=0 \
+		-mllvm -asan-mapping-offset=0xDFFF900000000000
+.endif
 .for f in subr_asan.c subr_kcov.c
 KASANFLAGS.${f}=	# empty
 .endfor

Reply via email to