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