fix(relinker): exclude trailing PS4 relative jump tables #6595
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6595"
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 MarcZX10 on 2026-10-15T21:54:38Z.
What
Carry the relative jump-table proposal attached to #3093, preserving the original author as co-author. On PS4 SCE executables, a trailing signed-relative jump table in or immediately after an unwind function can be decoded as instructions by the syscall scan, call-site scan, or code collector. This change detects the table from an RIP-relative LEA followed by an indirect jump, requires at least two entries targeting decoded instruction starts, and requires only padding after the table.
The pipeline scans a copy with detected table bytes replaced by NOPs. The code collector trims the unwind function at the table, excludes table addresses from roots, and stops CFG traversal at table ranges. This is limited to SCE dynamic executables/modules.
The implementation follows the proposal from @SuperCatElvis in #3093; that contributor requested carrying it with a co-author credit. Their issue report says the affected eboot passed the syscall and call-site scans with the patch applied and advanced to the next conversion stop. I did not run that eboot locally. This PR adds synthetic detector coverage because the original patch had no tests.
Related: #3093. This is separate from #6354, which finds the PLT before unwind code and changes code extent calculation.
Tested
f25f22630converts the inFAMOUS Second Son (CUSA00004) eboot;mainwith #6618 and #6977 stop on an unsupported guest TLS instruction.control_flow_graphcoverage checks a detected table and rejects a single-entry table, invalid instruction targets, and non-padding trailing bytes.python3 tools/check_conventions.py --base upstream/main --head HEAD: passed.git diff --check: passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T22:02:47Z.
CI follow-up: the relinker CTest suite now passes on Ubuntu (2m29s), Windows and macOS (2m57s). Eligibility, conventions and intake also pass. The AGC build jobs were skipped by the changed-path filter and do not cover this relinker-only change.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T22:07:20Z.
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/src/analysis/CodeInstructionCollector.cppL4, L116-117core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL5core/relinker/relinker/src/analysis/UnusedNidFilter/ControlFlowGraph.cppL71core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL374, L376-377, L385-386, L548-549, L551Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/CMakeLists.txtcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T22:08:01Z.
Manual check of the overlap warning for #6447: its
CodeInstructionCollector.cppchange adds overflow validation to the existingfileOffsetlambda. This PR adds the trailing jump-table scan/filter inCollectand the CFG data predicate. The edits are in separate logic, neither depends on the other, and I found no semantic overlap or merge dependency.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T22:31:23Z.
Review: COMMENTED
Tested on Apple M2 Max, macOS 27.2, Xcode 27 clang, CMake 4.4.4 + Ninja, relinker-only Release.
Head
f25f22630, merged ontomain5d9dcc42d(clean merge, no warnings).main/usr/bin/python33.9The 3 x86_64 failures are the same on
main(pr_overlap_tools,release_package,linux_fixed_base) and are unrelated.control_flow_graphpasses on both architectures.Coverage note: the new test only reaches the detector (
FindTrailingRelativeJumpTable/FindRelativeJumpTables). I disabled each integration point on top of the PR, one at a time, and the full suite still passed 173/173 every time:RelinkerPipeline.cpp: no table ranges filled with NOPs in the scan copy (the syscall and call-site scans see the original table bytes again).CodeInstructionCollector.cpp: no table ranges recorded and the unwind function not trimmed.ControlFlowGraph.cpp: theisDatachecks inenqueueand the decode loop removed.So a regression in the part that fixes #3093 (the scans decoding the table) would not be caught. A small synthetic SCE input whose trailing table bytes contain a
0F 05or a call-like pattern, run through the syscall scan path, would cover case 1.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T22:34:46Z.
Good catch. The current test exercises detector output and CFG exclusion, but it does not verify the pipeline scan copy or code-collector trimming; disabling those integration points still leaves the suite green. A synthetic SCE fixture that puts a syscall/call-like pattern in the table would cover the path you describe. I will track that as a separate follow-up test PR, consistent with the repository rule to keep follow-up work on a new branch.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T23:15:45Z.
The new #6618/#6619 results on #3093 are useful. I compared #6595 with #6618: #6618 detects a table within an FDE range from its LEA/MOVSXD pattern, while #6595 searches the end of an FDE and a bounded range after it, requiring decoded targets and padding. They cover related table layouts, but both change
CodeInstructionCollector.cppandRelinkerPipeline.cpp;git merge-treereports content conflicts in both. Could we coordinate a combined detector and integration so we keep the distinct range coverage and tests without carrying two competing scans? #6619 zero-length-FDE handling appears separate.Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T23:30:30Z.
Thanks for comparing them, @MarcZX100, and for the offer to combine. I ran #6595 (
f25f22630, relinker-only Release build, Windows,--skip-sce-module) on the two retail titles from #6618, using dumps of my own copies:Unsupported Windows guest TLS instruction (bytes: 64 fb), file offset 0x11e26fcUnsupported Windows guest TLS instruction (bytes: 65 fd), file offset 0x1c829cBoth stops are in trailing tables that #6595 leaves in the code:
lea rcx,movsxd rax, [rcx+rax*4],add,jmp rax, behindcmp eax, 0x12; ja.retat 0x1c4279 and a 2-bytenop. After it come an 8-bytenopland the next function at 0x1c42d0.retat 0x11de66c, acallat 0x11de66d and twonops.I haven't pinned down where #6595 rejects them. In a debug build its
TableEntriesdoes count all 19 entries of the Limbo table in one pass, so a reduced copy of these two layouts may be the quickest way to find it. #6595 passes every case of thesce_inline_jump_tablestest in #6618 (I ran that script against its relinker), so the synthetic fixtures don't separate the two; the titles do.In the other direction, #6618 only looks inside the FDE range, so it does not handle tables in the gap after it, as in the Until Dawn report.
A proposal for one change:
CodeInstructionCollectorandRelinkerPipelineintegration, and both sets of tests.I'm happy to do the combining on #6618 with you and @SuperCatElvis as co-authors. Or I can bring the in-range detection, its fixture and the title results to #6595, whichever you prefer.
AI-assisted: yes (Claude Code). The conversions above ran on my machine; no game files leave it.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T23:43:39Z.
Thanks for testing both detectors on the two titles and for sharing the layouts. This confirms #6618 covers the in-FDE trailing tables, while #6595 is aimed at the distinct bounded gap after an FDE (including the Until Dawn report). I suggest keeping the detector cases distinct for now; if #6618 lands first, I can rebase #6595 on it and resolve the shared integration points while preserving each change’s attribution. I will add the reduced in-FDE fixtures as a separate follow-up only if the current review needs that coverage.
Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-10-18T18:06:35Z.
Tested this branch (head
f25f22630) on a real PS4 eboot: inFAMOUS Second Son (CUSA00004, my own dump). Windows 11 Pro, WinLibs GCC 15.2.0, relinker-only build,relinker --windows --skip-sce-module eboot.elf app.exe.The eboot has the case this PR describes:
0x64c870has an FDE ending at0x64d0c3, after a call to a noreturn function and anop.0x64d0c4–0x64d104. It is loaded bylea rcx, [rip+0x6dd]at0x64c9e0andmovslq (%rcx,%rax,4),%rax.0x64d110.Results:
mainwith #6618: stops withUnsupported Windows guest TLS instruction (bytes: 65 ff ff) (offset 0x6510cc).AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T21:21:13Z.
Thanks for testing the current head on inFAMOUS Second Son. This directly confirms the post-FDE, NOP-padded table case converts under Windows, and the comparison with #6618 helps distinguish it from the in-FDE detector. I added your reported setup and result to the PR’s Tested section with credit.