5.1.2. Specifying stack and heap using the scatter-loading description file
The ARM C library provides alternative implementations of the function __user_initial_stackheap(), and can select the correct one for you automatically from information given in a scatter-loading description file.
To select the two region memory model, define two special execution regions in your scatter-loading description file named ARM_LIB_HEAP and ARM_LIB_STACK. Both regions have the EMPTY attribute. This causes the library to select the non default implementation of __user_initial_stackheap() that uses the value of the symbols:
Image$$ARM_LIB_STACK$$Base
Image$$ARM_LIB_STACK$$ZI$$Limit
Image$$ARM_LIB_HEAP$$Base
Image$$ARM_LIB_HEAP$$ZI$$Limit
Only one ARM_LIB_STACK or ARM_LIB_HEAP region can be specified, and you must allocate a size, for example:
ARM_LIB_HEAP 0x20100000 EMPTY 0x100000‑0x8000 ; Heap starts at 1MB
; and grows upwards
ARM_LIB_STACK 0x20200000 EMPTY ‑0x8000 ; Stack space starts at the end
; of the 2MB of RAM
; And grows downwards for 32KB
You can force __user_initial_stackheap() to use a combined stack/heap region by defining a single execution region named ARM_LIB_STACKHEAP, with the EMPTY attribute. This causes __user_initial_stackheap() to use the value of the symbols Image$$ARM_LIB_STACKHEAP$$Base and Image$$ARM_LIB_STACKHEAP$$ZI$$Limit.
Note
If you re-implement __user_initial_stackheap(), this overrides all library implementations.