Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/conf Make KASAN compatible with LLVM. Same as...



details:   https://anonhg.NetBSD.org/src/rev/793b8c5ec0ef
branches:  trunk
changeset: 930745:793b8c5ec0ef
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Apr 13 09:34:02 2020 +0000

description:
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.

diffstat:

 sys/arch/amd64/conf/Makefile.amd64 |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 7f285b22e442 -r 793b8c5ec0ef sys/arch/amd64/conf/Makefile.amd64
--- a/sys/arch/amd64/conf/Makefile.amd64        Mon Apr 13 09:30:42 2020 +0000
+++ b/sys/arch/amd64/conf/Makefile.amd64        Mon Apr 13 09:34:02 2020 +0000
@@ -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-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



Home | Main Index | Thread Index | Old Index