How initialize .data section

Massimiliano Guerra massimiliano.guerra@cmz.it
Mon Dec 1 15:43:00 GMT 2003


	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.



More information about the Binutils mailing list