I have built a static library (*.a for gcc, *.lib for keil). One of its source file, compiled into library, contains definition of RADIO_IRQHandler. An excerpt from this source file, called "ral_irq_handlers.c", is below:
...
void ral_symbol_import(void) //dummy function
{
return;
}
...
void RADIO_IRQHandler(void)
{
...
}
...
This IRQ symbol definition should override the weak definition which is declared in startup file. The startup file is not compiled into any static library and is just a regular file inside the project.
An excerpt of arm_startup_xxx.s file (keil toolchain) is below:
Default_Handler PROC
...
EXPORT RADIO_IRQHandler [WEAK]
...
...
RADIO_IRQHandler
...
B .
ENDP
ALIGN
An excerpt of similar gcc_startup_xxx.s file (gcc toolchain) is below:
.globl Default_Handler
.type Default_Handler, %function
Default_Handler:
b .
.size Default_Handler, . - Default_Handler
.macro IRQ handler
.weak \handler
.set \handler, Default_Handler
.endm
...
IRQ RADIO_IRQHandler
...
.end
Then I observed a strange behaviour. When I use any API function from "ral_irq_handlers.c" source file (compiled into library) inside one of the project source files, the linking is done correctly. Example:
...
int main(void)
{
ral_symbol_import();
...
}
...
However, if I don't use any API function of "ral_irq_handlers.c" source file, the linker cannot find the RADIO_IRQHandler symbol defined in my library. Can I somehow do this without this ugly hack (calling the dummy function to force correct linking)?
I would like to modify only the library code without touching the startup files.