Please explain __StackLimit & __HeapLimit gcc.ld
This dummy section at the end of all other sections helps me to verify there's enough remaining space in RAM to avoid stack would run into heap by setting appropriate values in MIN_HEAP_SIZE and MIN_STACK_SIZE
._user_
. = ALIGN(4);
. = . + _MIN_HEAP_SIZE;
. = . + _MIN_STACK_SIZE;
. = ALIGN(4);
} >RAM
gcc.ld seems to use a different mechanism that I don't understand (note I stripped some lines of what I believe is not relevant for my question/this discussion).
How do __HeapLimit and __StackLimit get their (max-) value so that the ASSERT might go off and warn during compile & link time?
I mean, the compiler nor linker will ever put things inside *(.heap*) or *(.stack*), right? So that the size of these sections at link time is always zero. Thus __StackLimit remains __StackTop, the very end of RAM. If none of the section before .heap fill up RAM, this assert would not trigger? What am I missing?
.heap (COPY): {
*(.heap*)
__HeapLimit = .;
} > RAM
.stack_dummy (COPY): {
*(.stack*)
} > RAM
/* Set stack top to end of RAM, and stack limit move down by size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- franchan
- Solved:
- Last query:
- Last reply: