When linking for the AVR ATMega88 the gcc driver adds an option -Tdata=0x800100
to ld that makes it impossible to move the .data section to a different
location. For example, trying to reserve some SRAM for a bootloader with 

avr-gcc -g -Wall -Os -mcall-prologues -mmcu=atmega88
-Wl,-Map,main.map,--section-start,.data=0x800200 -o main.elf main.o

GCC calls ld as following:

/usr/lib/gcc/avr/4.1.0/../../../../avr/bin/ld -m avr4 -Tdata 0x800100 -o
main.elf /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm88.o
-L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/lib/gcc/avr/4.1.0/avr4
-L/usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4 -Map main.map --section-start
.data=0x800200 main.o -lgcc -lc -lgcc

and in main.map we see that .data is still at default location:

.data           0x00800100       0x78 load address 0x00000802

When run with -mmcu=atmega8, ld is run correctly with

/usr/lib/gcc/avr/4.1.0/../../../../avr/bin/ld -m avr4 -o main.elf
/usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
-L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/lib/gcc/avr/4.1.0/avr4
-L/usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4 -Map main.map --section-start
.data=0x800200 main.o -lgcc -lc -lgcc


-- 
           Summary: Section .data cannot be moved with -mmcu=atmega88
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: e9fritte at etek dot chalmers dot se
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: avr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30417

Reply via email to