Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a fix in one of the shared libraries (.so) in the project on linux?

I want to make a quick fix to one of the project's .so libraries. Is it safe to just recompile the .so and replace the original? Or I have to rebuild and reinstall the whole project? Or it depends?

like image 962
facha Avatar asked Sep 15 '11 11:09

facha


1 Answers

It depends. Shared library needs to be binary-compatible with your executable.

For example,

  1. if you changed the behaviour of one of library's internal functions, you probably don't need to recompile.
  2. If you changed the size of a struct (e.g. by adding a member) that's known by the application, you will need to recompile, otherwise the library and the application will think the struct is smaller than it is, and will crash when the library tries to read an extra uninitialized member that the application didn't write to.
  3. If you change the type or the position of arguments of any functions visible from the applications, you do need to recompile, because the library will try to read more arguments off the stack than the application has put on it (this is the case with C, in C++ argument types are the part of function signature, so the app will refuse run, rather than crashing).

The rule of thumb (for production releases) is that, if you are not consciously aware that you are maintaining binary compatibility, or not sure what binary compatibility is, you should recompile.

like image 133
Alex B Avatar answered Oct 01 '22 20:10

Alex B