fix(relinker): report RIP-relative operands of VEX, EVEX and 0F38/0F3A instructions #432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/432"
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 adriadam10 on 2026-10-03T06:10:48Z.
What
X64InstructionDecoder::DecodeInstructionnever reported a RIP-relative operand for:What this breaks:
--to-intel: an EXTRQ/INSERTQ site shorter than ajmp rel32takes the next instructions into the stub only if they can move, and RIP-relative ones can't (Amd64OnlyConverter.cpp). A followingvmovdqa xmm0, [rip+x]orpshufb xmm0, [rip+x]was copied into the stub with its displacement unchanged, so it loaded from the wrong address without any error. Now the relink fails with "cannot move", like for the other RIP-relative instructions.unused-filter=2(StrictReachability): references from these instructions to import slots and pointer slots were missing. GOT loads usemov, so I don't know of a title where this changes the result.Fix: read ModRM after the VEX/EVEX payload and the 0F38/0F3A opcode byte, through one shared helper. The only VEX opcode with no ModRM (
0F 77, VZEROUPPER/VZEROALL) is also the whole instruction, so the existingpos < Lengthguard covers it.Tested
Linux x86-64, no title.
Amd64OnlyConverterTests.cpp:decoderRipRelative: VEX2, VEX3, EVEX, 0F38 and 0F3A loads report the displacement at the right offset. Register forms,[rax]and VZEROUPPER are not reported.converterRipRelativeFollower: a short register-form EXTRQ followed by each of those loads now fails at the follower's offset. The register forms still go into the stub.main. Negative checks: removing each piece (VEX ModRM read, 0F38/0F3A in the ModRM list, the third-byte skip) makes the test fail again.objdump(operand[rip±d]and the resolved displacement). Onmain, 79 827 RIP-relative instructions were not reported. With this PR, 0 missed, 0 false positives, 0 wrong displacement offsets out of 870 483 RIP-relative instructions.ctest: 125/125.Out of scope, seen in the same sweep:
Decodegives EVEXF6/F7(e.g.vpsadbw zmm) one byte too many because the TEST-immediate rule doesn't exclude EVEX. Zen 2 has no AVX-512, so it can't show up in a PS5 binary.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)