fix(relinker): protect executable inputs from output overwrites #2243
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2243"
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 NumberGuan on 2026-10-09T12:55:47Z.
What
The relinker can overwrite its input executable or a bundled input module when the executable output refers to the same file, including through a hard link. Conversion reports success.
Reject these destinations before writing the registry, converted modules or executable. The main-input check also runs with
--skip-sce-module; the module check uses the input inventory discovered byGuestModuleBuilder. Separate existing output files remain replaceable. Add an integration regression and document the output constraint.This complements #2100, which protects the JSON registry destination. The module guard runs after the input inventory is finalized and combines cleanly with #2212's module discovery changes, verified with
git merge-tree. There is no functional dependency.Tested
Windows x64, WinLibs MinGW-w64 GCC 15.2.0 UCRT POSIX SEH r7, Ninja Release, Python 3.12.14. Based on upstream
d70b8998; current contributiona406ad4d.All 41 registered test groups passed on the initial
dc9c75b5head. After moving the module guard ona406ad4d, the relinker rebuilt and four focused groups passed:input_preservation,guest_module_directories,guest_needed_modulesandguest_host_libc. Registration, conventions and whitespace checks passed.tls_function_coveragetook 68.99 seconds in the initial full run; no repository timeout was changed.The new regression fails on the original implementation, which converts over its input executable and returns success. With only the main-input guard applied, it then fails on conversion over a bundled input module. The complete fix passes both.
The regression checks Linux ELF and Windows PE conversion on the Windows host: direct paths, normalized paths, hard links, unchanged source bytes, error status and diagnostic, and absence of generated outputs on rejection. Valid new and existing destinations still convert. Four symbolic-link cases were skipped because this session cannot create symbolic links.
GitHub Actions passed Conventions and the relinker build/test matrix on Windows, Linux and macOS for the current
a406ad4dhead: Build run, Conventions run. The full Linux and Windows build jobs were skipped under the repository's pull-request policy. System-library builds and game/PS5 tests were not run locally.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T15:29:03Z.
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/CMakeLists.txtL269core/relinker/relinker/tests/test_input_preservation.py