[PATCH] Write alignment of `.tls` into `_tls_used.Characteristics`

Project / Subsystem

binutils / bfd

Date

2026-09-15

Proposer

LIU Hao <lh_mouse@126.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

—/10

Technical tradeoffs

  • • Ensures correct TLS alignment for modern Windows systems.
  • • Improves compatibility with compilers like Clang and MSVC.
  • • The change is backward compatible as older systems ignore the alignment field.

All attributes

project
binutils
subsystem
bfd
patch_id
—
discussion_id
66edde04-610a-42f8-a584-9a3b413c349e@126.com
source_type
public_inbox
title
[PATCH] Write alignment of `.tls` into `_tls_used.Characteristics`
headline
Write alignment of `.tls` into `_tls_used.Characteristics`
tldr
Updates binutils to correctly encode TLS variable alignment in PE executables.
proposer
LIU Hao <lh_mouse@126.com>
consensus
Proposed
outcome
proposed
sentiment_score
—
technical_tradeoffs
  • • Ensures correct TLS alignment for modern Windows systems.
  • • Improves compatibility with compilers like Clang and MSVC.
  • • The change is backward compatible as older systems ignore the alignment field.
series_id
—
series_role
standalone
series_parts
[]
tags
  • • binutils
  • • bfd
  • • pe
  • • tls
  • • windows
bugzilla_url
—
date
2026-09-15T00:00:00.000Z

[PATCH] Write alignment of `.tls` into `_tls_used.Characteristics`

This patch updates binutils’ BFD library to correctly handle the alignment of Thread Local Storage (TLS) variables in Windows PE executables. Since the Windows 8.1 SDK, the Characteristics field in the TLS directory has a dedicated subfield for Alignment. This patch ensures that when a user defines an over-aligned thread-local variable (e.g., using alignas), its alignment is correctly encoded in the _tls_used.Alignment field, matching the behavior of Clang and MSVC. This allows the system to allocate TLS storage with the proper alignment.