mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(mbedtls): fix undefined esp_mbedtls_mem_calloc/free at link time
platform.c (compiled into the 'builtin' archive) calls esp_mbedtls_mem_calloc and esp_mbedtls_mem_free directly by name via the MBEDTLS_PLATFORM_STD_CALLOC/FREE macros in esp_config.h. Previously, esp_mem.c was compiled into the 'tfpsacrypto' archive, which appears after 'builtin' in the link command, causing the linker to fail with undefined reference errors when 'builtin' was processed first. Moving esp_mem.c into 'builtin' to assure that the function used by esp_mbedtls_mem_calloc and esp_mbedtls_mem_free are available when pltform.c is linked.
This commit is contained in:
@@ -343,7 +343,14 @@ endif()
|
||||
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c")
|
||||
endif()
|
||||
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_mem.c")
|
||||
# esp_mem.c defines esp_mbedtls_mem_calloc/free, which platform.c (inside the
|
||||
# 'builtin' archive) calls via MBEDTLS_PLATFORM_STD_CALLOC/FREE. Compiling
|
||||
# esp_mem.c directly into 'builtin' ensures the symbols are in the same archive
|
||||
# as their caller, avoiding any link-order dependency on a separate archive.
|
||||
# port/include (for esp_mem.h) and the IDF global includes (sdkconfig.h,
|
||||
# esp_attr.h, esp_heap_caps.h) are both available here via directory-level
|
||||
# include_directories set up by idf_component_register before add_subdirectory.
|
||||
target_sources(builtin PRIVATE "${COMPONENT_DIR}/port/esp_mem.c")
|
||||
|
||||
if(CONFIG_SOC_AES_SUPPORTED)
|
||||
target_include_directories(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/aes/include")
|
||||
|
||||
Reference in New Issue
Block a user