A quick followup on this avr-gcc bug:  

First, the bug was not fixed as of avr-gcc 4.0.3 (although the program I 
sent doesn't trigger it).

Second, notice that this bug happens with the compilation options that 
TinyOS 1.x and 2.x both use.  So be careful!

John



--
John Regehr, [EMAIL PROTECTED]
Assistant Professor, School of Computing, University of Utah

On Sun, 16 Apr 2006, John Regehr wrote:

> I seem to be running afoul of a bug in the avr-gcc that is packaged up
> with avr-gcc-3.4.3-1.i386.rpm.  The bug is nasty and results in indirect
> calls to neverneverland.
> 
> A program that trips this bug is attached.
> 
> Compiling like this:
> 
>   avr-gcc -Wall -mmcu=atmega128 -Os shifty.c -o shifty.elf
> 
> generates a program that icalls to a bad address.
> 
> If you have Avrora installed this command:
> 
> java avrora.Main -colors=false -simulation=sensor-network -mcu=atmega128
> -seconds=30 shifty.elf
> 
> will cause an exception in the simulator.
> 
> On the other hand, compiling the same program with -O instead of -Os
> results in correct code.
> 
> The problem occurs when the Z register is loaded with the address of
> foo().  In the buggy (-Os) version, the literal address of foo() is
> loaded.  This is wrong because the Atmega128 PC addresses 16-bit
> locations, in order to reach all 2^17 bytes of flash.  In the correct
> (-O) version, Z is loaded with 1/2 of the address of foo().
> 
> Just wanted to make sure this is known, it was not fun to track down.
> If a workaround exists I'd be happy to hear about it.
> 
> Thanks,
> 
> John Regehr
> 
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to