binutils Newspaper
NOVEMBER 30, 2026
aarch64 — Proposed

aarch64: bound the TLS relaxation spans and sequence length

Binutils AArch64 TLS relaxation now validates spans and sequence lengths to prevent out-of-bounds access.

This patch enhances binutils’ AArch64 ELF support by adding checks for Thread-Local Storage (TLS) relaxation. It validates that the written span does not exceed section limits and that required relocation sequences are present, preventing out-of-bounds writes and reads caused by crafted objects.

In the Thread 1 participant
  1. Harshit Kumar <harshit7kr@gmail.com> proposer

    Proposes bounding TLS relaxation spans and sequence lengths in AArch64 ELF.

    “elfNN_aarch64_tls_relax rewrites a fixed instruction sequence at the relocation offset. The sequence is up to 20 octets, wider than the howto size, and the GD and TLSDESC transitions read the following one or two relocations. A crafted object could place such a relocation near the end of a short section, or leave the sequence truncated, and the linker wrote past the section contents or read pas…”

In Details

This is the second patch in a series for binutils' AArch64 ELF backend, focusing on Thread-Local Storage (TLS) relaxation. The elfNN_aarch64_tls_relax function rewrites instruction sequences which can be larger than the standard relocation size. This patch adds crucial bounds checking to ensure that the rewritten sequence, and the subsequent relocations it might need to read, do not extend beyond the section's boundaries. This prevents memory corruption on malformed inputs, improving robustness and security. It replaces a weak BFD_ASSERT with a proper error return.

For Context
TLS
Thread-Local Storage, a mechanism allowing each thread in a process to have its own private copy of a variable.
relaxation
An optimization process where the linker adjusts code or data references, often to create position-independent code or to enable specific features like TLS.
AArch64
The 64-bit ARM architecture.
ELF
Executable and Linkable Format, a standard file format for object files, executables, and shared libraries.
relocation
A placeholder in object code that specifies how to modify an address or symbol reference when linking.
howto
Describes how a relocation should be applied, including the size of the field being modified.
GD
General Dynamic, a TLS model providing access to thread-local variables via a GOT.
TLSDESC
TLS Descriptor, a mechanism used in some ABIs for accessing thread-local variables, often involving an indirection through a descriptor structure.
BFD_ASSERT
A macro used in the BFD library for internal assertions; if it fails, it typically terminates the program.
Filed Under: aarch64tlssecurityelfbinutils