Given this:
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP ; Reserved Vector ; LDR PC, IRQ_Addr LDR PC, [PC, #-0x0120] ; Vector from VicVectAddr LDR PC, FIQ_Addr Reset_Addr DCD Reset_Handler Undef_Addr DCD Undef_Handler SWI_Addr DCD SWI_Handler PAbt_Addr DCD PAbt_Handler DAbt_Addr DCD DAbt_Handler DCD 0 ; Reserved Address IRQ_Addr DCD IRQ_Handler FIQ_Addr DCD FIQ_Handler Undef_Handler B Undef_Handler SWI_Handler B SWI_Handler PAbt_Handler B PAbt_Handler DAbt_Handler B DAbt_Handler IRQ_Handler B IRQ_Handler FIQ_Handler B FIQ_Handler
I want to modify it to use an external version of SWI_Handler IFF it exists.
I could add an IMPORT SWI_Handler directive and comment out the SWI_Handler B SWI_Handler line, but that doesn't do it automatically.
I would like to use the default looping SWI_Handler if no other code has an EXPORT SWI_Handler.
Can this be done nicely?
Many thanks, David
Typically we recommend leaving the startup file as is. You could try the change you mentioned, as long as you are careful.
I assume you are using Arm Compiler 5 (ARMCC). If so, Another thing to try is using $$super$$ to replace the handler, at link time. See:
developer.arm.com/.../use-of--super---and--sub---to-patch-symbol-definitions