fix(relinker): preserve inputs behind Windows executable hard links #6328
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6328"
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 aaro56 on 2026-10-15T11:53:56Z.
What
On Windows with the supported MinGW-w64 compiler, an
output.exehard link toinput.elfpasses the relinker's input-overwrite checks. Conversion returns success and replaces the input ELF with the generated PE executable. The same comparison is used for additional executable inputs and bundled modules.Use the existing
SameOutputFilehelper for all three input/output comparisons. It already handles the extension-dependent permission mismatch that makes MinGW'sstd::filesystem::equivalentmiss these hard links. Collisions are rejected before any output is written.Extend the existing input-preservation test with main/secondary outputs aliased to the main executable, a secondary executable, and a bundled module, for Linux and Windows conversion targets. Windows also exercises read-only aliases. Check original bytes, existing outputs, permissions, link counts and temporary-probe cleanup. A positive control confirms that distinct multiply linked files with identical bytes still convert successfully.
The existing helper conservatively rejects ambiguous read-only identities or unwritable probe directories. Record this limitation in relinker technical debt.
Related: #6127 proposes removing the Windows permission-mismatch workaround from
SameOutputFile. This fix relies on that workaround; its removal would restore the input-overwrite failure covered by the new regression.Tested
Windows 11 Home Single Language 10.0.22631, WinLibs MinGW-w64 GCC 15.2.0
x86_64-ucrt-posix-sehr7, Release, relinker-only build, Python 3.13.12.mainat5050a23f38ed03e2601804e90e0565b84ca4f1b5: all 167 registered tests passed. The new regression then failed on that original executable; an independent synthetic reproduction returned success and observed the input bytes being overwritten.mainat6ea62f9b407b766c5adca63b37f63c70170f7612, rebuilt, and passed all 168 registered tests in 50.54 seconds. The input-preservation test completed in 4.06 seconds.fdea36b83667541516affdc8c04fdc39b3496337before publication. The relinker, its tests and its build inputs are unchanged from the tested tree; the intervening upstream changes concern AGC graphics.tools/check_conventions.pypassed against the exact staged tree and PR description. Whitespace and patch applicability checks passed.Synthetic fixtures only. No retail game, GPU execution, or Linux/macOS host execution. No performance claim.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:18:52Z.
Some 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.
docs/dev/debt/relinker.mdcore/relinker/main.cppcore/relinker/main.cppdocs/dev/debt/relinker.mddocs/dev/debt/relinker.mdcore/relinker/main.cppdocs/dev/debt/relinker.mdcore/relinker/main.cppdocs/dev/debt/relinker.mddocs/dev/debt/relinker.md