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