Other meanings of Dynamic linker
Computer Science
A dynamic linker is a program that loads and links shared libraries at runtime, resolving symbols and relocations when a program starts or when libraries are loaded on demand. It is a core component of modern operating systems, enabling code reuse, smaller executables, and runtime extensibility.
The dynamic linker, often invoked as ld.so on Unix-like systems, runs before the main program's entry point. It reads the executable's dynamic section, loads required shared libraries into memory, and resolves symbol references (e.g., function calls) to their definitions in those libraries. This process is called dynamic linking or runtime linking.
It also handles relocations—adjusting addresses in code and data to reflect where libraries are loaded. Modern linkers support lazy binding, where symbol resolution is deferred until the first call, improving startup performance. The linker maintains a global symbol table and uses a hash table for efficient lookup.
Dynamic linking emerged in the 1960s with systems like Multics, which used dynamic linking for system libraries. Early Unix systems used static linking, but by the 1980s, SunOS introduced shared libraries with a dynamic linker. The ELF format, standardized in the late 1980s, became the basis for most modern Unix-like systems.
Windows uses a similar mechanism with its Portable Executable (PE) format and the ntdll.dll loader. The dynamic linker has evolved to support features like symbol versioning, thread-local storage, and security hardening such as RELRO (RELocation Read-Only) and ASLR (Address Space Layout Randomization).
Beyond basic loading, the dynamic linker supports interposition, allowing a library to override symbols from another, which is used by tools like LD_PRELOAD for debugging or instrumentation. It also handles constructor and destructor functions, executing initialization code in libraries.
On Linux, the dynamic linker can be invoked manually with ld.so to run a program with custom library paths. The dlopen and dlsym functions allow programs to load libraries at runtime and look up symbols, enabling plugin architectures. Some systems use static-pie executables that combine static and dynamic linking for security.
Dynamic linking introduces security risks, such as library hijacking via LD_LIBRARY_PATH or LD_PRELOAD. Modern systems mitigate these with secure execution modes, stripping environment variables for setuid programs. RELRO and GOT (Global Offset Table) hardening prevent certain attacks.
Performance overhead is minimal but non-zero; lazy binding reduces startup cost but can cause runtime delays. The linker's hash table and caching (e.g., ld.so.cache) speed up library lookup. On some systems, prelinking precomputes relocations to further reduce startup time.
Dynamic linking is a fundamental mechanism in modern operating systems, balancing flexibility and performance.
Help improve the encyclopedia. Reports go straight to the site manager.