CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # The following lines of boilerplate have to be in your project's CMakeLists
  2. # in this exact order for cmake to work correctly
  3. cmake_minimum_required(VERSION 3.16)
  4. set(COMPONENTS main espcoredump esp_gdbstub)
  5. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  6. project(test_panic)
  7. if(CONFIG_TEST_MEMPROT)
  8. # TODO: IDF-6821 - Refactor this to make it easy to add any new targets
  9. if(CONFIG_SOC_MEMPROT_SUPPORTED)
  10. target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=esp_panic_handler")
  11. if(CONFIG_IDF_TARGET_ESP32C3)
  12. target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=panic_arch_fill_info")
  13. endif()
  14. endif()
  15. endif()
  16. if(NOT CONFIG_TEST_MEMPROT)
  17. # Enable UBSAN checks
  18. #
  19. # shift-base sanitizer is disabled due to the following pattern found in register header files:
  20. # #define SOME_FIELD 0xFFFF
  21. # #define SOME_FIELD_M ((SOME_FIELD_V)<<(SOME_FIELD_S))
  22. # #define SOME_FIELD_V 0xFFFF
  23. # #define SOME_FIELD_S 16
  24. # here SOME_FIELD_V doesn't have an unsigned (U) prefix, so the compiler flags
  25. # SOME_FIELD_M expansion (0xFFFF << 16) as generating integer overflow.
  26. #
  27. set(ubsan_options "-fsanitize=undefined" "-fno-sanitize=shift-base")
  28. # Only enable UBSAN for a few components related to the panic test,
  29. # due to RAM size limitations.
  30. foreach(component main espcoredump esp_system spi_flash
  31. esp_common esp_hw_support soc hal freertos)
  32. idf_component_get_property(lib ${component} COMPONENT_LIB)
  33. target_compile_options(${lib} PRIVATE ${ubsan_options})
  34. endforeach()
  35. endif()