feat(relinker): add conversion-time game patches #6314
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6314"
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 eliyarson on 2026-10-15T11:06:56Z.
What
Adds an opt-in per-title patch file,
relinker-patches.toml, that the relinker applies to the executable and its modules at conversion time. Proposal and design: #6206, questions: #6207.The file is found next to the input automatically.
--patches <file>selects another file.--no-patchesignores it. The file is a strict subset of TOML. Each[[patch]]entry hastarget,va,expectedandvalue, and optionallyname,type,min,max,alignanddescription.The relinker refuses the conversion when:
vadiffer fromexpected;PT_LOAD;Every check runs before any output is written. On error nothing is written. With no patch file the output is byte-identical to the output of
main.The relinker writes a manifest,
<stem>.patches.toml, built before the outputs. It lists every applied entry.--patches <manifest>replays it.--verify-patches <file> <path> [--verify-output]checks a patch file against an input, or against a converted output with--verify-output. It writes nothing.Motivating case: Hades II. One byte raises its upload pool from 512 to 768 MiB. Pinned to 2 cores, 7 of 10 runs crashed before and 0 of 10 after (details in #6206). The code and docs do not name a title.
Follow-ups: not in this PR; see #6206.
Tested
CachyOS, Linux 7.2.2, Ryzen 9 5950X, RTX 3080 Ti.
Results are for the squashed commit
cde39e8e5.ctestpasses 174 of 174.cteston the branch: 1236 tests, 4 failed, 2 skipped. Plainmain8856f180cwith the same configuration: 1234 tests, the same 4 failed and the same 2 skipped. The branch adds two tests. Nothing here is caused by this PR.guest_allocator_failuresfails on this host because of memory overcommit. #6310 (open) fixes the test.video_out_flip_eop,video_out_flip_eop_mainandvideo_out_flip_eop_aftergpualso fail on plainmain8856f180c; they passed here on760ffa683.agc_driver_stencil_ref_exportis skipped: the GPU lacksVK_EXT_shader_stencil_export.agc_import_watch_other_familyis skipped.python3 tools/check_conventions.py --base origin/mainpasses.app.elfand all 7 modules are byte-identical to the output ofmain. The same holds with a patch file present and--no-patches.app.elfdiffers (offset 0x290414, 0x20 to 0x30). The modules are unchanged.--verify-patcheson the input reportsapplicable. On the convertedapp.elfwith--verify-outputit reportsapplied. Both exit 0.--patcheson the manifest gives identical outputs; the new manifest differs only inconfig.Not tested: Windows; macOS; the web converter.
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 github-actions[bot] on 2026-10-15T11:13:57Z.
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/cli/src/CliArgs.cppL14, L17-19core/relinker/cli/tests/CliArgsTests.cppL310core/relinker/main.cppL65core/relinker/relinker/include/relinker/pipeline/Conversion.hppL26docs/user/USAGE.mdL78Some 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/relinker/src/guest/GuestModuleBuilder.cppdocs/user/USAGE.mddocs/user/USAGE.mdcore/relinker/CMakeLists.txtdocs/user/USAGE.mddocs/dev/ARCHITECTURE.mddocs/user/USAGE.mdcore/relinker/CMakeLists.txtdocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mddocs/user/USAGE.mdcore/relinker/CMakeLists.txtcore/relinker/main.cppdocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mddocs/user/USAGE.mddocs/dev/ARCHITECTURE.mddocs/user/USAGE.mdcore/relinker/CMakeLists.txtcore/relinker/relinker/include/relinker/guest/GuestImage.hppcore/relinker/relinker/src/guest/GuestModuleBuilder.cppcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/cli/include/Cli.hppcore/relinker/cli/src/CliArgs.cppcore/relinker/cli/tests/CliArgsTests.cppcore/relinker/main.cppcore/relinker/relinker/include/relinker/pipeline/Conversion.hppcore/relinker/relinker/src/pipeline/Conversion.cppdocs/user/USAGE.mdcore/relinker/CMakeLists.txtdocs/dev/ARCHITECTURE.mddocs/user/USAGE.mddocs/dev/ARCHITECTURE.mdImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T11:25:29Z.
The latest Windows relinker job is failing two tests:
relinker_game_patchrejects a config path containingdir\\p.tomlas unholdable, and thegame_patchesPython test asserts at line 69 that the generated manifest containsformat = 1. Linux and macOS pass. Could you reproduce on Windows and check the UTF-8/native path conversion plus manifest generation? This looks Windows-specific; it prevents merging even though the focused Linux suite is green.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T11:26:58Z.
I narrowed these failures to Windows-specific test assumptions. In
GamePatchTests.cpp, thedir\\p.tomlcase expects rejection, but on Windows that is a normal path separator and the fallback filename isp.toml; the same input is a literal backslash filename on Linux. The end-to-end Python assertion compares the manifest’s generic forward-slash path againststr(Path), which uses backslashes on Windows. The implementation intentionally serializes generic paths. I suggest making the C++ case use a platform-independent invalid character (e.g. control byte) and comparingsource.parent.as_posix()in the Python test. These appear to be test portability fixes rather than a Windows product bug.Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-15T23:14:45Z.
Thanks, you were right: both were test bugs, now fixed. I also rebased onto
main, and CI is green.