mbed-os/platform/source
Lingkai Dong 8d32b668ec Workaround for a bug in malloc() from newlib-nano 4.1.0
The commit 84d0689 "Nano-malloc: Fix for unwanted external heap
fragmentation" from newlib 4.1.0 introduced several optimizations,
one of which is as follows:

When the last chunk in the free list is smaller than requested,
nano_malloc() calls sbrk(0) to see if the heap's current head is
adjacent to this chunk, and if so it asks sbrk() to allocate the
difference in bytes only and expands the current chunk.

This doesn't work if the heap consists of non-contiguous regions.
sbrk(0) returns the the current region's head if the region has any
remaining capacity. But if this capacity is not enough for the second
(non-trivial) call to sbrk() described above, allocation will happen
from the next region if available. Expanding the current chunk won't
work and will result in a segmentation fault.

So this optimization needs to be reverted in order to bring back
compatibility with non-contiguous heaps. Before the next version
of newlib becomes available and gets updated in the GCC Arm Embedded
Toolchain, we work around this issue by including the fix in Mbed OS.
The linker prioritizes malloc() from the project to the one from the
toolchain.
2021-09-01 17:21:32 +01:00
..
TARGET_CORTEX_A/TOOLCHAIN_IAR
TARGET_CORTEX_M Update GCC except.S to support ARMC6 2021-05-24 13:54:57 +01:00
minimal-printf
ATCmdParser.cpp
CMakeLists.txt Workaround for a bug in malloc() from newlib-nano 4.1.0 2021-09-01 17:21:32 +01:00
CThunkBase.cpp
CriticalSectionLock.cpp
DeepSleepLock.cpp
FileBase.cpp
FileHandle.cpp
FilePath.cpp
FileSystemHandle.cpp
LocalFileSystem.cpp semihosting: add compat header where is required 2021-07-29 14:31:38 +01:00
Stream.cpp
SysTimer.cpp
mbed_alloc_wrappers.cpp Add integer overflow check to the malloc wrappers 2021-03-10 09:47:15 +00:00
mbed_application.c Make changes for Cortex-A5 support 2021-06-23 13:36:55 +08:00
mbed_assert.c
mbed_atomic_impl.c
mbed_board.c [STD-PIN] BUTTON and LED define 2021-03-18 17:01:50 +00:00
mbed_crash_data_offsets.h
mbed_critical.c Unify the __CORTEX_A macro in the files containing cmsis.h 2021-06-23 13:36:52 +08:00
mbed_error.c fixup! error: use __INITIAL_SP from cmsis instead of RTX one 2021-05-10 16:09:18 +01:00
mbed_error_hist.c
mbed_interface.c
mbed_mem_trace.cpp
mbed_mktime.c
mbed_mpu_mgmt.c
mbed_os_timer.cpp
mbed_poll.cpp
mbed_power_mgmt.c
mbed_retarget.cpp retarget: move compat header for ARMClang prior any cmsis headers 2021-07-29 14:31:33 +01:00
mbed_rtc_time.cpp
mbed_sdk_boot.c Unify the __CORTEX_A macro in the files containing cmsis.h 2021-06-23 13:36:52 +08:00
mbed_semihost_api.c semihosting: add compat header where is required 2021-07-29 14:31:38 +01:00
mbed_stats.c
mbed_thread.cpp
mbed_wait_api_no_rtos.c Make changes for Cortex-A5 support 2021-06-23 13:36:55 +08:00
newlib_nano_malloc_workaround.c Workaround for a bug in malloc() from newlib-nano 4.1.0 2021-09-01 17:21:32 +01:00