How to control location of startup code?
Duane Ellis
duane@franklin.com
Wed Mar 31 14:11:00 GMT 2004
>> Is there any way to control how the default startup code ends up in
the output file/the virutal address it gets and/or what output
section it's included in?
I do it by putting it in a seperate segment. More specifically, I have
my own "crt0.s" it contains the reset vector and other IRQ like things
below is the relavent snippit in ARM assembly
>> .section .vectors
>> .global reset_vector
>> .type reset_vector,function
>> reset_vector:
>> ldr pc,_Handle_RESET
>> ldr pc,_Handle_SWI
>> ldr pc,_Handle_PFA
>> ldr pc,_Handle_DA
>> ldr pc,_Handle_NOTUSED
>> ldr pc,_Handle_IRQ
>> ldr pc,_Handle_FIQ
>> vector_end:
>> .size reset_vector,vector_end - reset_vector
>> _Handle_RESET:
>> .word Handle_RESET
>> _Handle_SWI:
>> .word Handle_SWI
>> _Handle_PFA:
>> .word Handle_PFA
>> _Handle_DA:
>> .word Handle_DA
>> _Handle_NOTUSED:
>> .word Handle_NOTUSED
>> _Handle_IRQ:
>> .word Handle_IRQ
>> _Handle_FIQ:
>> .word Handle_FIQ
Then, in the linker script I do this:
>> SECTIONS
>> {
>> . = 0x0000;
>> ROM_START = .;
>> .vectors : { *(.vectors) }
>> . = 0x1000; /* code starts at 4K */
>> .text : { *(.text) }
>> ... and so forth ....
The *PROBLEM* with this is by default the '.vectors' segment is not
tagged as loadable perhaps there is a way to do this in GAS, it was
not obvious to me.
Result is - various tools skip/ignore this segment and it does not
get downloaded to the target.
I solve it via OBJCOPY like this:
arm-elf-objcopy --set-section-flags .vectors=alloc,contents,load,readonly,code INFILE.axf OUTFILE.axf
-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
More information about the crossgcc
mailing list