You copied the Doc URL to your clipboard.

Specifying stack and heap using the scatter file

The ARM C library provides multiple implementations of the function __user_setup_stackheap(), and can select the correct one for you automatically from information given in a scatter file.

To select the two region memory model, define two special execution regions in your scatter 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_setup_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 use a combined stack and heap region by defining a single execution region named ARM_LIB_STACKHEAP, with the EMPTY attribute. This causes __user_setup_stackheap() to use the value of the symbols Image$$ARM_LIB_STACKHEAP$$Base and Image$$ARM_LIB_STACKHEAP$$ZI$$Limit.


If you re-implement __user_setup_stackheap(), this overrides all library implementations.

See also


Developing Software for ARM® Processors:


Using ARM® C and C++ Libraries and Floating-Point Support:

Was this page helpful? Yes No