fix(relinker): skip jump tables placed right after a function's unwind range #7620
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7620"
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 DealPotato on 2026-10-18T17:36:34Z.
What
Some PS4 executables put a switch jump table right after the FDE of the function that reads it. #6618 only finds tables inside the function's unwind range, so code analysis decodes such a table's entries as instructions and the conversion stops.
inFAMOUS Second Son (CUSA00004) does this:
0x64c870has an FDE ending at0x64d0c3. It ends with a call to a noreturn function (call 0x984360) and anop.0x64d0c4:lea rcx, [rip+0x6dd]at0x64c9e0, thenmovslq (%rcx,%rax,4),%rax.leaadds0x64d0c4as a code root, and the conversion fails:The change:
FindTrailingJumpTablestracks the sameleaandmovsxdtable loads asFindInlineJumpTables, now shared through one helper. It does this for table bases between the function's end and the next function, or the end of the code segment.CodeInstructionCollectoradds these tables toinlineData, so the CFG neither enters them as roots nor reaches them by fall-through.RelinkerPipelinefills them withnopbefore the syscall scan, as it already does for tables inside the function.test_sce_inline_jump_tables.pygains atrailingfixture: theplaintable with the FDE ending at the table. Without the change, it fails withCannot decode instructionat the table.Tested
--windows --skip-sce-module. On this branch without the last commit, i.e.main+ #6618, it fails with the error above. With it, it converts.libc.prxandlibSceFios2.prxconvert.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 (none added).mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T17:52:54Z.
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.cppL6, L366core/relinker/relinker/include/relinker/analysis/InlineJumpTables.hppcore/relinker/relinker/src/analysis/InlineJumpTables.cppcore/relinker/relinker/tests/test_sce_inline_jump_tables.pySome 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/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/CMakeLists.txtcore/relinker/relinker/include/relinker/analysis/InlineJumpTables.hppcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/analysis/InlineJumpTables.cppcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppcore/relinker/relinker/tests/test_sce_inline_jump_tables.pycore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-10-18T18:07:09Z.
Closing in favour of #6595, which handles the same case and converts the Second Son eboot that motivated this PR.
Pull request closed