Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/sim: Enable more sanitizer check when enable #9197

Merged
merged 1 commit into from May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 24 additions & 3 deletions arch/sim/src/sim/sim_head.c
Expand Up @@ -98,15 +98,27 @@ static void allsyms_relocate(void)
****************************************************************************/

/****************************************************************************
* Name: __lsan_default_options
* Name: __xsan_default_options
*
* Description:
* This function may be optionally provided by user and should return
* a string containing leak sanitizer runtime options.
* a string containing sanitizer runtime options.
*
****************************************************************************/

#ifdef CONFIG_SIM_ASAN
const char *__asan_default_options(void)
{
return "abort_on_error=1"
" alloc_dealloc_mismatch=0"
" allocator_frees_and_returns_null_on_realloc_zero=0"
" check_initialization_order=1"
" detect_invalid_pointer_pairs=2"
" detect_stack_use_after_return=1"
" fast_unwind_on_malloc=0"
" strict_init_order=1";
}

const char *__lsan_default_options(void)
{
/* The fast-unwind implementation of leak-sanitizer will obtain the
Expand All @@ -123,7 +135,16 @@ const char *__lsan_default_options(void)
* disable fast-unwind by default to avoid unwind failure.
*/

return "fast_unwind_on_malloc=0";
return "detect_leaks=1"
" fast_unwind_on_malloc=0";
}
#endif

#ifdef CONFIG_SIM_UBSAN
const char *__ubsan_default_options(void)
{
return "print_stacktrace=1"
" fast_unwind_on_malloc=0";
}
#endif

Expand Down
3 changes: 2 additions & 1 deletion boards/sim/sim/sim/scripts/Make.defs
Expand Up @@ -73,7 +73,8 @@ ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
endif

ifeq ($(CONFIG_SIM_ASAN),y)
ARCHOPTIMIZATION += -fsanitize=address
ARCHOPTIMIZATION += -fsanitize=address -fsanitize-address-use-after-scope
ARCHOPTIMIZATION += -fsanitize=pointer-compare -fsanitize=pointer-subtract
else ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
Expand Down