From 716a9dc433befeedca565830cdcf8d05a1787efb Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 4 Jan 2025 16:11:33 -0600 Subject: [PATCH] AP_HAL_ESP32: ensure malloc is wrapped to zero memory The relevant linker flag needed to be put in the CMake script. --- libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt | 3 +++ libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt b/libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt index 9931d646592c27..9d3a88ea4ea544 100644 --- a/libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt +++ b/libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt @@ -121,6 +121,9 @@ target_link_libraries(${elf_file} # linker script generation, partition_table generation, etc. idf_build_executable(${elf_file}) +# wrap malloc to ensure memory is zeroed +target_link_options(${elf_file} PRIVATE "-Wl,--wrap,malloc") + set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Additional targets for measuring RAM use: size, size-components, size-files diff --git a/libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt b/libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt index 8627deba644654..ff0fe328bfff7d 100644 --- a/libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt +++ b/libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt @@ -121,6 +121,9 @@ target_link_libraries(${elf_file} # linker script generation, partition_table generation, etc. idf_build_executable(${elf_file}) +# wrap malloc to ensure memory is zeroed +target_link_options(${elf_file} PRIVATE "-Wl,--wrap,malloc") + set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Additional targets for measuring RAM use: size, size-components, size-files