[Top][All Lists]

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

Re: [avr-gcc-list] When does the Stack Frame Pointer (Y) get setup?

From: Bob Paddock
Subject: Re: [avr-gcc-list] When does the Stack Frame Pointer (Y) get setup?
Date: Tue, 3 Jul 2012 18:00:02 -0400

On Tue, Jul 3, 2012 at 2:21 PM, Weddington, Eric
<address@hidden> wrote:

> Avr-libc user manual, section on Memory Sections:
> http://www.nongnu.org/avr-libc/user-manual/mem_sections.html
> According to that, it looks like .init2.

I'm very familiar wit that section.  It says the stack pointer is set,
so call/returns can be used thereafter etc.
Beyond that it does not say anything about the frame pointer.  As all
of this .initX stuff is not standard C, other than bss being zeroed
before main() starts,
there may be no reason that the frame pointer should be valid at this
point, and this is simply a documentation issue that should have a
warning added.

> A disassembly of the whole program should allow you to verify what happens in 
> the .initX sections.

Did that, that is where the code I posted came from.
Looks to me like r28/r29 is set in .init2, however it does not seem to
be preserved until main() sets it again, then it is preserved there

> I'm not sure why your program doesn't seem to work...

It does not work because the code I posted is overwriting a structure
array that was initialized in an earlier .init8 section, and is now
filed with zeros because of the errant frame pointer.  Its not a
question of why my code is broken, but a question of should it be

All my, relevant to this issue, code is in C.   I'm not doing anything
with the registers.  Is the frame pointer guaranteed to be preserved
from the time it is set in .init2 until it is used in main(), across
all of the .initX sections (which are *not* proper functions with the
normal epilog/prologs that would push/pop the r28/r29 pair)?  It does
not look like it is from the listing, and certainly does not behave
like it is.  I make heavy use of the .initX sections, however only the
one has anything put on the stack, which is what I posted.


reply via email to

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