fix(relinker): root code addresses taken by RIP-relative LEA #2238
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2238"
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 mrk1987 on 2026-10-09T12:45:33Z.
What
Windows conversion only patches guest TLS accesses (
mov %fs:0x0, ...) in instructions that code analysis reaches. #1117 added roots for code that no root reaches. A function whose only reference is a 64-bit RIP-relativeLEAis still missed: a constructor, callback or thread entry whose address is stored and later called indirectly. Its TLS access stays unpatched, and the first call readsFS:0as a null pointer on Windows.A REX.W
LEAwith a RIP-relative displacement that resolves to executable code now adds that target as a code root. This applies both in the main instruction walk and while following the control-flow graph of unreached code.BuildControlFlowGraphgets an opt-infollowCodeAddressesflag for the second case. Existing callers keep their behaviour.A new
tls_function_coveragecase,address-taken-tls-callback, puts a TLS access in a function that is only reached throughlea rax, [rip+fn]; call rax. It fails on currentmain(the access is not rewritten to a jump) and passes with this change.Tested
Windows 11, MinGW-w64 GCC (project toolchain), Release/Ninja on upstream main
d70b8998.tls_function_coveragepasses; on unchanged production code the new case fails withAssertionError: address-taken-tls-callback.ctest: 507/507 pass (1 skipped:guest_video_out_wqhd_detection_no_vulkan).tools/check_conventions.pyandgit diff --checkpass.main, the title crashes early with a null read at a rawmov %fs:0x0, %raxin a function installed by address (OutputDeviceRedirectorthread). With this change that site is patched and startup continues.#1913 splits the same test script into groups. If it merges first, this four-line case moves into one of its groups.
Checklist
main; no other open PR implements the same functions🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T15:29:01Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/relinker/tests/test_tls_function_coverage.pyL425-562core/relinker/relinker/src/analysis/CodeInstructionCollector.cppL277-279core/relinker/relinker/src/analysis/UnusedNidFilter/ControlFlowGraph.cppL26Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:44:23Z.
Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Python 3.14, Release,
-DBUILD_TESTING=ON, #2238 (ba525633) tested on currentmain(0fdda7be).ctest -R "^tls_function_coverage$": passes cleanly in 12.8s (TLS function coverage integration tests passed).tools/check_conventions.py: passes cleanly.Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T05:35:14Z.
Heads-up @mrk1987: rooting LEA targets now reaches CPU-dispatched XOP code (AMD
8Fescape), which the x86 decoder doesn't support. The Windows conversion of three catalog titles (Stremio Plus, OpenNOW, PPSA99420) fails withCode analysis: overlapping instruction boundariessince this landed. Details, the bisect and a ready fix branch that adds XOP decoding are in #2559. The change itself is fine; it just exposed the decoder gap.