Generated by GPT-5-mini| ld | |
|---|---|
| Name | ld |
| Developer | Various (originally AT&T/Bell Labs; GNU Binutils; LLVM Project) |
| Released | 1971 (original Bell Labs linker), 1989 (GNU ld) |
| Latest release | varies by implementation |
| Programming language | C, C++ |
| Operating system | Unix, Linux, FreeBSD, NetBSD, OpenBSD, Windows (via ports) |
| Platform | x86, x86-64, ARM, AArch64, MIPS, PowerPC, RISC-V |
| Genre | Linker / linker script processor |
| License | GNU General Public License, permissive licenses (implementation-dependent) |
ld ld is the conventional name for the linker utility used to combine object files into executable binaries, shared libraries, and other linkable formats. It is a core tool in toolchains used by projects such as GCC, Clang, GNU Make, Autoconf, and CMake, and interacts with assemblers like GNU Assembler and compilers like GCC and LLVM clang. ld implementations exist across many systems including UNIX System V, GNU/Linux, FreeBSD, and Microsoft Windows ports, and are essential to producing artifacts adhering to formats like ELF, COFF, and a.out.
ld performs symbol resolution, relocation processing, and section layout to produce final linkable outputs such as executables, shared objects, and static libraries. Typical ld implementations accept object files produced by assemblers and compilers like GCC and Clang and consult archives such as ar (Unix). Linkers implement support for platform ABIs defined by specifications like the System V ABI and interact with debuggers such as GDB and performance tools like perf. Major ld variants include the GNU linker from GNU Binutils, the LLVM linker lld from the LLVM Project, and system-specific linkers in FreeBSD and NetBSD.
The original linker traces to early UNIX toolchains at Bell Labs where linkers for formats like a.out were developed alongside tools by authors such as Ken Thompson and Dennis Ritchie. System V and commercial UNIX vendors standardized features that influenced ld designs in the 1980s and 1990s. The GNU Project produced GNU ld as part of GNU Binutils to support the GNU toolchain and GCC; later, the LLVM Project developed lld to provide a faster, compatible alternative. Other notable evolutions include support for PE/COFF on Microsoft Windows via ports, relocation improvements for Position Independent Code, and integration of link-time optimization used by Gold linker and LLVM LTO.
Common features include symbol resolution, relocation handling, section merging and garbage collection of unused sections, support for shared libraries and dynamic linking via DT_ entries in ELF, and generation of linker maps and symbol tables compatible with nm and objdump. Advanced capabilities comprise linker scripts for custom layout, support for link-time optimization (LTO) integrating with GCC LTO and LLVM LTO, incremental linking used by Gold and lld, and plugin interfaces leveraged by tools such as BFD and LLVM plugin ecosystems. ld also supports generation of debug information formats consumed by GDB and LLDB, and produces outputs aligned with standards like the System V ABI and PE/COFF linking conventions used by Microsoft Visual C++ toolchain.
ld is typically invoked directly or via compiler driver front-ends such as GCC and Clang, which pass appropriate options for libraries, startup files, and runtime search paths. Common command-line options include specifying input object files, library search paths (e.g., -L), libraries to link against (e.g., -l), entry point selection (e.g., --entry), and opting for static or dynamic linking (e.g., --static). Linker scripts use directives like SECTIONS and PROVIDE to control layout; tools such as objcopy, readelf, and objdump are used alongside ld for inspecting and transforming binaries. Build systems like Make, CMake, and Bazel orchestrate ld invocations in complex projects such as Linux kernel and large applications like Firefox and Chromium.
ld reads and writes object and executable formats including ELF, COFF, Mach-O (in some toolchains), and legacy formats like a.out. Outputs can be executables, shared libraries (.so, .dll), relocatable object files, and linker map files. ld integrates with archive formats like ar (Unix) for static libraries and understands symbol versioning mechanisms used by glibc and system libraries on GNU/Linux. It also emits auxiliary files such as dynamic symbol tables, relocation entries, and debug sections (.debug_info) consumable by GDB and DWARF-aware tools.
Different ld implementations carry different licenses and platform support. The GNU linker in GNU Binutils is licensed under the GNU General Public License and targets many Unix-like systems; lld is provided under permissive licenses via the LLVM Project and is aimed at performance-sensitive builds on Linux, FreeBSD, Windows, and macOS. Proprietary and vendor-supplied linkers accompany toolchains from Microsoft Visual C++, Intel compilers, and embedded toolchains such as ARM Compiler and IAR Systems, each supporting target-specific ABIs and output formats.
Notable implementations include: - GNU ld from GNU Binutils, widely used in Linux distributions and GNU toolchains. - lld from the LLVM Project, designed for high performance and compatibility with Clang. - Gold linker (GNU Gold), a next-generation linker originating within GNU Binutils focused on speed and scalability for large codebases like the Linux kernel. - System linkers from FreeBSD, NetBSD, and OpenBSD tailored to their kernels and runtime. - Linkers in proprietary toolchains such as Microsoft Visual C++, Intel C++ Compiler, and toolchains for ARM Ltd. targets.
See also tools and projects interacting with ld such as GCC, Clang, GNU Make, CMake, GDB, objdump, readelf, nm, ar (Unix), Gold linker, lld, and the LLVM Project.
Category:Linkers