How the compiler works (in a simple explanation)
The most popular C ++ compilers (e.g. GCC) work by translating all C ++ codes (and Obj-C, C, etc.) into ASM.
Then it calls the appropriate assembler for the target processor and creates the binary files of the objects.
He then calls the linker, which looks in these binaries for symbols that explain what links are with what. The general optimization that linkers can perform is also a strip of final binary code from statically linked libraries that were not used, another general optimization does not try to link libraries that are not used at all.
Finally, the linker removes everything you need.
What does this mean in your case
You have a library, the library has anchor characters. You also have an executable file that has its associated characters removed, in fact, depending on how it was optimized, internal transitions can be just a couple of jmp commands for arbitrary addresses in the code. There is no machine, you can do what you want automatically, because you do not have the necessary information about the executable file.
How to do it anyway
You need to parse the executable file, independently indicate where the function calls are located, and then manually assemble it with your library, instead these functions will cause a transition to the addresses in your library.
This process is sometimes used by game mods to change the video drivers of old games (for example, to update the OpenGL version or to force the use of Glide games to use some newer drivers, etc.).
So, if you still want to do this (I warn you: this is absurd madness, though ...) ask these guys :) I donβt remember anyone pointing to you now, but they exist.
Analogy
When you are in the normal linking phase, the compiled object files are similar to the source code, which the machine understands, and makes function calls if necessary.
After compilation, all function calls became goto.
So, if you are a linker who is tasked with doing what you want to do, imagine that you will read the source code filled with goto in random places in the code (sometimes even inside loops) and somehow you need to draw some of you want to change them to go to the new part that you are trying to insert there.