Skip to content
Discussion options

You must be logged in to vote

Hi @VoltXd,

The purpose of setting a value different than 0 to STACK_SIZE is to "force" the linker to leave at least this exact amount of free space for stack growth. This is not required, but sometimes you want to make sure there is a decent amount of space free in the stack. For example, if your program has too many nested function calls. If the linker fails to fit a region of STACK_SIZE bytes in memory, you'll get an error message.

Example: suppose you have MEMORY_SIZE = 4 MB and STACK_SIZE = 2MB. If you write a program whose .text + .data sections total, say, 3MB, the linker will print an error message saying there is no space left for the stack.

As you noted, the .stack region does n…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@VoltXd
Comment options

Answer selected by VoltXd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants