fix(relinker): resume scans after undecodable bytes between PS4 unwind functions #7660
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7660"
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 savvaniss on 2026-10-18T20:46:10Z.
What
In PS4 (
PT_SCE_DYNLIBDATA) executables and modules, the bytes between unwind functions are 16-byte slots of function tails and NOP padding, and a tail can begin inside an instruction. Hasbro Family Fun Pack (CUSA03312) has a slot that is a lone48followed by a 15-byte NOP, which decodes as one 16-byte instruction, so the syscall scan failed the relink withCannot decode instruction: Instruction exceeds 15 bytes. This is stop 2 in my #3093 comment; @MarcZX10 suggested a focused PR with synthetic fixtures that stays strict inside FDE ranges.sce_modulepaths) and the call-site scan now get the segment's unwind function ranges (SceUnwindRanges, from the sameReadExceptionFunctionslist thatFindSceCodeEnduses).Unsupported Windows guest TLS instruction (bytes: 65 f0 5b)) needs nothing here: since #6102 the Windows TLS builder traps GS-prefixed instructions.docs/dev/debt/relinker.md.Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON) onmainf3059421f. The branch is rebased onto6e27fc8f0; nothing undercore/relinkerchanged in between.sce_code_gapsandamd64_only_converterwith its new scanner case.test_sce_code_gaps.pyagainst a relinker built from unchangedmainf3059421f, case by case:mainCannot decode instruction ... (offset 0x210)Cannot decode instruction ... (offset 0x1000)syscallin the gapCannot decode instructionForbidden syscall instruction at code offset 0x220mov eax, imm32opcode in the gap byte before a function that starts withsyscallmovswallows the syscallForbidden syscall instruction at code offset 0x200Cannot decode instructionCannot decode instructionCannot decode instruction3b158c1e4from #6977, without the earlier local experiment. The Linux and--windowsconversions of the eboot and its 9 bundled modules complete (External prx references: 1345). Without this change the eboot stops at stop 2 as described in #3093.mainwith #6354 (c3d1363df): relinker CTest 199 of 199.python3 tools/check_conventions.py --base origin/main: passed.risk.selfandmonopoly.selfconvert with this change. In the stack of #7198 (on an RX 9070 XT), Risk then plays a local match against the AI and Monopoly Plus reaches its loading screen.boggle.selfandtp.selfstill stop at a syscall pattern inside a 15 MB data gap.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)RelinkerPipeline.cpp; whichever lands second needs a short rebase. #6354 has merged and is included sincec3d1363df.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T20:57:46Z.
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/codegen/include/codegen/IInstructionScanner.hppL20core/relinker/codegen/src/InstructionScanner.cppL13, L18, L22, L28-29, L41, L59, L64, L67-68core/relinker/relinker/src/analysis/SyscallScanner.cppL190core/relinker/relinker/src/guest/GuestModuleBuilder.cppL359core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL383-384, L388-391docs/dev/debt/relinker.mdL21Some 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.txtdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/relinker/src/analysis/SceCodeExtent.cppcore/relinker/relinker/src/guest/GuestModuleBuilder.cppcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtdocs/dev/debt/relinker.mdImported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T00:13:05Z.
Tested at
45a2e3dd4on Windows 11 / GCC 15.2 and WSL Ubuntu 24.04 / gcc 13.3,main8a456334f.sce_code_gapsandamd64_only_converterpass on both, and the other relinker tests are unchanged. On Windows that is 136/137: the one failure,windows_import_modules, fails the same way onmainhere.Running each case of
test_sce_code_gaps.pyagainst a relinker built frommainreproduces your table exactly:syscall-after-slotfail withInstruction exceeds 15 bytes (offset 0x210/0x1000);instruction-into-functionconverts;Overlap: this conflicts textually in
RelinkerPipeline.cppwith #6595 and #6618. Both are open, and both rewrite the same syscall-scan loop from the sameReadExceptionFunctionslist, so whichever lands second needs a rebase. Since you tested with #6618 merged, maybe list it under Depends on or Overlaps.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T06:42:28Z.
@wachi35676 thanks for reproducing the table on both toolchains.
On #6618: this change doesn't need it. The 11 fixture cases and the relinker suite pass on
mainwithout it, as your run shows. Hasbro's Windows conversion needed #6618 for a separate reason: a jump table at the end of an unwind function inlibSceFios2.prx, which lies inside an FDE range and so isn't a gap (details on #6618). I've kept #6595 and #6618 as textual overlaps in the description and updated it now that #6354 has merged.Since then I merged
main(with #6354) into the branch asc3d1363df. Onlydocs/dev/debt/relinker.mdconflicted, and all 199 relinker tests pass at that head on Windows 11 / WinLibs GCC 15.2.0 r7.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T11:18:04Z.
Re-checked against current main: the merge is clean and the scanner change is unchanged. Undecodable bytes are skipped only outside every unwind range, a decoding that crosses into a range ends at its start, a
syscallin the gap is still rejected, and inside a range (or without ranges, SysV) a decode failure still fails the relink.scannerUnwindRangesandtest_sce_code_gaps.pycover the positive and negative cases and need the new behaviour; relinker CI is green on Linux, Windows, macOS and ASan; merged.