Skip to content

Commit 729333e

Browse files
committed
AP_HAL_ESP32: ensure malloc is wrapped to zero memory
The relevant linker flag needed to be put in the CMake script.
1 parent 94aa4fc commit 729333e

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Tools/ardupilotwaf/boards.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,7 @@ def configure_env(self, cfg, env):
13901390
]
13911391

13921392
# wrap malloc to ensure memory is zeroed
1393+
# note that this also needs to be done in the CMakeLists.txt files
13931394
env.LINKFLAGS += ['-Wl,--wrap,malloc']
13941395

13951396
if cfg.options.force_32bit:

libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ target_link_libraries(${elf_file}
121121
# linker script generation, partition_table generation, etc.
122122
idf_build_executable(${elf_file})
123123

124+
# wrap malloc to ensure memory is zeroed
125+
target_link_options(${elf_file} PRIVATE "-Wl,--wrap,malloc")
126+
124127
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
125128

126129
# Additional targets for measuring RAM use: size, size-components, size-files

libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ target_link_libraries(${elf_file}
121121
# linker script generation, partition_table generation, etc.
122122
idf_build_executable(${elf_file})
123123

124+
# wrap malloc to ensure memory is zeroed
125+
target_link_options(${elf_file} PRIVATE "-Wl,--wrap,malloc")
126+
124127
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
125128

126129
# Additional targets for measuring RAM use: size, size-components, size-files

0 commit comments

Comments
 (0)