ADVANCED FEATURES
OF SHARED LIBRARIES
The previous chapter covered the fundamentals of shared libraries. This chapter
describes a number of advanced features of shared libraries, including the following:
z dynamically loading shared libraries;
z controlling the visibility of symbols defined by a shared library;
z using linker scripts to create versioned symbols;
z using initialization and finalization functions to automatically execute code
when a library is loaded and unloaded;
z shared library preloading; and
z using LD_DEBUG to monitor the operation of the dynamic linker.
42.1 Dynamically Loaded Libraries
When an executable starts, the dynamic linker loads all of the shared libraries in
the program’s dynamic dependency list. Sometimes, however, it can be useful to
load libraries at a later time. For example, a plug-in is loaded only when it is
needed. This functionality is provided by an API to the dynamic linker. This API,
usually referred to as the dlopen API, originated on Solaris, and much of it is now
specified in SUSv3.