Updated in 2022-05.
This article is a continuation to ELF
interposition and -Bsymbolic. It focuses on the GCC/Clang option
-fno-semantic-interposition
and why it can (sometimes
incredibly) optimize -fPIC
programs.
Updated in 2022-05.
This article is a continuation to ELF
interposition and -Bsymbolic. It focuses on the GCC/Clang option
-fno-semantic-interposition
and why it can (sometimes
incredibly) optimize -fPIC
programs.
Updated in 2023-10.
GCC and Clang support __attribute__((weak))
which marks
a symbol weak. The same effect can be achieved with a preprocessor
directive #pragma weak symbol
.
In ELF, there are three main symbol bindings. The ELF specification says:
STB_LOCAL
: Local symbols are not visible outside the
object file containing their definition. Local symbols of the same name
may exist in multiple files without interfering with each other.STB_GLOBAL
: Global symbols are visible to all object
files being combined. One file's definition of a global symbol will
satisfy another file's undefined reference to the same global
symbol.STB_WEAK
: Weak symbols resemble global symbols, but
their definitions have lower precedence.In research papers, a segment tree refers to a tree data structure allowing retrieving a list of segments which contain the given point. In competitive programming, the name "segment tree" usually refers to a data structure maintaining an array. According to http://web.ntnu.edu.tw/~algo/Sequence2.html, the data structure originated from Baltic OI 2001: Mars Maps.
Updated in 2023-09.
This article introduces RISC-V linker relaxation and describes the downside.
Because the linker has a global view and layout information, it can perform some peephole optimizations which are difficult/impossible to do on the compiler side. Generic link-time code sequence transformation is risky, because semantic information is lost and what the linker sees are byte streams. However, if every instruction in the candidate code sequence is associated with one ore more relocations, the ABI and the implementation can assign (additional) semantics to the relocation types and make such transformation safe. This technique is usually called linker optimization or linker relaxation. It seems that the term "linker optimization" is often used when the number of bytes does not change while "linker relaxation" is used when the number of bytes decreases.
A program may have a lot of unused code and data. There can be many reasons:
Updated in 2024-11.
Thread-local storage (TLS) provides a mechanism allocating distinct
objects for different threads. It is the usual implementation for GCC
extension __thread
, C11 _Thread_local
, and
C++11 thread_local
, which allow the use of the declared
name to refer to the entity associated with the current thread. This
article will describe thread-local storage on ELF platforms in detail,
and touch on other related topics, such as: thread-specific data keys
and Windows/macOS TLS.
Many compiler options intrument or annotate text sections, and need to create a metadata section for every candidate text section. Such metadata sections have the following property:
As mainly an LLVM person, I occasionally contribute to GNU toolchain projects. This is sometimes for fun, sometimes for investigating why an (usually ancient) feature works in a particular way, sometimes for pushing forward a toolchain feature with the mind of both communities, or sometimes just for getting sense of how things work with mailing list+GNU make.
Updated in 2024-04.
GNU indirect function (ifunc) is a mechanism making a direct function call resolve to an implementation picked by a resolver. It is mainly used in glibc but has adoption in FreeBSD.