Linker Script Initialized Data

Ian Caddy ianc at microsol.iinet.net.au
Thu Jan 8 03:02:49 UTC 2004


Hi Brett,

The only thing to remember is that you still need to have your startup 
code, copy the data section into the correct space, not where it has 
been loaded.

Ian Caddy


Brett Swimley wrote:

> Thanks Ian for responding.  I was able to get similar functionality by 
> modifying the examples from the web link that I posted.  I think I'll 
> try your implementation however, as I like the fact that it is  
> completely contained within the linker script file.
> 
> Regards,
> 
> Brett
> 
> Ian Caddy wrote:
> 
>> Hi Leon,
>>
>> In the axample that I provided we copy the following variables.
>>
>> I just looked at my linkcmds and realised that I forgot an important 
>> line which shows where the ROM image (even though it is RAM) of the 
>> data region is: (in our file it is down at the end)
>>
>>
>> start_data_rom = LOADADDR(.data) ;
>>
>>
>> Then following the example you will need to copy the data region from 
>> start_data_rom to start_data and the length is (end_data - start_data)
>>
>> Each of these three variables is available to you in your C or 
>> assembler code but don't forget to define them as externs:
>>
>> extern UCHAR start_data;
>> extern UCHAR end_data;
>> extern UCHAR start_data_rom;
>>
>> in your code, the linker will resolve them as they are defined in the 
>> linkcmds.
>>
>> If you need any more help or if you would like the whole linker file 
>> jsut ask.  We use two different linkcmds, one for RAM loads and one 
>> for flash loads.  The flash loads are then copied into RAM on startup, 
>> whereas the RAM loads are just used for debugging with the BDM.
>>
>> Talk to you soon,
>>
>> Ian Caddy.
>>
>>
>> Leon Pollak wrote:
>>
>>> Thank you for the example, Ian.
>>>
>>> {...}
>>>
>>>> Our startup code in our bootloader will copy the data section into the
>>>> right place on startup.
>>>
>>>
>>>
>>>
>>> Just to fill the picture - where is the right place to copy to?
>>>
> 




More information about the users mailing list