fix(relinker): do not take instructions another AMD-only stub moved as a short instruction's followers #8001
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8001"
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 mopga on 2026-10-19T17:15:48Z.
What
A short AMD-only instruction takes the following instructions into its stub until its site fits a jump. That loop did not check which instructions an earlier 256-bit store island had already claimed, so with
--to-rosettatwo trampolines could cover the same bytes.Reproduced with
relinker --to-rosettaon currentmain(jeto the RCPPS,jmpover nothing,vmovups [rdi],ymm0,rcpps xmm1,xmm2, fouradd rax,rcx, padding,ret):74 06 EB 00 C5 FC 11 07 0F 53 CA 48 01 C8 ×4 90 ×8 C3The store's forward window is blocked by the branch target and its backward window by the
jmp, so it is lowered through an island that claims the adds. RCPPS then took the same adds as its followers: the converter returned trampolines at +8 (6 bytes) and +11 (6 bytes), and the conversion failed withAMD-only site bytes changed before patching (offset 0x1008). With RDPID (F3 0F C7 F8) instead of RCPPS the result is the same.A claimed follower now ends the attempt: an optional instruction such as RCPPS, RSQRTPS, RDPID or RDTSCP is kept, and any other instruction fails with an error naming the moved follower instead of producing overlapping sites.
Tested
Windows 11, AMD Ryzen 7 7800X3D (Zen 4), MinGW-w64 GCC 15.2.0 (WinLibs r7), relinker-only build of this branch on current
main:converterClaimedFollowerinAmd64OnlyConverterTests.cpp(RCPPS and RDPID variants; no two trampolines overlap and the short instruction is kept) fails onmainwith overlapping sites and passes with the fix.relinker --to-rosetta.mainthe converted code crashes.ctest: 211/211 passed.python3 tools/check_conventions.py --base origin/mainpasses. A trial merge with the open PRs that change these files (#2780, #7363, #7651, #7660) shows no conflict caused by this change; it also merges cleanly with #7999, which changes the same test file.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T23:18:01Z.
Verdict: confirmed on Windows and Linux, and it works together with #7999.
Environment: Windows 11 Home 10.0.26300, Ryzen 5 9600X (Zen 5), WinLibs GCC 15.2.0 r7, relinker-only Release build. This PR was merged onto
main9127ea36d, alone and together with #7999.test_tls_function_coverage.pymake_imageimage, converted withrelinker --skip-sce-module --to-rosetta. The RCPPS one is74 06 eb 00 c5 fc 11 07 0f 53 ca (48 01 c8)x4 (90)x8 c3.main: rc 2,Intel conversion: 0 in place, 3 stubs, 0 kept,FAIL: AMD-only site bytes changed before patching (offset 0x1248), for both RCPPS and RDPID.2 stubs, 1 kept, for both.Amd64OnlyConverter.cppreverted tomain,amd64_only_converter_testsfails withA short instruction's site overlaps instructions another stub already moved.ctest:-j4because of host load, and also do so onmain, passed on a serial rerun.shader_cache_runtime_sources, fails intermittently onmaintoo.MatchSequenceand this PR adds theclaimedcheck in the follower loop of_convertSegment. An in-place follower that #7999 moves into the stub goes intotaken/consumed, notclaimed, so the two changes don't interact.--windows --to-intel,--macos --to-rosettaand Linux--to-intel. These conversions produce real stubs: 1/5/22/0 under--to-inteland 4495/16745/51131/192 under--to-rosetta, for PPSA47402/PPSA99005/PPSA99581/PPSA99995 respectively, with 0 kept. All 12 output sets are byte-identical tomain, both with this PR alone and combined with #7999. None of these stubs hit the claimed-follower case.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T11:24:02Z.
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.
core/relinker/codegen/tests/Amd64OnlyConverterTests.cpp