summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.ubsan
blob: c18fecc536059926db5f9c168feb1be3233f3ca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# SPDX-License-Identifier: GPL-2.0

export CFLAGS_UBSAN :=

ifdef CONFIG_UBSAN_ALIGNMENT
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
endif

ifdef CONFIG_UBSAN_BOUNDS
      ifdef CONFIG_CC_IS_CLANG
            CFLAGS_UBSAN += -fsanitize=array-bounds
      else
            CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
      endif
endif

ifdef CONFIG_UBSAN_LOCAL_BOUNDS
      CFLAGS_UBSAN += -fsanitize=local-bounds
endif

ifdef CONFIG_UBSAN_MISC
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
      CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
endif

ifdef CONFIG_UBSAN_TRAP
      CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error)
endif