Makefile.kasan 934 B

1234567891011121314151617181920212223242526272829303132
  1. ifdef CONFIG_KASAN
  2. ifdef CONFIG_KASAN_INLINE
  3. call_threshold := 10000
  4. else
  5. call_threshold := 0
  6. endif
  7. KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
  8. CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
  9. CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
  10. -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET) \
  11. --param asan-stack=1 --param asan-globals=1 \
  12. --param asan-instrumentation-with-call-threshold=$(call_threshold))
  13. ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
  14. ifneq ($(CONFIG_COMPILE_TEST),y)
  15. $(warning Cannot use CONFIG_KASAN: \
  16. -fsanitize=kernel-address is not supported by compiler)
  17. endif
  18. else
  19. ifeq ($(CFLAGS_KASAN),)
  20. ifneq ($(CONFIG_COMPILE_TEST),y)
  21. $(warning CONFIG_KASAN: compiler does not support all options.\
  22. Trying minimal configuration)
  23. endif
  24. CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
  25. endif
  26. endif
  27. endif