Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1# SPDX-License-Identifier: GPL-2.0
2
3# Shared with KVM/arm64.
4export CFLAGS_UBSAN_TRAP := $(call cc-option,-fsanitize-trap=undefined,-fsanitize-undefined-trap-on-error)
5
6# Enable available and selected UBSAN features.
7ubsan-cflags-$(CONFIG_UBSAN_ALIGNMENT) += -fsanitize=alignment
8ubsan-cflags-$(CONFIG_UBSAN_BOUNDS_STRICT) += -fsanitize=bounds-strict
9ubsan-cflags-$(CONFIG_UBSAN_ARRAY_BOUNDS) += -fsanitize=array-bounds
10ubsan-cflags-$(CONFIG_UBSAN_LOCAL_BOUNDS) += -fsanitize=local-bounds
11ubsan-cflags-$(CONFIG_UBSAN_SHIFT) += -fsanitize=shift
12ubsan-cflags-$(CONFIG_UBSAN_DIV_ZERO) += -fsanitize=integer-divide-by-zero
13ubsan-cflags-$(CONFIG_UBSAN_UNREACHABLE) += -fsanitize=unreachable
14ubsan-cflags-$(CONFIG_UBSAN_BOOL) += -fsanitize=bool
15ubsan-cflags-$(CONFIG_UBSAN_ENUM) += -fsanitize=enum
16ubsan-cflags-$(CONFIG_UBSAN_TRAP) += $(CFLAGS_UBSAN_TRAP)
17
18export CFLAGS_UBSAN := $(ubsan-cflags-y)
19
20ubsan-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
28export CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y)