Just create a file for the inserted code (make sure the implementation is out of line) ... the namespaces, class name and function should be the same as for the method you want to intercept. In the definition of your class, do not mention other methods that you do not want to intercept. Remember that LD_PRELOAD needs the full path to intercept the shared object.
For example, to intercept void X :: fn1 (), create the libx2.cc file with:
#include <iostream>
class X
{
public:
void X :: fn1 ();
};
void X :: fn1 () {std :: cout << "X2 :: fn () \ n"; }
Then compile it:
g ++ -shared -o libx2.so libx2.cc
Then run ala
LD_PRELOAD = `pwd` / libx2.so ./libx_client
Greetings
Tony delroy
source share