This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cross debugger and load address (want download to VMA, not LMA)


toralf>> If not, is there any way to produce a version of the binary
	 with LMA = VMA for .text and .data, besides relinking with a
	 separate linker script?

You might want to try something like this: Note that the MY_ROM_START
is a SYMBOL - and it is not defined in the linker script, instead
define it on the linker command line.

>>   SECTIONS {
>>     . = MY_ROM_START;
>>     .vectors : { *(.vectors) }
>>     . = MY_TEXT_START;
>>    
>>     [snip]
>>   }

For info about the .vectors segment see:

>>   http://sources.redhat.com/ml/crossgcc/2004-03/msg00194.html
>>   http://sources.redhat.com/ml/crossgcc/2004-03/msg00195.html

Then, specify the value these symbols on the LINKER command line

>>  ld --defsym=MY_ROM_START=0x123456 --defsym=MY_LMA=0x654321 \
>>    --script=./MyLinkerScript 

The trick of this is: On the LD command line the --defsym statements
must occure *BEFORE* the --script option, not the other way around.

There are other helpful tricks you can do with --defsym too.

Some people like to tag date/time builds with the built in __DATE__
and __TIME__. PROBLEM: These sometimes end up in a stale .o file that
gets out of sync with real life. SOLUTION: Functionally equivlent
method on the linker command line is like this:

>>    ld ... options ... \
>>              --defsym __LINK_DATE__=`date +"0x%Y%m%d"` \
>>              --defsym __LINK_TIME__=`date +"0x%H%M%S"` \
>>              --defsym __LINK_TIMESTAMP__=`date +"%s"`

Or with GCC, you use these options:

>>    gcc ... options ... \
>>      -Wl,--defsym,__LINK_DATE__=`date +"0x%Y%m%d"` \
>>      -Wl,--defsym,__LINK_TIME__=`date +"0x%H%M%S"` \
>>      -Wl,--defsym,__LINK_TIMESTAMP__=`date +"%s"` \

You could also add a few others - much like your problem - of
different linked versions - DEBUG vrs FLASH...
    
>>    --defsym __BUILD_TYPE__=0x44454247
>> or --defsym __BUILD_TYPE__=0x464C5548

In this case, the hex numbers are ascii for DEBG and FLSH...

In your C code, you reference them like this:

>>   extern const char __LINK_DATE__[];
>>   extern const char __LINK_TIME__[];
>>   printf("BUILT: %08lx %08lx\n", 
>>		  (unsigned long)(&__LINK_DATE__[0]),
>>		  (unsigned long)(&__LINK_TIME__[0]) );

Or - insert them into variables like this:

>>     extern char __BUILD_TYPE__[];
>>
>>    unsigned long build_type = (unsigned long)(&__BUILD_TYPE__[0]));

-Duane.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]