This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

binutils: elf sections - copying from ROM to RAM.


target: powerpc-eabi
binutils: binutils-2.9.1.0.19a
cc: egcs-1.1.2
libc: newlib-1.8.1

I have a powerpc embedded system.  We currently use the DiabData
cross-compiler I have just ported all our application code to work with
gcc (powerpc-eabi-egcs-1.1.2 actually).   I have managed to get
everything to work when I load the code directly into DRAM via the BDM
debug port.  However, the code fails if I program it into flash and try
to run it.  I have tried to debug this and I believe the problem is that
I am not copying initialised data from ROM into RAM.

I have read the ld docs and it likes the AT section option is
appropriate and my startup code is copy from the initialised data
section in ROM to the initialised data section in RAM.  I am uncertain
as to which sections need to have the AT command so I took the approach
that all sections not in RAM should have the AT option.

The powerpc linker script (ads script taken from newlib-1.8.1) has
_many_ sections.  Is there some documentation describing the meaning and
use of all these sections (.interp, .hash, .dynsyn, .dynstr, .rela.text,
.rela.data, .plt, etc) ?

My linker script calculates of offset between ROM and RAM and uses this
for the address AT uses.
eg.
RomStart = 0xffe01000;
RamStart = 0x00001000;
loadOffset = RomStart - RamStart;
.text : AT(. + loadOffset) { ... }

I now get link error messages saying "Not enough room for program
headers (allocated 3, need 14)".
Where are the program headers supposed to live ?
Is this a good way to copy initialised data from ROM to RAM ?  Any
suggestions ?

The DiabData script uses a GROUP statement which encapsulates multiple
SECTION statements.
Is there something equivalent for gcc/ld ?
eg.
GROUP :
{
    .text : { *(.text) *(.init) *(.fini) }
    .sdata2 : {}
    .datarom : {. += ( SIZEOF(.data) + SIZEOF(.sdata) ); }
} > ROM

GROUP :
{
    .data LOAD( ADDR(.text) + SIZEOF(.text) + SIZEOF(.sdata2) ) {}
    .sdata LOAD( ADDR(.text) + SIZEOF(.text) + SIZEOF(.sdata2)
+ SIZEOF(.data) ) {}
    .sbss : {}
    .bss : {}
} > RAM

Brendan Simon.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]