Loading at startup
For ELF programs on Linux, the dynamic linker locates required shared objects, prepares execution and starts the program. Libraries can depend on other libraries, creating a dependency graph.
A name without a pathname is searched using configured directories, environment settings, the system cache and defaults. DT_RUNPATH and older DT_RPATH differ in how searches extend to indirect dependencies.
References: [1]
Explicit loading and symbol binding
A program can explicitly load an object with dlopen and use its handle for subsequent symbol lookup. This supports optional modules beyond dependencies loaded at startup.
RTLD_NOW resolves the relevant undefined symbols before returning. RTLD_LAZY can defer function-reference binding until use, but variable references are bound immediately; missing symbols can consequently surface at different stages.
References: [2]
Dependencies and unloading
dlclose releases a loader reference, but success does not guarantee immediate removal: another loaded object may still require the library. Releasing a handle and removing the last dependency are distinct.
Dynamic linking does not ensure interface compatibility. Linux also ignores some loader-related environment variables in secure-execution mode, limiting how ordinary environment settings can redirect protected programs’ dependencies.