fix(relinker): reject outputs that overwrite the input file #356
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/356"
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 nicolasabosch on 2026-10-02T12:21:41Z.
What
The relinker can overwrite its source ELF when the output identifies the input file. For example,
relinker --skip-sce-module --windows input.elf input.elfcurrently succeeds and replaces the original ELF with a PE executable.Reject that output using C++20
std::filesystem::equivalentbefore conversion or artifact writes. Distinct output files, including existing files, remain valid. Add and register a real-binary regression test covering identical paths, relative/absolute and normalized aliases, hard links, symlinks when supported, and case aliases on case-insensitive Windows filesystems. Both Linux ELF and Windows PE output modes are covered; rejection preserves input bytes and creates no registry artifact.Tested
core/relinker/CMakeLists.txtusing a temporary CMake harness outside the repository. The harness sets C++20, enables testing, defines the rootadd_test_executablehelper, and adds the unchanged relinker subdirectory. The full runtime/library build and the documented MinGW toolchain were not tested locally.ctest --test-dir work/relinker-build --output-on-failure: 16/16 passed. Hard-link, symlink and Windows case-alias cases ran without skips.git diff --check: passed.Checklist
main; no other open PR implements the same functions (95 open PRs checked).mdfiles or images added to the repositoryPull request closed