[Top][All Lists]

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

[avr-gcc-list] Stack-allocated array bug

From: Cory Cross
Subject: [avr-gcc-list] Stack-allocated array bug
Date: Tue, 12 Apr 2011 20:35:16 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv: Gecko/20100918 Icedove/3.0.8

Hi all,

I've been running into several problems with avr-gcc from the Debian unstable repo which is at version 4.3.5. I am compiling for ATMega168. This problem was also present going back to compilers from 2007.

All the problems traced down to a stack-allocated array whose pointer ends up being set at or near 0x100 (whether that's over end of RAM or not, I'm not sure), which when written starts clobbering the .data section. But it only seems to happen in complex cases.

Contrary to the names of the files, I'm not sure whether the following demonstrates what I'm saying.

In clobber.lss lines 50&51, r28 is set to 0xFF and r29 to 0x04.
In no-clobber.lss on the same lines, the same occurs.

In clobber.lss, r12&r13 become the address for adc_readings[8].
In no-clobber.lss, r22&r23 become the address for adc_readings[8].

But the setup is different in the no-clobber case. In clobber.lss lines 107-110 differ from no-clobber.lss lines 102-104 even though I don't think they have to. This is the source of my problem I believe.

For now, I just can't have stack-allocated arrays :(.

Thanks for any help,

Attachment: clobber.c
Description: Text Data

Attachment: clobber.lss
Description: Text document

Attachment: no-clobber.c
Description: Text Data

Attachment: no-clobber.lss
Description: Text document

Attachment: Makefile
Description: Text document

reply via email to

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