Discussing how compilers, links and loaders work and the benefits of shared libraries.
Loading Shared Libraries from Applications
Shared libraries can be loaded from applications even in the middle of their executions. An application can request a dynamic linker to load and link shared libraries, even without linking those shared libraries to the executable. Linux, Solaris and other systems provides a series of function calls that can be used to dynamically load a shared object. Linux provides system calls, such as dlopen, dlsym and dlclose, that can be used to load a shared object, to look up a symbol in that shared object and to close the shared object, respectively. On Windows, LoadLibrary and GetProcAddress functions replace dlopen and dlsym, respectively.
Tools for Manipulating Object Files
Here's a list of Linux tools that can be used to explore object/executable files.
-
ar: creates static libraries.
-
objdump: this is the most important binary tool; it can be used to display all the information in an object binary file.
-
strings: list all the printable strings in a binary file.
-
nm: lists the symbols defined in the symbol table of an object file.
-
ldd: lists the shared libraries on which the object binary is dependent.
-
strip: deletes the symbol table information.