Repository navigation
fix(relinker): exclude trailing PS4 relative jump tables - #6595
Conversation
Co-authored-by: SuperCatElvis <39642318+SuperCatElvis@users.noreply.github.com>
|
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. |
|
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.
Some 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.
|
|
Manual check of the overlap warning for #6447: its |
jotitadev
left a comment
There was a problem hiding this comment.
Tested on Apple M2 Max, macOS 27.2, Xcode 27 clang, CMake 4.4.4 + Ninja, relinker-only Release.
Head f25f22630, merged onto main 5d9dcc42d (clean merge, no warnings).
| Build | main |
this PR |
|---|---|---|
| arm64 | 173/173 | 173/173 |
x86_64 under Rosetta, /usr/bin/python3 3.9 |
170/173 | 170/173 |
The 3 x86_64 failures are the same on main (pr_overlap_tools, release_package, linux_fixed_base) and are unrelated. control_flow_graph passes 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 05 or 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.
|
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. |
|
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 |
|
Thanks for comparing them, @MarcZX100, and for the offer to combine. I ran #6595 (
Both stops are in trailing tables that #6595 leaves in the code:
I haven't pinned down where #6595 rejects them. In a debug build its 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:
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 |
|
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. |
|
Tested this branch (head The eboot has the case this PR describes:
Results:
AI-assisted: yes (Claude Code). |
|
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. |
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 fix(relinker): skip jump tables placed after a function's code #6618 and feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #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)