From c692aced232da210469b2c04270edc5a980b72d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 11 Oct 2026 09:21:54 +0200 Subject: [PATCH] compiler_rt.elf.tls: fix potential underflow if PT_TLS p_align is zero Very unlikely with any sane linker, but technically allowed. --- lib/compiler_rt/elf/tls.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compiler_rt/elf/tls.zig b/lib/compiler_rt/elf/tls.zig index fd1bdb381d7eca0a038c967bdb48c0fff10cbec5..dccd2018ce02a2b32050b239a30f9d30dc9d06bd 100644 --- a/lib/compiler_rt/elf/tls.zig +++ b/lib/compiler_rt/elf/tls.zig @@ -499,7 +499,7 @@ fn computeAreaDesc(phdrs: []elf.ElfN.Phdr) void { var block_size: usize = undefined; if (tls_phdr) |phdr| { - align_factor = phdr.@"align"; + align_factor = @max(phdr.@"align", 1); // The effective size in memory is represented by `memsz`; the length of the data stored // in the `PT.TLS` segment is `filesz` and may be less than the former. -- 2.54.0