It seems that this version of the GCC does ignore __progmem__ attribute. Following code (but the same result for other vriable types) produces elf image with rotor array placed in .data section const uint8_t rotor[ANIMSTEPS] __attribute__((__progmem__)) = { ~(SEG_A)&SEG_MASK, ~(SEG_B)&SEG_MASK, ~(SEG_C)&SEG_MASK, ~(SEG_D)&SEG_MASK, ~(SEG_E)&SEG_MASK, ~(SEG_F)&SEG_MASK }; Where SEG_* are simple numeric defines. Below a fragment of the map file: .data 0x00800060 0x2c load address 0x00000604 0x00800060 PROVIDE (__data_start, .) *(.data) .data 0x00800060 0x2b display.o 0x00800078 rotor (AVR)Binutils version 2.14 GCC version: Reading specs from /usr/lib/gcc/avr/3.4.0/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c --disable-nls --target=avr i686-redhat-linux-gnu Thread model: single gcc version 3.4.0 20040206 (prerelease)
Created attachment 5722 [details] preprocessed testcase Command line was: avr-gcc -g -Wall -Os -mmcu=attiny26 -Wl,-Map,pgmtst.map -save-temps -o pgmtst test.c
Confirmed. The problem is that avr was depending on the order of the calls to avr_insert_attributes and the actually adding the attribute to the decl. It really should not depending on them at all.
Created attachment 5766 [details] "Fixes" __progmem__ attribute problem This patch has "fixed" the __progmem__ attribute problem for me when applied to a recent CVS pull of gcc: avr-gcc (GCC) 3.5.0 20040216 (experimental) I tried to take some educated guesses based on Andrew Pinski's comments, but I don't know the first thing about gcc internals, so beware.
AVR is not a primary platform, so I have postponed this until 3.4.1. The patch here is not quite right. I believe a correct patch would be to modify avr_insert_attributes to use avr_progrmem_p (node) || lookup_attribute ("progmem", *attributes) That would still find a progmem attribute already in the DECL_ATTRIBUTES, which the patch would not. If someone will test that change, such a patch would be OK for 3.4.0.
Created attachment 5845 [details] Fixes the bug This patch contains the suggestion from mmitchel, and it seems, that it works. I tested it with the supplied test.i attachment, as well with some other sources. Would be nice, it it can applied to the 3.4 branch.
According to comment #4 (by Mark Mitchell) he pre-approved a patch for this for 3.4 if tested ok. Oliver Schulz tested the patch and confirmed that this works on March 2. Mark, can this be approved and rolled into 3.4 please? Currently the AVR port is only good up to 3.3.2 (There's a showstopper for 3.3.3, see #14149). It would be disappointing if we had to wait for 3.4.1 to upgrade. Thanks Eric
The patch needs to go through a full "make bootstrap && make check" process. I can't tell if that's been done, or whether just the small program has been tested. If the full test process has been done, and it's been confirmed that there are no regressions, then it's OK to check in this change for GCC 3.4.
Being so tiny a microcontroller, I don't think "make bootstrap" is possible. I've heard that some AVR simulator is available, but I don't know if it's known to work with dejagnu to run gcc testsuite. (Well, I guess one could at least test gcc.c-torture/compile and such.)
Subject: Re: [3.4/3.5 Regression] __progmem__ attribute doesn't work kazu at cs dot umass dot edu wrote: > ------- Additional Comments From kazu at cs dot umass dot edu 2004-03-11 04:52 ------- > Being so tiny a microcontroller, I don't think "make bootstrap" is possible. > I've heard that some AVR simulator is available, but I don't know if > it's known to work with dejagnu to run gcc testsuite. > (Well, I guess one could at least test gcc.c-torture/compile and such.) If people using this tareget don't normally run DejaGNU, then the patch can be checked in with whatever testing would normally be done. If no testing is normally done, then just go ahead and commit the patch. :-)
The patch only affects 2 files in the config/avr subdir. Doesn't "make bootstrap" only apply to building native compilers? The avr port is always built as a cross compiler. ... Or do you need the "make bootstrap ..." to test that the changes done in config/avr don't affect any of the other ports (that are primary targets)? Also, a simulator is available, but it IIRC it doesn't run with dejagnu.
Denis and Marek: Could one of the AVR port maintainers please commit this approved patch for 3.4 as soon as possible, please? Thanks Eric Weddington
Would *anyone* with CVS write permissions please commit this approved patch for 3.4? Thanks Eric
Subject: Bug 14047 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: denisc@gcc.gnu.org 2004-03-13 06:38:12 Modified files: gcc : ChangeLog gcc/config/avr : avr.c avr-protos.h Log message: PR target/14047 * config/avr/avr.c (avr_progmem_p): Add "attributes" parameter. (avr_insert_attributes): Pass "attributes" to avr_progmem_p. * config/avr/avr-protos.h (avr_progmem_p): Change prototype. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.336&r2=2.2326.2.337 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.108.4.1&r2=1.108.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.31&r2=1.31.10.1
Subject: Re: [3.4/3.5 Regression] __progmem__ attribute doesn't work "eric at ecentral dot com" <gcc-bugzilla@gcc.gnu.org> writes: > ------- Additional Comments From eric at ecentral dot com 2004-03-12 04:13 ------- > Denis and Marek: > > Could one of the AVR port maintainers please commit this approved patch for 3.4 > as soon as possible, please? Committed as: 2004-03-13 Dean Ferreyra <dferreyra@igc.org> PR target/14047 * config/avr/avr.c (avr_progmem_p): Add "attributes" parameter. (avr_insert_attributes): Pass "attributes" to avr_progmem_p. * config/avr/avr-protos.h (avr_progmem_p): Change prototype. Denis.
Subject: Bug 14047 CVSROOT: /cvs/gcc Module name: gcc Changes by: denisc@gcc.gnu.org 2004-03-13 06:43:31 Modified files: gcc/config/avr : avr.c avr-protos.h Log message: PR target/14047 * config/avr/avr.c (avr_progmem_p): Add "attributes" parameter. (avr_insert_attributes): Pass "attributes" to avr_progmem_p. * config/avr/avr-protos.h (avr_progmem_p): Change prototype. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr.c.diff?cvsroot=gcc&r1=1.117&r2=1.118 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr-protos.h.diff?cvsroot=gcc&r1=1.31&r2=1.32
Fixed for 3.4.0.
Subject: Bug 14047 CVSROOT: /cvs/gcc Module name: gcc Changes by: denisc@gcc.gnu.org 2004-03-13 06:51:56 Modified files: gcc : ChangeLog Log message: PR target/14047 * config/avr/avr.c (avr_progmem_p): Add "attributes" parameter. (avr_insert_attributes): Pass "attributes" to avr_progmem_p. * config/avr/avr-protos.h (avr_progmem_p): Change prototype. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3154&r2=2.3155
Thanks, Denis! Eric