Defined in rt_misc.h, the
__user_heap_extend() function can be defined to return extra blocks of memory, separate from the initial one, to be used by the heap.
If defined, this function must return the size and base address of an eight-byte aligned heap extension block.
There is no default implementation of this function. If you define this function, it must have the following characteristics:
- The returned size is one of the following:
- In AArch32 state, a multiple of 8 bytes of at least the requested size.
- In AArch64 state, a multiple of 16 bytes of at least the requested size.
- 0, denoting that the request cannot be honored.
- The returned base address is aligned on:
- In AArch32 state, an 8-byte boundary.
- In AArch64 state, a 16-byte boundary.
- Size is measured in bytes.
- The function is subject only to Procedure Call Standard for the Arm® Architecture (AAPCS) constraints.
- The first argument is always zero on entry and can be ignored. The base is returned in the register holding this argument.
__user_heap_extend()is only weakly referenced by the C library. This means that unused section elimination might remove the
__user_heap_extend()function at link time, and in this case, the heap cannot be extended. To prevent this situation, you can use
armlink --keepto prevent the function from being eliminated. Alternatively, include an explicit reference to
__user_heap_extend()from a part of the application code that you are sure will not be removed at link time.
This function places a pointer to a block of at least the requested size in *base and returns the size of the block. 0 is returned if no such block can be returned, in which case the value stored at *base is never used.