boards: native_posix: Add option to build with Address Sanitizer
Address Sanitizer helps finding issues related to memory: buffer overflows, usage of uninitialized memory, etc. This is available in both Clang and GCC for a while, and, since the POSIX port is only meant for testing, this will help find issues. Signed-off-by: Leandro Pereira <leandro.pereira@intel.com> Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
parent
e07a1ad254
commit
91220ba640
2 changed files with 15 additions and 0 deletions
|
@ -19,6 +19,12 @@ zephyr_link_libraries_ifdef(CONFIG_COVERAGE
|
||||||
-lgcov
|
-lgcov
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (CONFIG_ASAN)
|
||||||
|
zephyr_compile_options(-fsanitize=address)
|
||||||
|
zephyr_link_libraries(-lasan)
|
||||||
|
zephyr_ld_options(-fsanitize=address)
|
||||||
|
endif ()
|
||||||
|
|
||||||
zephyr_compile_definitions(_POSIX_C_SOURCE=200809)
|
zephyr_compile_definitions(_POSIX_C_SOURCE=200809)
|
||||||
|
|
||||||
zephyr_ld_options(
|
zephyr_ld_options(
|
||||||
|
|
|
@ -16,6 +16,15 @@ config DEBUG
|
||||||
only disables optimization, more debugging variants can be selected
|
only disables optimization, more debugging variants can be selected
|
||||||
from here to allow more debugging.
|
from here to allow more debugging.
|
||||||
|
|
||||||
|
config ASAN
|
||||||
|
bool "Build with address sanitizer"
|
||||||
|
depends on ARCH_POSIX
|
||||||
|
help
|
||||||
|
Builds Zephyr with Address Sanitizer enabled. This is currently
|
||||||
|
only supported by the native_posix port, and requires a recent-ish
|
||||||
|
compiler with the `-fsanitize=address` command line option, and
|
||||||
|
the libasan library.
|
||||||
|
|
||||||
config STACK_USAGE
|
config STACK_USAGE
|
||||||
bool "Generate stack usage information"
|
bool "Generate stack usage information"
|
||||||
default n
|
default n
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue