[Top][All Lists]

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

[avr-gcc-list] Re: avr-gcc code generation and initialization of the re

From: Theodore A. Roth
Subject: [avr-gcc-list] Re: avr-gcc code generation and initialization of the return stack
Date: Wed, 5 May 2004 08:43:17 -0700 (PDT)

On Wed, 5 May 2004, Torleif Sandnes wrote:

> Hi.
> While adding debug support for avr-gcc elf/dwarf object files in AVR Studio, 
> we
> have come upon a problem with some of the code generated by avr-gcc.
> Quoting an e-mail from my colleague Svenn-Ivar:
> > It seems like the main function does an re-initialization of the return
> > stack (SPL/SPH). Actually, the new JTAGICE mkII expects the stack pointer
> > not to be modified this way apart from in the system startup-code, or the
> > single-stepping mechanisms wont work. The avr-gcc does set up the stack
> > properly in the startup-code, so I dont clearly see why it's done over again
> > in 'main'.
> Do any of you know why the stack is reinitialized this way?
> Can gcc's code egeneration be changed to not reinitialize the return stack?

I don't know the history of having main() initial the stack but removing
it has been discussed on the list before. It just hasn't been done by
the gcc maintainers. Changing it would also require changes to gdb
prologue scanner, but that's not really a big deal.

I'm a bit concerned that the mkII works like this. It seems to be
imposing an arbitrary restriction on how end users can write their
programs. There shouldn't be any reason that a program that doesn't even
have a main() or even startup code (e.g. a pure asm program that doesn't
even use the stack) can't be stepped through (by instruction). I've done
this with gdb/avarice/jtagice.

Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden

reply via email to

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