at commit 205cccd0

1 # SPDX-License-Identifier: GPL-2.0
2
3 # Shared with KVM/arm64.
4 export CFLAGS_UBSAN_TRAP := $(call cc-option,-fsanitize-trap=undefined,-fsanitize-undefined-trap-on-error)
5
6 # Enable available and selected UBSAN features.
7 ubsan-cflags-$(CONFIG_UBSAN_ALIGNMENT) += -fsanitize=alignment
8 ubsan-cflags-$(CONFIG_UBSAN_BOUNDS_STRICT) += -fsanitize=bounds-strict
9 ubsan-cflags-$(CONFIG_UBSAN_ARRAY_BOUNDS) += -fsanitize=array-bounds
10 ubsan-cflags-$(CONFIG_UBSAN_LOCAL_BOUNDS) += -fsanitize=local-bounds
11 ubsan-cflags-$(CONFIG_UBSAN_SHIFT) += -fsanitize=shift
12 ubsan-cflags-$(CONFIG_UBSAN_DIV_ZERO) += -fsanitize=integer-divide-by-zero
13 ubsan-cflags-$(CONFIG_UBSAN_UNREACHABLE) += -fsanitize=unreachable
14 ubsan-cflags-$(CONFIG_UBSAN_BOOL) += -fsanitize=bool
15 ubsan-cflags-$(CONFIG_UBSAN_ENUM) += -fsanitize=enum
16 ubsan-cflags-$(CONFIG_UBSAN_TRAP) += $(CFLAGS_UBSAN_TRAP)
17
18 export CFLAGS_UBSAN := $(ubsan-cflags-y)
19
20 ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \
21 -DINTEGER_WRAP \
22 -fsanitize-undefined-ignore-overflow-pattern=all \
23 -fsanitize=signed-integer-overflow \
24 -fsanitize=unsigned-integer-overflow \
25 -fsanitize=implicit-signed-integer-truncation \
26 -fsanitize=implicit-unsigned-integer-truncation \
27 -fsanitize-ignorelist=$(srctree)/scripts/integer-wrap-ignore.scl
28 export CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y)