2023-07-12 02:28 PM
Hi,
I'd like to create a library for fast handling the USART2 and TIMER. Unfortunately, when I move the USART2_IRQHandler() to the library, the linker do not include this function in a final application, and the program crashes by ending up in the endless loop of the Default_Handler. When I move the function back to main.c or other file within a target project - it works. How to update the interrupt vector table for external function?
Cheers,
Mike
Solved! Go to Solution.
2023-07-18 06:20 AM - edited 2023-07-18 06:21 AM
The issue is already solved - extern "C" was missing in the library code.
2023-07-12 06:26 PM
What functions are you using that would cause the library to be pulled in?
Are the library components being build from .cpp files or compiled as C++?
How is the project aware of the library?
2023-07-12 11:04 PM
This is a toolchain-specific issue, so I am now assuming you are using a gcc suite i.e. the binutils ld linker.
The weak/(strong) mechanism is an afterthough and a not that well thought out too; and then the way how the linker treats them is not well defined either. ld treats objects in libraries differently from "plain" objects and simply ignores the weak marker when it links libraries, see e.g. here.
JW
2023-07-13 12:53 AM - edited 2023-07-13 12:54 AM
> when I move the USART2_IRQHandler() to the library, the linker do not include this function in a final application
IMHO this is only to the better. Define a custom function name for your library and call it from USART2_IRQHandler in your app source - similar to how cube-generated code calls HAL libraries.
2023-07-18 06:20 AM - edited 2023-07-18 06:21 AM
The issue is already solved - extern "C" was missing in the library code.
2023-07-18 08:04 AM
Thanks for coming back with the solution... so @Tesla DeLorean was right that you're using C++...
JW