1 # SPDX-License-Identifier: GPL-2.0
2 ifdef CONFIG_UBSAN_ALIGNMENT
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
6 ifdef CONFIG_UBSAN_BOUNDS
7 ifdef CONFIG_CC_IS_CLANG
8 CFLAGS_UBSAN += -fsanitize=array-bounds
10 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
14 ifdef CONFIG_UBSAN_LOCAL_BOUNDS
15 CFLAGS_UBSAN += -fsanitize=local-bounds
18 ifdef 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)
28 ifdef CONFIG_UBSAN_TRAP
29 CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error)
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)