Skip to content

Commit 49fa611

Browse files
xiaoxiang781216pkarashchenko
authored andcommitted
boards/sim: Enable more sanitizer check when enable
to catch more runtime usage error Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1 parent 37f318c commit 49fa611

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

arch/sim/src/sim/sim_head.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,27 @@ static void allsyms_relocate(void)
9898
****************************************************************************/
9999

100100
/****************************************************************************
101-
* Name: __lsan_default_options
101+
* Name: __xsan_default_options
102102
*
103103
* Description:
104104
* This function may be optionally provided by user and should return
105-
* a string containing leak sanitizer runtime options.
105+
* a string containing sanitizer runtime options.
106106
*
107107
****************************************************************************/
108108

109109
#ifdef CONFIG_SIM_ASAN
110+
const char *__asan_default_options(void)
111+
{
112+
return "abort_on_error=1"
113+
" alloc_dealloc_mismatch=0"
114+
" allocator_frees_and_returns_null_on_realloc_zero=0"
115+
" check_initialization_order=1"
116+
" detect_invalid_pointer_pairs=2"
117+
" detect_stack_use_after_return=1"
118+
" fast_unwind_on_malloc=0"
119+
" strict_init_order=1";
120+
}
121+
110122
const char *__lsan_default_options(void)
111123
{
112124
/* The fast-unwind implementation of leak-sanitizer will obtain the
@@ -123,7 +135,16 @@ const char *__lsan_default_options(void)
123135
* disable fast-unwind by default to avoid unwind failure.
124136
*/
125137

126-
return "fast_unwind_on_malloc=0";
138+
return "detect_leaks=1"
139+
" fast_unwind_on_malloc=0";
140+
}
141+
#endif
142+
143+
#ifdef CONFIG_SIM_UBSAN
144+
const char *__ubsan_default_options(void)
145+
{
146+
return "print_stacktrace=1"
147+
" fast_unwind_on_malloc=0";
127148
}
128149
#endif
129150

boards/sim/sim/sim/scripts/Make.defs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
7373
endif
7474

7575
ifeq ($(CONFIG_SIM_ASAN),y)
76-
ARCHOPTIMIZATION += -fsanitize=address
76+
ARCHOPTIMIZATION += -fsanitize=address -fsanitize-address-use-after-scope
77+
ARCHOPTIMIZATION += -fsanitize=pointer-compare -fsanitize=pointer-subtract
7778
else ifeq ($(CONFIG_MM_KASAN_ALL),y)
7879
ARCHOPTIMIZATION += -fsanitize=kernel-address
7980
endif

0 commit comments

Comments
 (0)