0

I have a dynamically linked linux executable that uses shared libraries. One of those libraries has a function that is used by other functions in that library - the object code of that function is contained in this library. I would like to provide alternative implementation of that function, so that instead of calling the original code that is in the library, those other functions would call my code.

Any way to do it?

  • 1
    Not without recompiling the library; unless the function allows functors or polymorphism.. – Svalorzen Jul 09 '14 at 15:32
  • If you can use LD_PRELOAD you can provide an alternative implementation. You can read more about it in [this post](http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick) or on the [man page for ld.so](http://linux.die.net/man/8/ld.so). – RedX Jul 09 '14 at 15:34

1 Answers1

0

Cannot do it without compiling the library with new changes.

If those functions are global or static functions, definitely you have to recompile.

If those functions are virtual member functions and if your application/library has hooks/expandability or factory kind of thing to new a derived object to the applications you can change it.

Otherwise you have to recompile the library code.

Sujith Gunawardhane
  • 1,251
  • 1
  • 10
  • 24