Repository navigation
fix(relinker): do not take instructions another AMD-only stub moved as a short instruction's followers - #8001
Merged
oneandonlydean merged 1 commit intoOct 20, 2026
Conversation
…s a short instruction's followers A short AMD-only instruction takes the following instructions into its stub until its site fits a jump. The loop did not check which instructions an earlier 256-bit store island had already claimed, so with --to-rosetta two trampolines covered the same bytes: for je; jmp; vmovups [rdi],ymm0; rcpps xmm1,xmm2 followed by adds, the RCPPS site at +8 overlapped the island at +11, the patched code crashed, and the real patchers failed with 'AMD-only site bytes changed before patching'. A claimed follower now ends the attempt: an optional instruction such as RCPPS or RDPID is kept, and any other instruction fails with an error naming the moved follower. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
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
AI-assisted: yes (Claude Code); results above were run on this machine. |
11 tasks done
|
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (feat(relinker): lower MCOMMIT and RDPRU for Intel with execution tests #2780, fix(relinker): synthesise a non-executable PT_GNU_STACK for Linux executables #7363, fix(relinker): ignore direct branch targets inside an instruction past its prefixes #7651, fix(relinker): resume scans after undecodable bytes between PS4 unwind functions #7660) shows no conflict caused by this change; it also merges cleanly with fix(relinker): move in-place AMD-only replacements into a short instruction's stub #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