📖 WIPIVERSE

🔍 Currently registered entries: 51,780건

gold (linker)

gold is a high-performance linker developed by the GNU project. It is designed as a faster alternative to the traditional GNU linker, ld, with a particular focus on improving link times, especially for large projects.

Overview

The primary goal of gold is to significantly reduce the time it takes to link large executables and shared libraries. This is achieved through several key design choices, including:

  • Parallel Processing: gold is designed to utilize multiple CPU cores to perform linking tasks concurrently. This parallelization allows it to process different parts of the input files simultaneously, leading to faster overall link times.
  • Efficient Data Structures: gold employs optimized data structures for symbol tables, relocation information, and other internal representations. These efficient data structures enable faster lookups and processing of the linking data.
  • On-Demand Symbol Resolution: gold uses an on-demand symbol resolution strategy, meaning that it only resolves symbols when they are actually needed. This avoids unnecessary processing of unused symbols, further improving link times.
  • Input File Format Support: gold supports a variety of object file formats, including ELF (Executable and Linkable Format), which is commonly used on Unix-like systems.

Key Features

  • Faster Link Times: The most significant feature of gold is its improved linking speed compared to ld, particularly for large projects.
  • Plugin Support: gold supports plugins, allowing users to extend its functionality and customize its behavior.
  • Command-Line Compatibility: gold is largely command-line compatible with ld, making it relatively easy to switch between the two linkers. However, there might be some minor differences in command-line options or behavior.
  • Deterministic Output: gold can generate deterministic output, which means that the same input files linked with the same options will always produce the same output file (byte-for-byte). This is useful for debugging and reproducibility.
  • Dynamic Shared Object (DSO) Support: gold fully supports linking dynamic shared objects (DSOs), also known as shared libraries.

Relationship to ld

While gold is intended as a replacement for ld, it is important to note that it is not a complete drop-in replacement. There may be some corner cases or specific options where gold's behavior differs from that of ld. However, for most common use cases, gold should provide a faster and more efficient alternative. ld remains the default linker in many GNU toolchain distributions.

Configuration and Usage

gold is typically invoked through the compiler driver (e.g., gcc, g++, clang) by specifying the -fuse-ld=gold option. The exact method of configuring and using gold may vary depending on the specific operating system and build environment.