Posts
LLD and GNU linker incompatibilities
Updated in 2024-06.
Subtitle: Is ld.lld a drop-in replacement for GNU ld?
The motivation for this article was someone challenging the "drop-in replacement" claim on LLD's website (the discussion was about Linux-like ELF toolchain):
LLD is a linker from the LLVM project that is a drop-in replacement for system linkers and runs much faster than them. It also provides features that are useful for toolchain developers.
99.9% pieces of software work with ld.lld without a change. Some linker script applications may need an adaption (such adaption is oftentimes due to brittle assumptions: asking too much from GNU ld's behavior which should be fixed anyway). So I defended for this claim.
…C++ exception handling ABI
Updated in 2024-11.
I wrote an article a few weeks ago to introduce stack unwinding in detail. Today I will introduce C++ exception handling, an application of stack unwinding. Exception handling has a variety of ABI (interoperability of C++ implementations), the most widely used of which is Itanium C++ ABI: Exception Handling
…All about symbol versioning
Updated in 2026-01.
Many people just want to know how to define or reference versioned symbols properly. You may jump to Recommended usage below.
In 1995, Solaris' link editor and ld.so introduced the symbol versioning mechanism. Ulrich Drepper and Eric Youngdale borrowed Solaris' symbol versioning in 1997 and designed the GNU style symbol versioning for glibc.
gnu-gabi specification: https://sourceware.org/gnu-gabi/program-loading-and-dynamic-linking.txt#:~:text=versioning
…Explain GNU style linker options
Updated in 2025-02
(首先庆祝一下LLVM 2000 commits达成!)
Compiler driver options
Before describing the linker options, let's introduce the concept of driver options.
The user-facing options of gcc and clang are called driver options.
Some driver options affect the options passed to the linker.
Many such options have the same name as the linker's, and they often have additional functions in addition to the options of the same name passed to the linker, such as:
Stack unwinding
Update in 2025-11.
The main usage of stack unwinding is:
- To obtain a stack trace for debuggers, crash reporters, profilers, garbage collectors, etc.
- To implement C++ exceptions (Itanium C++ ABI) using personality routines and language-specific data area. See C++ exception handling ABI
Some people use "stack walking" to refer to obtaining a stack trace, while "stack unwinding" refers to an enhanced operation that also recovers callee-saved registers. In this post, we don't make the distinction.
…Command line processing in LLVM
Updated in 2023-05.
There are two libraries for processing command line options in LLVM.
llvm/Support/ComandLine.h
See https://llvm.org/docs/CommandLine.html for documentation.
Global variables (mostly llvm::cl::opt<type>, some llvm::cl::list<type>) are most common to represent command-line options.
The llvm::cl::opt constructor registers this command line option in a global registry.
The program calls llvm::cl::ParseCommandLineOptions(argc, argv, ...) in main to parse the command line options.
opt supports various integer types, bool, std::string, etc. Defining some specialization can support support custom class/enum types.