1# SPDX-License-Identifier: GPL-2.0 2ifdef CONFIG_UBSAN_ALIGNMENT 3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) 4endif 5 6ifdef CONFIG_UBSAN_BOUNDS 7 ifdef CONFIG_CC_IS_CLANG 8 CFLAGS_UBSAN += -fsanitize=array-bounds 9 else 10 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) 11 endif 12endif 13 14ifdef CONFIG_UBSAN_LOCAL_BOUNDS 15 CFLAGS_UBSAN += -fsanitize=local-bounds 16endif 17 18ifdef CONFIG_UBSAN_MISC 19 CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift) 20 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero) 21 CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable) 22 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow) 23 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size) 24 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool) 25 CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum) 26endif 27 28ifdef CONFIG_UBSAN_TRAP 29 CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error) 30endif 31 32 # -fsanitize=* options makes GCC less smart than usual and 33 # increase number of 'maybe-uninitialized false-positives 34 CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) 35