feat: run test with cfi
Some checks failed
Hello World (Multiplatform) / build (macos-12) (push) Waiting to run
Hello World (Multiplatform) / build (macos-14) (push) Waiting to run
Hello World (Multiplatform) / build (ubuntu-22.04) (push) Waiting to run
Hello World (Multiplatform) / build (windows-2022) (push) Waiting to run
Run tests with twister / twister-build-prep (push) Waiting to run
Run tests with twister / twister-build (push) Blocked by required conditions
Run tests with twister / Publish Unit Tests Results (push) Blocked by required conditions
Run tests with twister / Check Twister Status (push) Blocked by required conditions
Twister TestSuite / Twister Unit Tests (ubuntu-22.04, 3.10) (push) Has been cancelled
Twister TestSuite / Twister Unit Tests (ubuntu-22.04, 3.11) (push) Has been cancelled
Twister TestSuite / Twister Unit Tests (ubuntu-22.04, 3.12) (push) Has been cancelled
Twister TestSuite / Twister Unit Tests (ubuntu-22.04, 3.8) (push) Has been cancelled
Twister TestSuite / Twister Unit Tests (ubuntu-22.04, 3.9) (push) Has been cancelled

This commit is contained in:
Patrick 2024-08-13 16:36:35 +02:00
parent 754d5e4be2
commit f80f0fda2a
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
7 changed files with 13 additions and 6 deletions

View file

@ -508,7 +508,6 @@ endchoice
config LTO
bool "Link Time Optimization [EXPERIMENTAL]"
depends on !(GEN_ISR_TABLES || GEN_IRQ_VECTOR_TABLE) || ISR_TABLES_LOCAL_DECLARATION
depends on !NATIVE_LIBRARY
depends on !CODE_DATA_RELOCATION
select EXPERIMENTAL
help

View file

@ -159,13 +159,17 @@ endif()
# (supported by current gcc's as well)
#
if(CONFIG_CFI)
zephyr_compile_options(-flto -fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt)
target_link_options(native_simulator INTERFACE "-flto -fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt")
target_compile_options(native_simulator INTERFACE "-flto -fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt")
zephyr_link_libraries("-flto")
zephyr_compile_options(-fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt)
target_link_options(native_simulator INTERFACE "-fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt")
target_compile_options(native_simulator INTERFACE "-fvisibility=hidden -fno-sanitize-trap=cfi -fsanitize-ignorelist=/home/patrick/repos/uni/idp/zephyrtest/zephyr/ignore_list.txt")
list(APPEND LLVM_SANITIZERS "cfi")
endif()
if(CONFIG_LTO)
target_compile_options(native_simulator INTERFACE "-flto")
target_link_options(native_simulator INTERFACE "-flto")
endif()
if(CONFIG_ASAN)
list(APPEND LLVM_SANITIZERS "address")
endif()

View file

@ -131,7 +131,6 @@ function(toolchain_ld_link_elf)
${TOPT}
${TOOLCHAIN_LD_LINK_ELF_LINKER_SCRIPT}
${TOOLCHAIN_LD_LINK_ELF_LIBRARIES_POST_SCRIPT}
-flto
${LINKERFLAGPREFIX},-Map=${TOOLCHAIN_LD_LINK_ELF_OUTPUT_MAP}
${LINKERFLAGPREFIX},--whole-archive

View file

@ -1 +1,2 @@
src:*/native_simulator/*
fun:z_cbvprintf_impl

View file

@ -2,6 +2,7 @@ CONFIG_GPIO=y
#CONFIG_ASAN=y
CONFIG_CFI=y
CONFIG_LLVM_USE_LLD=y
CONFIG_LTO=y
#CONFIG_DEBUG=y
#CONFIG_DEBUG_INFO=y

View file

@ -285,6 +285,7 @@ class TestInstance:
content = content + "\nCONFIG_COVERAGE=y"
content = content + "\nCONFIG_COVERAGE_DUMP=y"
content = content + "\nCONFIG_CFI=y\nCONFIG_LTO=y\nCONFIG_LLVM_USE_LLD=y"
if enable_asan:
if platform.type == "native":
content = content + "\nCONFIG_ASAN=y"

View file

@ -110,6 +110,8 @@ config GPROF
config CFI
bool "Build with control flow integrity sanitizer"
depends on LTO
depends on LLVM_USE_LLD
help
Builds Zephyr with Address Sanitizer enabled. This is currently
only supported by boards based on the posix architecture, and requires a