binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/bfd

Write alignment of `.tls` into `_tls_used.Characteristics`

Binutils PE/COFF writer now encodes TLS alignment in the Characteristics field.

This change updates the PE/COFF object file writer in BFD to correctly encode the alignment of thread-local storage (TLS) variables into the Characteristics field of the _tls_used directory. This aligns with modern Windows SDKs (starting Windows 8.1) and compilers like Clang and MSVC, ensuring proper runtime alignment for over-aligned thread-local variables.

In Details

The BFD library's PE writer is enhanced to populate the Alignment subfield within the Characteristics dword of the IMAGE_TLS_DIRECTORY64 structure. This change implements the behavior expected by recent Windows SDKs and compilers, correctly writing the alignment requirement for over-aligned thread-local variables, which was previously only handled by specific compiler toolchains.

For Context
PE/COFF
Portable Executable/Common Object File Format, the standard file format for executables, object code, and DLLs used in 32-bit and 64-bit versions of Windows operating systems.
TLS
Thread-Local Storage, a mechanism that provides each thread in a process with its own instance of a variable.
Characteristics field
A field within PE/COFF headers and structures that holds flags indicating various attributes of a section or directory, such as alignment or memory protection.
Alignment
The requirement that data in memory be located at an address that is a multiple of some value, often related to the data size or CPU architecture for performance reasons.
Filed Under: binutilsbfdwindowstlsalignment