I'm developing a static library (libfb.a) file which contains multiple implementations of two functions:
void foo() { ... }
.void bar() { ... }
.void foo() { ... }
and void bar() { ... }
.All the 3 implementations (...
) are different, because if both foo and bar are needed, both of them can be implemented more efficiently, using each other.
How can I combine the .o files to an .a file for which GNU ld would do automatic selection, i.e. gcc prog.c libfb.a
will
I was trying to do it using weak symbols and weak aliases, but it didn't work. Maybe it's not possible. Any ideas how it can be done?
Repeating @A.Monti's comment as an answer.
It's not possible. You can't detect when prog.c calls both foo and bar using the available primitives.