Providing stack in the linker scripts

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all!

I have been reading the linker scripts provided with the AVRFreaks distro ov avr-gcc and I was wondering about the settings for the stack.

All the linker scripts define the stack from the top of the memory and downwards.

Are there no definitions describing the size of the stack?

How do one determine if a stack overflow occurs?

This must be an issue if one uses malloc and free.

Best Regards
Geir Tore Olsen

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are no stack boundaries. The compiler will not automatically include stack checking code in your program. So the stack may grow into the variable space and will be mixed up and
if the controller seems to become more and more unstable the more code you add, that means that more and more variables are overwritten by stack entries and if the controller crashes, the variables have overwritten a return address on the stack. Then it is time to get a controller with more memory so that there is more room between the beginning of the stack and the variables.

Ciao

Tobi