AnyPS5/core/relinker
AlxcBTW fccfbee72b fix(relinker): convert Windows guest TLS reads after zero alignment padding
The Windows TLS rewriter only patches FS-relative instructions that
CodeInstructionCollector decodes. Code that no symbol, unwind range or
root reaches is covered by a linear sweep that starts after int3 padding
and stops at the first instruction beginning with two zero bytes, so
zero-filled bytes are not read as code.

The .NET NativeAOT homebrew titles pad between functions with zero bytes
instead of int3 and have unwind entries for only part of their code. In
Prospero Vibrate (PPSA99920) the sweep ended at the padding after the
first function. Functions reached only through switch jump tables, which
the control-flow graph does not follow, or through pointers it cannot
resolve kept 105 of 670 FS loads unpatched: 84 `mov reg, fs:[0x28]`
stack-guard reads (65 into rax, 19 into rcx) and 21 `mov rax, fs:[0]`
thread-pointer reads. The title faulted reading address 0x28 within a
second of start.

The sweep now treats a zero run that follows a jump, call, return or
trap and ends at the next 16-byte boundary as alignment padding, and
continues at that boundary. A call counts because a function can end in
a call to a noreturn function. Zero fill after straight-line code, or a
whole zero 16-byte block, still ends the sweep as before.

All 670 FS loads in PPSA99920 are now patched, as are the 102 of 685 in
Prospero Explorer (PPSA99109) and the 103 of 718 in Prospero Multi Tools
(PPSA99110). New tls_function_coverage padding cases: loads behind zero
padding after a return, a call and a jump, with 13, 2, 1 and 5 zero
bytes, are patched; a load behind zero fill after a nop is left
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0306c677784b6c4272990ce65f6daf9fb2dbc3ca)
2026-10-10 16:08:54 +00:00
..
cli fix(relinker): default module path to input elf directory 2026-10-10 14:12:04 +03:00
codegen Merge pull request #2568 from oneandonlydean/fix/relinker-decode-xop-2559 2026-10-10 19:47:50 +13:00
domain/include/domain fix(relinker): discover required guest module identities 2026-10-09 13:53:48 +02:00
elfpatcher Merge pull request #2594 from morten-holm/pr/macos-clear-pie 2026-10-10 11:15:15 +02:00
io fix(relinker): reject non-regular input files 2026-10-10 08:26:32 +02:00
relinker fix(relinker): convert Windows guest TLS reads after zero alignment padding 2026-10-10 16:08:54 +00:00
CMakeLists.txt feat(relinker): add explicit guest module parent path option 2026-10-10 14:10:13 +03:00
main.cpp feat(relinker): add explicit guest module parent path option 2026-10-10 14:10:13 +03:00