Relocating Data Sections
Wood Mark
mjwood2@hotmail.com
Fri Aug 22 20:37:00 GMT 2003
I am writing a program to be used in an powerpc embedded system. I have
compiled the appropriate cross compiler and including binutils-2.13.92.
I am trying to place my .text section at 0xff400000. Since I can only load
to flash, I am also trying to load my .data section directly after my .text
section, but have it relocated to 0xe80000 during program initialization.
Upon reading the ld documentation, I was under the impression this could be
accomplished by using the AT command as follows:
--- start linker script ---
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
"elf32-powerpc")
OUTPUT_ARCH(powerpc)
PROVIDE (__stack = 0x00E00000);
MEMORY
{
flash : ORIGIN = 0xFF400000, LENGTH = 0xFFFFF
ram : ORIGIN = 0x00E80000, LENGTH = 0x7FFF
}
SECTIONS
{
.text : { *(.text) _etext = .; } > flash
.data : AT ( ADDR( .text ) + SIZEOF( .text ) )
{ _data = . ; *(.data); _edata = . ; }
}
--- end linker script ---
If I use this linker script, the resulting ELF file shows the LMA of the
.data section to be 0xff4041bc and the VMA of the .data section at
0x00e80000.
However, when I load this application on the hardware, before the code is
even run, I find the .data section at 0xe80000. Interestingly enough, it is
not located at 0xff4041bc as well. This is problematic because everything
at 0xe80000 is zeroed before execution by crt0. Am I wrong in believing
that crt0 is supposed to copy everything from the _etext through _edata and
place it at _data?
Thanks for any help,
Mark Wood
_________________________________________________________________
Get MSN 8 and help protect your children with advanced parental controls.
http://join.msn.com/?page=features/parental
More information about the Binutils
mailing list