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