sim: Split SIM_SANITIZE to SIM_ASAN and SIM_UBSAN

align the naming style with MM_ASAN

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-10-30 23:45:34 +08:00 committed by Abdelatif Guettouche
parent c82a676630
commit 3e967f784e
3 changed files with 25 additions and 7 deletions

View File

@ -58,7 +58,7 @@ config SIM_CYGWIN_DECORATED
run: It will crash early, probably in some function due to the failure to
allocate memory.
config SIM_SANITIZE
config SIM_ASAN
bool "Address Sanitizer"
default n
depends on MM_CUSTOMIZE_MANAGER
@ -66,6 +66,13 @@ config SIM_SANITIZE
AddressSanitizer (ASan) is a fast compiler-based tool for detecting memory
bugs in native code.
config SIM_UBSAN
bool "Undefined Behaviour Sanitizer"
default n
---help---
Compile-time instrumentation is used to detect various undefined behaviours
at runtime.
choice
prompt "X64_64 ABI"
default SIM_X8664_SYSTEMV if HOST_LINUX

View File

@ -26,7 +26,8 @@ CONFIG_READLINE_TABCOMPLETION=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_ONEXIT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIM_SANITIZE=y
CONFIG_SIM_ASAN=y
CONFIG_SIM_UBSAN=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_OSTEST=y
CONFIG_USER_ENTRYPOINT="nsh_main"

View File

@ -129,14 +129,19 @@ ifeq ($(CONFIG_LIBCXX),y)
endif
endif
ifeq ($(CONFIG_SIM_SANITIZE),y)
CFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
CXXFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
ifeq ($(CONFIG_SIM_ASAN),y)
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer
else ifeq ($(CONFIG_MM_KASAN),y)
CFLAGS += -fsanitize=kernel-address
CXXFLAGS += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_SIM_UBSAN),y)
CFLAGS += -fsanitize=undefined -fno-omit-frame-pointer
CXXFLAGS += -fsanitize=undefined -fno-omit-frame-pointer
endif
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS)
@ -200,11 +205,16 @@ ifeq ($(CONFIG_SIM_M32),y)
HOSTLDFLAGS += -m32
endif
ifeq ($(CONFIG_SIM_SANITIZE),y)
CCLINKFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
ifeq ($(CONFIG_SIM_ASAN),y)
CCLINKFLAGS += -fsanitize=address -fno-omit-frame-pointer
else ifeq ($(CONFIG_MM_KASAN),y)
CCLINKFLAGS += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_SIM_UBSAN),y)
CCLINKFLAGS += -fsanitize=undefined -fno-omit-frame-pointer
endif
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(EXTRAFLAGS) -D__SIM__ -pipe