mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00: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:
@@ -27,10 +27,7 @@ idf_component_register(SRCS "${srcs}"
|
|||||||
|
|
||||||
|
|
||||||
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||||
# Increase link multiplicity to get some lwip symbols correctly resolved by the linker
|
|
||||||
# due to cyclic dependencies present in IDF for lwip/esp_netif/mbedtls
|
|
||||||
idf_component_get_property(lwip lwip COMPONENT_LIB)
|
idf_component_get_property(lwip lwip COMPONENT_LIB)
|
||||||
set_property(TARGET ${lwip} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 5)
|
|
||||||
else()
|
else()
|
||||||
# For linux target, define ESP_TLS_WITH_LWIP if LWIP is enabled in the build
|
# For linux target, define ESP_TLS_WITH_LWIP if LWIP is enabled in the build
|
||||||
if(CONFIG_LWIP_ENABLE)
|
if(CONFIG_LWIP_ENABLE)
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ endif()
|
|||||||
|
|
||||||
set(srcs "src/esp_err_to_name.c")
|
set(srcs "src/esp_err_to_name.c")
|
||||||
|
|
||||||
# Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here.
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
LDFRAGMENTS ${ldfragments})
|
LDFRAGMENTS ${ldfragments})
|
||||||
|
|
||||||
|
# Note: LINK_INTERFACE_MULTIPLICITY is needed to break circular static-library
|
||||||
|
# dependencies in the component graph. The core cycle is:
|
||||||
|
# esp_system -> bootloader_support -> efuse -> esp_system
|
||||||
|
# (efuse registers an ESP_SYSTEM_INIT_FN and calls esp_restart(), both of which
|
||||||
|
# pull in esp_system). Several more cycles exist through esp_partition, esp_mm,
|
||||||
|
# and mbedtls. All cycle-causing deps are already PRIV_REQUIRES, so the
|
||||||
|
# multiplicity property on this universal dependency is the established fix.
|
||||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)
|
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)
|
||||||
|
|
||||||
# List of components needed for the error codes list
|
# List of components needed for the error codes list
|
||||||
|
|||||||
@@ -343,7 +343,14 @@ endif()
|
|||||||
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||||
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c")
|
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c")
|
||||||
endif()
|
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)
|
if(CONFIG_SOC_AES_SUPPORTED)
|
||||||
target_include_directories(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/aes/include")
|
target_include_directories(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/aes/include")
|
||||||
|
|||||||
Reference in New Issue
Block a user