blob: 5b15bc425ec9872dba1f59e9c827699d7dd12b67 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Andrey Ryabininc6d30852016-01-20 15:00:55 -08002ifdef CONFIG_UBSAN
Kees Cook0887a7e2020-04-06 20:12:27 -07003
4ifdef CONFIG_UBSAN_ALIGNMENT
5 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
6endif
7
Kees Cook277a1082020-04-06 20:12:31 -07008ifdef CONFIG_UBSAN_BOUNDS
9 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
10endif
11
12ifdef CONFIG_UBSAN_MISC
Andrey Ryabininc6d30852016-01-20 15:00:55 -080013 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)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080016 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080017 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080018 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
19 CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
Kees Cook277a1082020-04-06 20:12:31 -070020endif
Andrey Ryabininc6d30852016-01-20 15:00:55 -080021
Kees Cook0887a7e2020-04-06 20:12:27 -070022ifdef CONFIG_UBSAN_TRAP
23 CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080024endif
Christian Borntraeger725c4d22016-09-12 14:37:19 +020025
Arnd Bergmanna76bcf52016-11-10 17:44:44 +010026 # -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)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080029endif