avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] stack layout


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] stack layout
Date: Fri, 24 Jun 2005 07:16:36 +0200 (MET DST)

Torsten Mohr <address@hidden> wrote:

> Is it a bug that the stack is set to 0x10ff in __init?

It's some historic heritage that the stack is initialized twice.
I think this used to be intented for a transitional period, but
eventually never got removed.

It should probably only be initialized in the .init2 section, not in
main() itself.  Marek might tell that more exactly.

> Can i change the options somehow to _always_ use 0x8ff for the
> stack, also in __init?

I don't think so, not without changing either the startup code or the
compiler.  But why do you care?  The stack is not going to be used (at
least not by the code that is in the .initN sections by default) until
main() has started, so the different initialization in .init2 doesn't
hurt you.

> Shouldn't the startup code also refer to the symbol __stack?

The code in .init2 explicitly uses __stack, but that gets already
compiled into the object file itself, rather then deferred to the link
stage.  That looks like a bug to me.

> __stack seems to be only a symbol, not a section.  Would it make
> sense to define an own section for the stack, so some overlap
> checking could be done?

No, you cannot perform overlap checks for the stack anyway, at not
least useful ones.  The stack grows dynamically, so it's always the
programmer that needs to ensure it doesn't collide with anything else.
The compiler (or linker) has no notion of the size of the stack.  The
default setup is similar to the (historical) Unix model where stack
and heap are allowed to use the entire available RAM, growing towards
from different ends.  That's the best you could get anyways, and if
you as the programmer are changing that model, it's your
responsibility to ensure there's enough room for the stack.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]