Files
kernel_google_wahoo/scripts/Makefile.kasan
Greg Hackmann 14affa5fc1 ANDROID: kasan, LLVMLinux: add clang-specific CFLAGS_KASAN
clang and gcc have slightly different syntax for asan parameters.

Change-Id: Ic06f85d3b82010cfdd8138e459337134e9ae48ba
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-04-03 09:46:33 -07:00

40 lines
1.2 KiB
Makefile

ifdef CONFIG_KASAN
ifdef CONFIG_KASAN_INLINE
call_threshold := 10000
else
call_threshold := 0
endif
KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
ifeq ($(cc-name),clang)
CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
-mllvm \
-asan-mapping-offset=$(KASAN_SHADOW_OFFSET) \
-asan-stack=1 -asan-globals=1 \
-asan-instrumentation-with-call-threshold=$(call_threshold))
else
CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
-fasan-shadow-offset=$(KASAN_SHADOW_OFFSET) \
--param asan-stack=1 --param asan-globals=1 \
--param asan-instrumentation-with-call-threshold=$(call_threshold))
endif
ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
ifneq ($(CONFIG_COMPILE_TEST),y)
$(warning Cannot use CONFIG_KASAN: \
-fsanitize=kernel-address is not supported by compiler)
endif
else
ifeq ($(CFLAGS_KASAN),)
ifneq ($(CONFIG_COMPILE_TEST),y)
$(warning CONFIG_KASAN: compiler does not support all options.\
Trying minimal configuration)
endif
CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
endif
endif
endif