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:

LOAD_FLASH ...
{
    ...
    ARM_LIB_STACK 0x40000 EMPTY -0x20000  ; Stack region growing down
    { }
    ARM_LIB_HEAP 0x28000000 EMPTY 0x80000 ; Heap region growing up
    { }
    ...
}

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.

Note

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

See also

Reference

ARM C and C++ Libraries and Floating-Point Support User Guide:

Was this page helpful? Yes No