Other meanings of Linker (computing)
Computer Science
A linker is a system program that combines one or more object files—produced by a compiler or assembler—into a single executable program or library, resolving symbolic references and relocating code and data to final memory addresses.1 It is a critical step in the software build process, bridging the gap between compilation and execution. Linkers also handle tasks such as symbol resolution, address binding, and the merging of sections, and they support various output formats including executables, shared libraries, and loadable modules.2
The linker's primary role is symbol resolution: it matches each symbol reference (e.g., a function call or global variable) to its definition, either in the same object file or in an external library.1 It then performs relocation, adjusting absolute addresses in the code and data to reflect the final memory layout, since object files typically use relative or zero-based addresses.2 The linker also merges sections (e.g., .text, .data) from multiple object files into a single output, and it may perform dead code elimination to remove unused functions.
Linkers can operate in two modes: static linking, where all code is copied into the executable at build time, and dynamic linking, where shared libraries are loaded at runtime, reducing disk and memory usage.3 Dynamic linking introduces complexities such as symbol interposition and versioning, which the linker must manage.
The first linkers appeared in the 1950s as part of early assemblers, which combined multiple assembly-language modules into a single program. By the 1960s, with the rise of high-level languages like FORTRAN and COBOL, linkers became separate tools, enabling separate compilation of source files. The 1970s saw the introduction of dynamic linking in systems like Multics and later Unix, allowing libraries to be shared across processes.4
Modern linkers, such as GNU ld and LLVM's lld, support complex features like link-time optimization (LTO), where the linker performs whole-program analysis and optimization across object files, and incremental linking, which speeds up development by relinking only changed modules.5 The development of standardized object file formats, such as COFF and ELF, has been crucial for interoperability.
Linkers are classified by their output: executable linkers produce runnable programs, while library linkers create static or shared libraries. Static libraries (e.g., .a files) are archives of object files that are extracted and linked into the executable; shared libraries (e.g., .so or .dll) are linked at runtime, with the linker generating a dynamic symbol table and relocation records.3
Specialized linkers exist for embedded systems, which may perform partial linking to combine object files into a single relocatable module, and for operating system kernels, which link the kernel image at a fixed address. Cross-linkers, which run on one platform but target another, are essential for embedded development.2 Additionally, linkers for managed languages like Java and .NET use a just-in-time (JIT) approach, but they still perform linking-like resolution at runtime.
One obscure but critical function is link-time garbage collection, which removes unused sections to reduce binary size, a feature used in embedded systems and mobile apps.5 Another is the handling of symbol versioning, as in glibc, where the linker selects specific versions of functions to maintain backward compatibility.
Linkers also play a role in security: they can randomize the layout of the executable (ASLR) and enforce control-flow integrity by inserting checks. The concept of "linker scripts" allows fine-grained control over memory layout, often used in kernel and embedded development. Historically, linkers were used to "overlay" programs, allowing large programs to run in limited memory by swapping code segments. Finally, the term "linker" is sometimes confused with "loader," but the loader is a separate component that loads the executable into memory and performs dynamic linking at runtime.4
Linkers are fundamental to software development, enabling modular programming and efficient code reuse.
Help improve the encyclopedia. Reports go straight to the site manager.