cmake: toolchain abstraction for address sanitizer
Added toolchain abstraction for address sanitizer Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
1c7892df3f
commit
89e97d13ec
6 changed files with 21 additions and 3 deletions
|
@ -24,9 +24,7 @@ if (CONFIG_COVERAGE)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (CONFIG_ASAN)
|
if (CONFIG_ASAN)
|
||||||
zephyr_compile_options(-fsanitize=address)
|
toolchain_cc_asan()
|
||||||
zephyr_link_libraries(-lasan)
|
|
||||||
zephyr_ld_options(-fsanitize=address)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)
|
zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)
|
||||||
|
|
|
@ -86,6 +86,7 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
||||||
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_sanitizers.cmake)
|
||||||
|
|
||||||
macro(toolchain_cc_security_fortify)
|
macro(toolchain_cc_security_fortify)
|
||||||
# No op, clang doesn't understand fortify at all
|
# No op, clang doesn't understand fortify at all
|
||||||
|
|
8
cmake/compiler/clang/target_sanitizers.cmake
Normal file
8
cmake/compiler/clang/target_sanitizers.cmake
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
macro(toolchain_cc_asan)
|
||||||
|
|
||||||
|
zephyr_compile_options(-fsanitize=address)
|
||||||
|
zephyr_ld_options(-fsanitize=address)
|
||||||
|
|
||||||
|
endmacro()
|
|
@ -126,3 +126,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_imacros.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_imacros.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_base.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_base.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
||||||
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_sanitizers.cmake)
|
||||||
|
|
9
cmake/compiler/gcc/target_sanitizers.cmake
Normal file
9
cmake/compiler/gcc/target_sanitizers.cmake
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
macro(toolchain_cc_asan)
|
||||||
|
|
||||||
|
zephyr_compile_options(-fsanitize=address)
|
||||||
|
zephyr_link_libraries(-lasan)
|
||||||
|
zephyr_ld_options(-fsanitize=address)
|
||||||
|
|
||||||
|
endmacro()
|
|
@ -77,3 +77,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
||||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_coverage.cmake)
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_coverage.cmake)
|
||||||
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_sanitizers.cmake)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue