Linkers, Loaders & Executables
On Linux, when is the version number in a shared library's soname, such as the ".1" in libfoo.so.1, generally increased?
- AWhenever even one bug is fixed
- BWhen the library file is moved to another directory
- CWhen a change breaks ABI compatibility with old programs, such as altering function arguments or struct layouts
Show answer and explanation
Answer: C. When a change breaks ABI compatibility with old programs, such as altering function arguments or struct layouts
A dynamically linked program uses, at run time, the shared library named by its soname. A compatible fix keeps the same soname, so replacing the file updates every program. Changing argument types or struct sizes, however, would make old programs call with wrong assumptions, so the soname number is raised to treat it as a different library that can be installed alongside the old one.
- A. Compatible fixes keep the same number.
- B. Location has nothing to do with the version.
- C. Correct. It prevents old programs from picking up the incompatible version.