Reputation: 143
I am writing a bare metal application and am running into an issue that I believe is related to the linker.
IRQ handler is not being linked from the static library provided. The IRQ is declared outside of the library with __attribute__ ((weak, alias("defaultInterrupt")))
. When this attribute is provided, the IRQ is not linked. When the attribute is removed, the IRQ is linked.
This post: Linking with static library not equivalent to linking with its objects indicates that the issue may be with the linker not finding the strong declaration because it stops searching, but does not suggest a fix.
Is there any way to ensure that the linker will find the strongly declared function?
I am using arm-none-eabi-ld distributed by ARM, found here: arm-none-eabi
Re-ordering the libraries passed to the linker
Upvotes: 4
Views: 1250
Reputation: 393
It appears that a similar question was asked quite some time ago in a galaxy not at all far away: Override weak symbols in static library
tl;dr;
The take away is that the weak
attribute doesn't apply as one would expect in static archive libraries. The linker stops searching at the first encounter of the target symbol name. The author of the accepted answer explains that weak
may only make sense for shared objects.
Upvotes: 1