Windows relinker: TLS thread pointer ignores PT_TLS alignment rounding #3136
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-10T22:57:01Z.
AI-assisted (Claude Code), reviewed by the contributor.
Finding: On Windows the relinker's
.gtcodetrampoline forfs:0reads loaded the thread pointer displacement fromblockSizeinstead ofalign_up(p_memsz, p_align). PS5 code reads TLS variables attp - align_up(memsz, p_align), so the converted code reads the wrong slot when the two differ.Evidence: a synthetic ELF with PT_TLS
memsz=0x21,align=8, first variable0x2a, second0x63, and codemov rax, fs:0; mov eax, [rax-0x28]. Before the change the converted exe exits with0x63, after it with0x2a. The regression test iscore/relinker/relinker/tests/test_windows_tls_thread_pointer.py(verified failing without the fix, passing with it, on Windows).In a real title (RE4, PPSA07411) the wrong offset made a thread read another thread variable; this is how I found it. I did not verify that this alone makes the title run; other blockers remain.
Branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/relinker-windows-tls-thread-pointer (2 commits on current
main,tools/check_conventions.pypasses). Not opened as PR because intake is paused for new contributors; happy for a maintainer to carry the commits.Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T05:35:20Z.
Carried as #3290 with both your commits unchanged. On native Windows 11 (GCC 15.2), the relinker suite passes 101/101 and the new test fails against
mainwithread 0x63 instead of the first variable 0x2a. Three catalog homebrew titles have the same PT_TLS shape (memsz 0x258,align 8): Prospero Explorer, Multi Tools and Vibrate. Their converted TLS accesses use thread-pointer offset0x260onmainand0x258with your fix, so those are affected too.