23.3.2 Default Values for Minimum Stack and Heap Sizes

The next section of the default linker script provides default values for the minimum stack and heap sizes.

/*
 * Provide for a minimum stack and heap size
 * - _min_stack_size - represents the minimum space that must
 *                     be made available for the stack. Can
 *                     be overridden from the command line
 *                     using the linker's --defsym option.
 * - _min_heap_size  - represents the minimum space that must
 *                     be made available for the heap. Can
 *                     be overridden from the command line
 *                     using the linker's --defsym option.
 */
EXTERN (_min_stack_size _min_heap_size)
PROVIDE(_min_stack_size = 0x400) ;
PROVIDE(_min_heap_size = 0) ;

The EXTERN line ensures that the rest of the linker script has access to the default values of _min_stack_size and _min_heap_size assuming that the user does not override these values using the linker’s --defsym command line option.

The two PROVIDE lines ensure that a default value is provided for both _min_stack_size and _min_heap_size. The default value for the minimum stack size is 1024 bytes (0x400). The default value for the minimum heap size is 0 bytes.