adding a new section and make it start at address 0
Till Harbaum
harbaum@tm.uka.de
Wed Feb 5 18:19:00 GMT 2003
Hi list,
i am having a small problem and have been unable to solve it using google etc.
There's a port for the avr compiler of gcc called avr-gcc. This compiler suite
supports the eeprom memory of the avr by using a seperate section named
.eeprom for this. Data can be stored at compile time in this segment like
this:
short __attribute__((section (".eeprom"))) x = 1234;
And access to this segment is done via special functions to access the right
part of the eeprom. Using the address of x as an offset into the eeprom.
In order to allow tests and debugging on the pc, i'd like to be able to use
the exact same machanisms on the pc using gcc 3.2 to save data in a seperate
file.
What i am doing is, i put the data into a section called .eeprom as shown
above and tell the linker, that this section is to begin at offset 0:
gcc -Wl,--section-start=.eeprom=0x0 -o test test.o
The problem is, once i tell the linker to do this, it creates a new segment
called .eeprom and renames my old one to .eeprom.1. Objdump shows this:
0 .eeprom 00000000 00000000 00000000 00004200 2**0
CONTENTS
16 .eeprom.1 00000002 0804c0b0 0804c0b0 000040b0 2**1
CONTENTS, ALLOC, LOAD, DATA
My question now is: Why doesn't the linker use the new start address i supply
for my .eeprom section? How can i make it work on my existing section instead
of creating a new (empty and useless one) instead of creating a new section
and renaming my original one?
Thanks,
Till
More information about the Gcc-help
mailing list