ATmega2560 and gcc __prologue_saves__

View: New views
5 Messages — Rating Filter:   Alert me  

ATmega2560 and gcc __prologue_saves__

by Stu Bell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I've stumbled across another problem with ATmega2560 support.  Although
the problem is triggered from avr-libc, I believe this to be a gcc
problem.

I'm trying to use the rand() function.  The function that calls rand()
is close to the 128K flash boundary in lower flash, and the rand()
function (and practically all of the std library) is placed above the
128K boundary.

The compiler generates a direct CALL to the rand() function.  So far, so
good.  Then, the rand() function calls do_rand(), defined in the
avr-libc rand.c file.  Again, so far, so good.

Then the do_rand() calls __prologue_saves__.  That function saves the
appropriate registers, but then assembles an EIJUMP without setting the
proper value in EIND.  This wouldn't matter on anything *but* an
ATmega2560.  On my code, EIND = 0 (because I've never made an EICALL to
set EIND = 1) so the code jumps into lower flash and I'm dead.

I *assume* (yeah, bad that) that the _prologue.* file is under the
jurisdiction of GCC since I was unable to find it in the avr-libc
source.  But then, I could be smoking something wonderful and
hallucinating badly.

I don't have a test case (yet), but will generate one if/when asked.  I
can also give my current disassembled code of these three areas, if
anyone is interested.

Best regards,

Stu Bell
Senior Software Engineer
DPHI, Inc. (DataPlay)



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: ATmega2560 and gcc __prologue_saves__

by Anatoly Sokolov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.

> I've stumbled across another problem with ATmega2560 support.  Although
> the problem is triggered from avr-libc, I believe this to be a gcc
> problem.
>
> Then the do_rand() calls __prologue_saves__.  That function saves the
> appropriate registers, but then assembles an EIJUMP without setting the
> proper value in EIND.  This wouldn't matter on anything *but* an
> ATmega2560.  On my code, EIND = 0 (because I've never made an EICALL to
> set EIND = 1) so the code jumps into lower flash and I'm dead.

This bug fixed in GCC mainline:

Patch AVR: fix call prologue saves for avr6 - commited.
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01611.html

Anatoly.
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: ATmega2560 and gcc __prologue_saves__

by Weddington, Eric-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
> org] On Behalf Of Stu Bell
> Sent: Monday, July 14, 2008 1:21 PM
> To: avr-gcc-list@...
> Subject: [avr-gcc-list] ATmega2560 and gcc __prologue_saves__
>
> Hi all,
>
> I've stumbled across another problem with ATmega2560 support.
>  Although
> the problem is triggered from avr-libc, I believe this to be a gcc
> problem.
<snip>

*sigh*. Yes, prologue/epilogue code is generated in GCC. Yes, this
sounds like a GCC problem.

Please fill out a GCC bug report. Add me to the CC list.

Eric Weddington


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: ATmega2560 and gcc __prologue_saves__

by Weddington, Eric-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
> org] On Behalf Of Anatoly Sokolov
> Sent: Monday, July 14, 2008 1:36 PM
> To: Stu Bell; avr-gcc-list@...
> Subject: Re: [avr-gcc-list] ATmega2560 and gcc __prologue_saves__
>
> Hello.
>
> > I've stumbled across another problem with ATmega2560
> support.  Although
> > the problem is triggered from avr-libc, I believe this to be a gcc
> > problem.
> >
> > Then the do_rand() calls __prologue_saves__.  That function
> saves the
> > appropriate registers, but then assembles an EIJUMP without
> setting the
> > proper value in EIND.  This wouldn't matter on anything *but* an
> > ATmega2560.  On my code, EIND = 0 (because I've never made
> an EICALL to
> > set EIND = 1) so the code jumps into lower flash and I'm dead.
>
> This bug fixed in GCC mainline:
>
> Patch AVR: fix call prologue saves for avr6 - commited.
> http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01611.html
>
> Anatoly.
>

Ok, so never mind with the bug report, Stu.


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: ATmega2560 and gcc __prologue_saves__

by Stu Bell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, everyone!  I figured it was fixed, just not available yet.

My workaround was to copy the rand source into my own source and rename
it.  I'll leave it that way for now.


Best regards,

Stu Bell
DataPlay (DPHI, Inc.)


-----Original Message-----
From: Weddington, Eric [mailto:eweddington@...]
Sent: Monday, July 14, 2008 1:41 PM
To: Anatoly Sokolov; Stu Bell; avr-gcc-list@...
Subject: RE: [avr-gcc-list] ATmega2560 and gcc __prologue_saves__

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
> org] On Behalf Of Anatoly Sokolov
> Sent: Monday, July 14, 2008 1:36 PM
> To: Stu Bell; avr-gcc-list@...
> Subject: Re: [avr-gcc-list] ATmega2560 and gcc __prologue_saves__
>
> Hello.
>
> > I've stumbled across another problem with ATmega2560
> support.  Although
> > the problem is triggered from avr-libc, I believe this to be a gcc
> > problem.
> >
> > Then the do_rand() calls __prologue_saves__.  That function
> saves the
> > appropriate registers, but then assembles an EIJUMP without
> setting the
> > proper value in EIND.  This wouldn't matter on anything *but* an
> > ATmega2560.  On my code, EIND = 0 (because I've never made
> an EICALL to
> > set EIND = 1) so the code jumps into lower flash and I'm dead.
>
> This bug fixed in GCC mainline:
>
> Patch AVR: fix call prologue saves for avr6 - commited.
> http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01611.html
>
> Anatoly.
>

Ok, so never mind with the bug report, Stu.


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
LightInTheBox - Buy quality products at wholesale price