Repository navigation
fix(relinker): ignore direct branch targets inside an instruction past its prefixes - #7651
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Windows host run, since the description covers macOS only. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
AI-assisted |
… inside an instruction past its prefixes (@DavidSamir) This branch gathers the open macOS work, and this PR is part of it: it is merged here with its author credited, so the integration carries it now and merging it first in main only shrinks this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows check,
AI-assisted: yes |
|
Checked the branch-target rule against |
What
With
--macos --to-rosetta, SuperTuxKart (PPSA69421) and Mortalfin (PPSA99141) stop during instruction conversion:The branch is not real. Both titles link OpenSSL's x86-64 SHA-1 assembly, which keeps its signature string in the code segment, right before
sha1_block_data_order_avx2:The converter collects branch targets from a linear scan of the segment, so the string's
jaelands one byte into the store's VEX prefix and the store is refused. In both titles the only branch to that address is this one: a search of every rel8, rel32 and Jcc rel32 encoding in the file finds no other.Jump-table entries already count as targets only where a scanned instruction starts. This applies a narrower form of that rule to direct branches. A target inside a scanned instruction still counts where every byte before it is a legacy prefix or REX, so a branch that skips a
lockprefix, or the INSERTQ prefixes the existing test uses, still keeps the instruction in place. A target in a VEX prefix, opcode or operand bytes is ignored: executing from there does not run the instruction the scan decoded, and the conversion of that instruction already relies on that decode.Three commits:
fix(relinker): ignore direct branch targets inside an instruction past its prefixestest(relinker): a branch into a 256-bit store and into the instruction moved with it no longer keeps the store. The existing "branch into the compare keeps it native" case now uses the legacycmpsswith a branch past itsF3prefix, which still keeps it native; a new case shows that a branch past the VEX prefix ofvcmpssno longer does (it would executec2 ca 03,ret 0x3ca).docs(debt): the relinker debt file records the rule and what it gives up: a real branch into the middle of an instruction, as overlapping hand-written code can do, is not seen.Tested
macOS 26 on an Apple M2 (MoltenVK 1.4.x, Vulkan SDK 1.4.363), x86-64 build under Rosetta 2, Release, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON).amd64_only_converter_tests: the new cases fail onmain(No room for a jump to the stub of 256-bit store within its neighbours or a nearby islandin the small fixture, where the false target also blocks the neighbour placement) and pass with this change. All other converter cases pass, the INSERTQ "Branch into an AMD-only instruction was accepted" check included.ctest: 192 of 192 pass.hardware_oracle_comparetimed out at 20 s once under-j8and passed alone in 5.6 s.--macos --to-rosettaand theirsce_module:mainBranch enters an AMD-only instructionForbidden syscall instruction at code offset 0xe2c3a7Branch enters an AMD-only instructionUnsupported macOS guest TLS instruction (bytes: 65 6e)libc.prxaborts withThread destructor callback is already registered, Since #6112, every title aborts at start-up on Linux: "Thread destructor callback is already registered" #7636) and @mugurc's macOS library series: the title starts, probes its video decoders, and on this M2 reportsNo device with Vulkan support found. That is the unhinted direct-memory placement in macOS support #1 (comment 6254181383). With that placement worked around locally, it selects the Apple M2 and stops at the MoltenVK pipeline error that fix(shader): preserve raw fragment exports for integer attachments #6235 covers (output of type float4 is not compatible with a MTLPixelFormatR8Uint color attachment). Nothing past that point is tested.--to-intel, but neither title reaches it there.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)--to-rosetta(no bring-up discussion)