From ad039bd70c55b85122343ac41cfd104b32e2d211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gr=C3=A9goire?= Date: Sat, 10 Oct 2026 07:54:26 -0400 Subject: [PATCH] Elf2: check size of TLS section before erroring --- src/link/Elf2.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/link/Elf2.zig b/src/link/Elf2.zig index b7d441e8ad1f2dee1d5e670caff8ca9063067fb5..479c96d7c824736e29da8d857e1e8159d07ecc06 100644 --- a/src/link/Elf2.zig +++ b/src/link/Elf2.zig @@ -7625,11 +7625,15 @@ fn loadObject( }) catch |err| switch (err) { else => |e| return e, error.StripSection => continue, - error.TlsSectionUnavailable => return diags.failParse( - path, - "thread-local storage section '{s}' is incompatible with '-fsingle-threaded'", - .{name}, - ), + error.TlsSectionUnavailable => { + if (section.shdr.size == 0) continue; + + return diags.failParse( + path, + "thread-local storage section '{s}' is incompatible with '-fsingle-threaded'", + .{name}, + ); + }, error.UnsupportedSectionFlags => if (!section.shdr.flags.shf.ALLOC) { // It probably doesn't matter, just skip this section. continue; -- 2.54.0