Linker script

Paul Whitfield paulw@microsol.iinet.net.au
Thu Jun 26 08:49:00 GMT 2003


Daniel Lidsten wrote:

> Hi,
> 
> I have a special problem that has to do with the linker script. In my
> application i want to add a CRC value to the binary image so that i can
> check the code segment for errors during runtime. I cannot put the CRC
> over the entire image since some segment are changing during execution
> so instead i want to calculate it based on the text segment only.
> However, the segment is of different size each time i link which means
> that i have to communicate the size to the CRC calcualtion routine. I
> think that it should be done in the linker script by something like
> this:
> 
>     .text   0x5000  :      { _stext = .; *(.text*) *(.gnu.warning)
> *(.gnu.linkonce*) *(.init) } >  ram  _etext = .;  PROVIDE 
> 
> The text segment specifies where the end is in the variable _etext.
> 
> I need the above value to be place on a fixed location by something like
> this:
> 
> .TextEnd   0x004DFFFC :      { etext }
> 
> The above dones work but can any see a way for this to work?

The address of _etext should be a global symbol that you can
access directly in your 'C' program. You need to
add a definition like

extern char _etext

And then you can take the address of it

I.e.

ptEndOfText = &e_test;


Hope that helps

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