Initialised Data

Paul Whitfield paulw@microsol.iinet.net.au
Thu Jan 16 06:40:00 GMT 2003


Nicolas Moreau wrote:
> Hi
> 
> I am trying to understand the logic behind the initialised data segment.
> I understand that, the values should be copied from ROM to RAM by crt0.s on startup, the values normally sit after the text section.
> What gets me really confused is that in my current build where my linker script says:
> . = 0xC0000000;
> .data : 
> { 
> 	__data_start__ = .;
> 	*(.data) 
> 	__data_end__ = .;
> } 
> The actual values are put in 0xC0000000, my text stops at around 0x00600000.
> This has been working fine with GDB, but now that I am trying to build a binary image, objcopy complains that it can't write at 0xc0000000 (which is normal). So to create my binary image to load into the system, I have to relocate the data segment to the end of text using objcopy.
> This works but sounds very awkward, can someone tell me how this should be done ?
> Thanks
> 
> Nic

This is done in the linker script using the "AT" instruction

Here is an example:

    .data :
    AT ( ROM_ADDRESS )

This should put a copy of the .data in your rom at ROM_ADDRES

Hope that helps... see the LD documentation for more information.

Regards

Paul



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list