7.1.4 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:

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$$ZI$$Base and Image$$ARM_LIB_STACKHEAP$$ZI$$Limit.

Note:

If you re-implement __user_setup_stackheap(), this overrides all library implementations.
Non-ConfidentialPDF file icon PDF versionARM DUI0474M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.