diff --git a/cpu/esp_common/Makefile.include b/cpu/esp_common/Makefile.include index 684afff317..6d34b99845 100644 --- a/cpu/esp_common/Makefile.include +++ b/cpu/esp_common/Makefile.include @@ -88,7 +88,7 @@ LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static ifeq (,$(filter esp_idf_heap,$(USEMODULE))) # use the wrapper functions for calloc to add correct overflow detection missing # in the newlib's version. - LINKFLAGS += -Wl,-wrap=calloc + LINKFLAGS += -Wl,-wrap=_calloc_r endif # LINKFLAGS += -Wl,--verbose diff --git a/cpu/esp_common/syscalls.c b/cpu/esp_common/syscalls.c index b1c5f9fe76..ea42a718b7 100644 --- a/cpu/esp_common/syscalls.c +++ b/cpu/esp_common/syscalls.c @@ -289,7 +289,7 @@ void* IRAM_ATTR __wrap__calloc_r(struct _reent *r, size_t count, size_t size) #else /* MODULE_ESP_IDF_HEAP */ -void *__wrap_calloc(size_t nmemb, size_t size) +void* IRAM_ATTR __wrap__calloc_r(struct _reent *r, size_t nmemb, size_t size) { /* The xtensa support has not yet upstreamed to newlib. Hence, the fixed * calloc implementation of newlib >= 4.0.0 is not available to the ESP @@ -299,7 +299,7 @@ void *__wrap_calloc(size_t nmemb, size_t size) return NULL; } - void *res = malloc(total_size); + void *res = _malloc_r(r, total_size); if (res) { memset(res, 0, total_size);