Linux - Shared Library (so, sl)


so means shared object file and are shared library in Linux

There format is the Executable and Linkable Format.

As Shared Library, so files are open file opened by a process.

The shared library extension is operating system dependent:

  • .so for Linux, Solaris, or AIX,
  • .sl for HP-UX.


Search Path

When an executable is looking for a dynamic library (.so file), the linker searches in order:

  • in the directories listed in the LD_LIBRARY_PATH environment variable
  • in the directories listed in the executable's rpath. /usr/lib
  • directories on the system search path. For instance:


Dynamically linked libraries are typically placed in directories.

The usual directories include:

Path Description
/usr/lib Standard system libraries
/gnu/lib Gnu libraries
/lib/security PAM modules
/usr/X11R6/lib or /usr/openwin/lib X-windows
/usr/local/lib 3rd party libraries

On GNU glibc-based systems, including all Linux systems, the list of directories automatically searched during program start-up is stored in the file /etc/

cat /etc/

To control this process, you can use the LD_PATH environment variable (for instance: LD_LIBRARY_PATH for Linux/Solaris)

Content (Unpack)

readelf -a -W /path/To/SoFile



In an ELF file:

  • The version info in not explicitly stored . The full version is usually stored as a part of the library file name.
  • The soname contains the name of the library which includes the major version. If there was an API change, the library creator is supposed to change the soname. Multiple libraries can then be on a single system.


  • - The library file itself, containing the full version
  • - Symlink to, having the same name as soname
  • - Symlink to used for linking.

To get the soname:

readelf -d  /path/to/ | grep SONAME


The version is just to be found in the symbolic link.

libc below is the version 2.5

file /lib64/
/lib64/ symbolic link to `'

File System - ( Symbolic | ln | Soft) link - File Alias - Symlink - Junction - Reparse Points

# if it's a symlink symbolic link to `'
# if it's file ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

Load Test

dltest /path/to/


  • ldd (list dynamic dependencies) print shared library dependencies
ldd ../product/fmw/Oracle_BI1/bifoundation/odbc/lib/
ldd: warning: you do not have execution permission for `../product/fmw/Oracle_BI1/bifoundation/odbc/lib/' =>  (0x00007fff375c4000) => /lib64/ (0x00007f7bc07ba000) => /lib64/ (0x00007f7bc05b0000) => /u01/app/oracle/product/fmw/Oracle_BI1/bifoundation/odbc/lib/ (0x00007f7bc03ca000) => /u01/app/oracle/product/fmw/Oracle_BI1/bifoundation/odbc/lib/ (0x00007f7bbf7b9000) => /lib64/ (0x00007f7bbf5b4000) => /usr/lib64/ (0x00007f7bbf2d9000) => /lib64/ (0x00007f7bbf056000) => /lib64/ (0x00007f7bbecfd000) => /lib64/ (0x00007f7bbeaef000)
        /lib64/ (0x00000035bb600000)

List Shared Library used by processes

With the lsof

  • one process
lsof -p $(pgrep nqsserver) | awk '{print $9}' | grep .so$
  • all process from a root directory
lsof /path/to*

Find a shared library

sudo find / | grep
  • Example
sudo find / | grep


Example with Sqlite and an amalgam adapted from the Ref documentation

gcc \
-Wl,-soname, \
-shared \
-o \
-fPIC \

Documentation / Reference

Powered by ComboStrap