fix(relinker): accept an identical duplicate relocation in Windows executables #11299
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11299"
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 p3n1cillin on 2026-10-26T00:53:26Z.
What
The Windows relinker refused an executable whose
RELAtable lists the same relocation twice. Forever Launcher (PPSA99030) starts a second executable,game-child.bin, which repeats oneR_X86_64_RELATIVEentry: target0x2df70, addend0x2e040, twice inDT_RELAand nowhere else. Converting it with--executable game-child.binstopped with:A RELA entry writes its value rather than adding to the target, so applying an identical entry twice leaves the same result as applying it once. FreeBSD's rtld walks every entry and, for a relative one, assigns
relocbase + addend. The Linux output already passes such a table through unchanged.WindowsRelocationBuilder: skips an entry identical to one already applied at the same target (samer_info, same addend).CodeInstructionCollector): accepts a second relative or defined-symbol pointer at a slot only when it resolves to the same value.Overlapping guest relocations). No module with a duplicate entry is known.duplicate_relocationsis a new test built on #6607's fixtures:RELATIVEentry listed twice converts for Linux, Windows and macOS, and the Windows and macOS pointers are checked.Tested
Windows 11 Pro (26300), WinLibs GCC 15.2.0, Release, full build on
main1f68b1f776:core/relinkerpass,duplicate_relocationsandoverlapping_relocationsamong them.Overlapping ELF relocation targets (offset 0x308). With only the builder change it fails in code analysis withinvalid relative relocation.--executable game-child.bin, it now converts botheboot.binandgame-child.bin.exe. Its run is still blocked elsewhere: its Wine needs0x7ffe0000, which a Windows host already owns.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pylists only #5021 and #6713, which it couldn't compare; they share onlycore/relinker/CMakeLists.txt.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)game-child.bin(the title stays blocked by its fixed0x7ffe0000mapping)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T01:01:02Z.
Review: APPROVED
Reviewed exact head
191f1da02020b1f095cb76247a4105bd3492314a. The Windows builder suppresses only a repeated relocation at the same target with identicalr_infoand addend; distinct/overlapping entries still take the existing rejection path. The code-analysis change likewise accepts duplicate pointer entries only when their resolved target is equal. This matches the relocation write semantics and keeps conflicting-target protection intact.\n\nI built this exact head on Linux with the relinker-only Release configuration and randuplicate_relocationsplusoverlapping_relocations: 2/2 passed. Hosted Linux, Windows, macOS arm64 and macOS x86_64 relinker jobs, ASan, conventions, intake, eligibility and labels all pass. Product and hardware-specific jobs were skipped by path policy. I found no blocking issue.Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-26T01:27:29Z.
Review: APPROVED
Reviewed exact head
191f1da02020b1f095cb76247a4105bd3492314a. The identicalR_X86_64_RELATIVEcase is fixed, and I approve.I built fresh relinker-only Release binaries from this head, current-main pin
0f34ebb8539187e50e028e088093d25c85405d2a, and their clean local integrationeb62eed58e8be9432fd6771dbcb811813e3de5dc(tree8c98f334d7c21316447db71fcf16af54b2a147bd): 88 Ninja steps each, Windows 11 build 26200 / GCC 16.2.0-6 UCRT64 / CMake 4.3.1 / Ninja 1.13.2 / Python 3.14.7. The changed Windows builder, code collector and new test are byte-identical between head and integration.Overlapping ELF relocation targets (offset 0x308).The selected tests are
duplicate_relocations(positive trees),overlapping_relocations,guest_none_relocations,guest_own_tls_relocationsandguest_symbol_names. Every individual test finishes below 30 seconds.Additional independent matrix: 132 real CLI conversions and 24 native Windows executable runs. For each tree:
r_info. This is an existing limitation; these results establish the RELATIVE change rather than general support for repeated imports.For successful Windows cases, the probe changes the synthetic entry point to jump through the relocated relative pointer itself. All 10 head, 10 integration and four main programs return 42. It also checks pointer values, exactly one PE DIR64 base-relocation record per target, the unchanged single import-registry slot, preserved ELF relocation records, and unchanged source/provider bytes. These are synthetic homebrew executions, not the reported title.
Source review also confirms table-type validation precedes the duplicate skip, and different or partially overlapping writes retain the rejection path. The cited pinned FreeBSD relative-relocation implementation assigns base plus addend, consistent with collapsing identical relative entries.
Conventions against pinned
origin/mainand whitespace checks pass for head and integration; all three builds have no compiler warnings. No full product build, full relinker suite, actual title, Linux/macOS execution, console/GPU, performance or hosted-CI result is claimed. This checks integration with the pinned main, not every outstanding PR. AI-assisted: yes.Additional matrix replay
Save the script below and run it with the head checkout, the three executable paths and a JSON output path:
It uses the committed fixture and format parsers. Run on Windows x86-64; it executes each successful generated Windows program.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T05:48:50Z.
Review: CHANGES_REQUESTED
I rechecked the current integration state after the earlier exact-head approval. The implementation and focused regression are still unchanged, and the hosted relinker matrix plus the reported Linux/Windows focused tests passed on the tested revisions. However,
tools/check_main_sync.py --base upstream/main --head 191f1da02020b1f095cb76247a4105bd3492314anow reports 1 commit ahead and 379 behind currentmain(14c99b52ac). The merge preview is clean, butcore/relinker/CMakeLists.txtchanged on both sides since the base.CONTRIBUTING.mdrequires keeping the branch up to date; please refresh and rerunduplicate_relocationsandoverlapping_relocationson the resulting exact head. The prior approval covered191f1dabefore these main changes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:09:53Z.
Review: CHANGES_REQUESTED
I refreshed the exact-head check against current
upstream/main204c6747d0a1cbaf932def3dea0778810cc3935e:191f1da02020b1f095cb76247a4105bd3492314ais 1 ahead / 456 behind. The merge preview is clean, but currentmainhas changedCodeInstructionCollector.cppandcore/relinker/CMakeLists.txtsince the tested base1f68b1f7; in particular, the prior external integration run pinned an older main and does not cover these intervening collector changes. Please rebase and rerunduplicate_relocationsandoverlapping_relocationson the exact new head. The extensive existing Windows/Linux evidence remains useful; this is a current-main integration request.