This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
How initialize .data section
- From: Massimiliano Guerra <massimiliano dot guerra at cmz dot it>
- To: "'binutils at sources dot redhat dot com'" <binutils at sources dot redhat dot com>
- Date: Mon, 1 Dec 2003 16:47:49 +0100
- Subject: How initialize .data section
- Organization: CMZ SISTEMI ELETTRONICI S.r.l.
- Reply-to: "massimiliano dot guerra at cmz dot it" <massimiliano dot guerra at cmz dot it>
Hello I'm a novice with the LD GNU Linker.
My problem is how initilize the .data section at the runtime.
I know that there are many examples for do this from ROM using the
AT() directive.
But my problem is different!
My problem is that I needs to create a copy Image (a clone) of the content of the .data
section at address less than the .data section itself. I must to create my FMW
in a single RAM image. I use the ELF format for PPC.
The solution is to use the follow linker script:
>>>
MEMORY
{
ram : org = 0x100000 , len = 31M
}
SECTIONS {
.text ALIGN( 4 ):
{
_ftext = .;
* (.text)
} > ram
.initdata ALIGN( 8 ):
{
_finitdat = .;
* (.initdat)
_einitdat = .;
} > ram
.rodata ALIGN( 8 ):
{
_frodata = .;
* (.rodata)
* (.rodata.*)
* (.tls)
* (.lit)
_erodata = .;
} > ram
_etext = .;
.data ALIGN( 8 ):
{
_fdata = . ;
* (.data)
_edata = . ;
_fsdata = .;
* (.rosdata)
* (.sdata)
_esdata = .;
_fsdata2 = .;
* (.rosdata2)
* (.sdata2)
_esdata2 = .;
} > ram
.bss ALIGN( 8 ):
{
_fbss = . ;
* (.bss)
_ebss = . ;
_fsbss = .;
* (.sbss)
_esbss = .;
_fsbss2 = .;
* (.sbss2)
_esbss2 = .;
} > ram
.heap ALIGN( 8 ):
{
_fheap = . ;
* (.heap)
_eheap = . ;
} > ram
.stack ALIGN( 8 ):
{
_fstack = . ;
* (.stack)
_estack = . ;
_esram = . ;
} > ram
}
<<<
But how I can procede for build inside the ".initdata" section the whole content of the
".data" section.
The problems are:
1) How to reserve inside the ".initdata" section an amount of space equal to the ".data".
This is impossible because the linker can't know the size of the ".data"section before to
link it !?!
2) How to copy the content of the ".data" section inside the ".initdata" section.
I think isn't possible to resolve my problem via linker scripts. It's correct ??
I think is better to modify the sources of the LD and then clone the .data section in the finla Link
and then build the ".initdata" section. But how I can procede for do this ??
Please help me :-(
Best regards
MaxG.