__user_setup_stackheap() sets up and returns the locations of the initial stack and heap.
If you define this function, it is called by the C library during program start-up.
__user_setup_stackheap() is called,
the same value it had on entry to the application. If this was set
to a valid value before calling the C library initialization code,
it can be left at this value. If
sp is not valid,
change this value before using any stack and before returning.
__user_setup_stackheap() returns the:
- Heap base, if the program uses the heap.
- In AArch32 state, register R0 contains the heap base.
- In AArch64 state, register X0 contains the heap base.
Stack base in
- Heap limit, if the program uses the heap and uses two-region memory.
- In AArch32 state, register R2 contains the heap limit.
- In AArch64 state, register X2 contains the heap limit.
If this function is re-implemented, it must:
- Preserve the registers required by the PCS, except for SP.
- Ensure alignment of the heap:
- In AArch32 state, maintain 8-byte alignment of the heap by ensuring that the heap base is a multiple of 8.
- In AArch64 state, maintain 16-byte alignment of the heap by ensuring that the heap base is a multiple of 16.
To create a version of
__user_setup_stackheap() that inherits
the execution environment and does not have a heap:
- In AArch32 state, set
r2to zero and return.
- In AArch64 state, set
x2to zero and return.
There is no limit to the size of the stack. However, if the
heap region grows into the stack,
to detect the overlapping memory and fails the new memory allocation request.
NoteAny re-implementation of
__user_setup_stackheap()must be in assembler.