2020-05-04 00:20:01 -04:00
|
|
|
|
# The following lines of boilerplate have to be in your project's CMakeLists
|
|
|
|
|
# in this exact order for cmake to work correctly
|
2022-05-27 04:10:51 -04:00
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2020-05-04 00:20:01 -04:00
|
|
|
|
|
2021-12-13 04:52:22 -05:00
|
|
|
|
set(COMPONENTS main espcoredump esp_gdbstub)
|
2020-05-04 00:20:01 -04:00
|
|
|
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
2020-11-20 21:15:59 -05:00
|
|
|
|
|
2020-05-04 00:20:01 -04:00
|
|
|
|
project(test_panic)
|
2020-11-20 21:15:59 -05:00
|
|
|
|
|
2023-01-06 00:16:26 -05:00
|
|
|
|
if(CONFIG_TEST_MEMPROT)
|
|
|
|
|
# TODO: IDF-6821 - Refactor this to make it easy to add any new targets
|
|
|
|
|
if(CONFIG_SOC_MEMPROT_SUPPORTED)
|
|
|
|
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=esp_panic_handler")
|
|
|
|
|
if(CONFIG_IDF_TARGET_ESP32C3)
|
|
|
|
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=panic_arch_fill_info")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2020-11-20 21:15:59 -05:00
|
|
|
|
|
2024-05-06 09:41:25 -04:00
|
|
|
|
if(NOT CONFIG_TEST_MEMPROT AND NOT CONFIG_ESP_COREDUMP_CAPTURE_DRAM)
|
2023-01-06 00:16:26 -05:00
|
|
|
|
# Enable UBSAN checks
|
|
|
|
|
#
|
|
|
|
|
# shift-base sanitizer is disabled due to the following pattern found in register header files:
|
|
|
|
|
# #define SOME_FIELD 0xFFFF
|
|
|
|
|
# #define SOME_FIELD_M ((SOME_FIELD_V)<<(SOME_FIELD_S))
|
|
|
|
|
# #define SOME_FIELD_V 0xFFFF
|
|
|
|
|
# #define SOME_FIELD_S 16
|
|
|
|
|
# here SOME_FIELD_V doesn't have an unsigned (U) prefix, so the compiler flags
|
|
|
|
|
# SOME_FIELD_M expansion (0xFFFF << 16) as generating integer overflow.
|
|
|
|
|
#
|
|
|
|
|
set(ubsan_options "-fsanitize=undefined" "-fno-sanitize=shift-base")
|
|
|
|
|
|
|
|
|
|
# Only enable UBSAN for a few components related to the panic test,
|
|
|
|
|
# due to RAM size limitations.
|
2024-01-10 07:41:18 -05:00
|
|
|
|
set(ubsan_components main espcoredump esp_system spi_flash
|
|
|
|
|
esp_common esp_hw_support soc hal freertos)
|
|
|
|
|
if(CONFIG_ESP_COREDUMP_CHECKSUM_SHA256)
|
|
|
|
|
if(CONFIG_IDF_TARGET_ESP32S2)
|
|
|
|
|
# due to the ram limitation, coredump is removed from esp32s2 built
|
|
|
|
|
list(REMOVE_ITEM ubsan_components espcoredump)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
foreach(component IN LISTS ubsan_components)
|
2023-01-06 00:16:26 -05:00
|
|
|
|
idf_component_get_property(lib ${component} COMPONENT_LIB)
|
|
|
|
|
target_compile_options(${lib} PRIVATE ${ubsan_options})
|
|
|
|
|
endforeach()
|
|
|
|
|
endif()
|