[PATCH][ARM]Honour __heap_limit__ during _sbrk() memory allocation checking.

Renlin Li renlin.li@arm.com
Tue Feb 17 06:20:00 GMT 2015

Hi all,

HeapInfo is returned when SYS_HEAPINFO Angel semihost call is triggered, 
the following data will be returned.

struct block {
     int heap_base;
     int heap_limit;
     int stack_base;
     int stack_limit;

the heap_limit should be honoured while doing dynamic memory allocation. 
Currently, _sbrk() does a simple check by comparing the heap end against 
stack pointer. This is not enough, if __heap_limit is valid, it also 
should be used to predicate whether enough heap memory is there to be 

libstdc++v3, gcc regression tests are checked using arm-none-eabi 
toolchain, on new issues.

Okay to commit?

Actually, aarch64 target also has the same problem. In addition, 
__heap_base__ is not used either. I will come up with a patch later.


2015-02-13  Renlin Li  <renlin.li@arm.com>

     * arm/crt0.S: Initialise __heap_limit when ARM_RDI_MONITOR is defined.
     * arm/syscalls.c: define __heap_limit global symbol.
     * arm/syscalls.c (_sbrk): Honour __heap_limit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new-1.diff
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150217/bcfd45dc/attachment.bin>

More information about the Newlib mailing list