My goal is to be able to monkeypatch a lot of my functions when I do a test build, while having regular behaviour for normal builds (linker error).
I know that I can use #pragma weak or __attribute__ (( weak)) in front of the functions I want to monkeypatch in the original module to say to the linker: "this function is monkeypatchable".
But this would destroy the normal behaviour in the regular build. Instead I would like something to put in the new module, like #pragma this_is_the_one_definition. Which would then make the linker choose this definition whatever the next functions and modules he check after.
They are ways around (Set GCC default attribute for all functions (get all function symbol to be weak for monkeypatching)), but it feel wrong from me to do that. Is there really no way to force a linker to stick to one definition? It seem weird to me that this feature would not have been considered doable/usefull, but in the other end the whole weak symbol stuff had been implemented.