blob: 27348029b2b81ae74a46c1819b89bdde957099be [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Kees Cook0887a7e2020-04-06 20:12:27 -07002ifdef CONFIG_UBSAN_ALIGNMENT
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
4endif
5
Kees Cook277a1082020-04-06 20:12:31 -07006ifdef CONFIG_UBSAN_BOUNDS
7 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
8endif
9
10ifdef CONFIG_UBSAN_MISC
Andrey Ryabininc6d30852016-01-20 15:00:55 -080011 CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift)
12 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
13 CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080014 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080015 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080016 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
17 CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
Kees Cook277a1082020-04-06 20:12:31 -070018endif
Andrey Ryabininc6d30852016-01-20 15:00:55 -080019
Kees Cook0887a7e2020-04-06 20:12:27 -070020ifdef CONFIG_UBSAN_TRAP
21 CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080022endif
Christian Borntraeger725c4d22016-09-12 14:37:19 +020023
Arnd Bergmanna76bcf52016-11-10 17:44:44 +010024 # -fsanitize=* options makes GCC less smart than usual and
25 # increase number of 'maybe-uninitialized false-positives
26 CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)