I have a precompiled library. It contains some function, let's consider functions A() and B(). B() calls A() inside this library. I would like to link my own code with this library, replacing all calls of B() with my own C() function that will itself call B().
So, instead of A -> B I need to get A -> C -> B, where C is my own function.
In other words, I want to do (semantically): _original_B = B B = C C() { _original_B() }
It is also ok to just replace B by C without calling original B.
Is it possible using segments manipulations or something else?
I fact I found that it is possible. Here is the solution.
I forced Keil to place function B that I wanted to substitute at specific location. Then I forced new function C to be placed at the same location. It generated a warning about overlay, but finally C was placed instead of B, B was deleted and all references from A to B pointed to C.