fix(relinker): classify rewrite reference sites with the instruction decoder #1393
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1393"
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 xsvm on 2026-10-08T01:39:36Z.
What
X64InstructionRewriter::ClassifyInstructionassumed that every opcode other than a near branch is followed by a ModRM byte. During a length-changing rewrite this:MOVABS rax, imm64whose low byte is05;C5/C4) and0F 38/0F 3Ainstructions;E0-E3).It now takes the RIP-relative displacement offset and the branch target from
X64InstructionDecoder::DecodeInstruction.Rel32InstructionLengthbecame unused and is removed.The converter currently only rewrites in place with equal length, so this affects the
Rewritecontract and length-changing callers (as exercised byrewriterStrayRex), not today's--to-inteloutput.The rewriter entry in TechnicalDebt no longer lists VEX/0F38/0F3A RIP-relative operands among the references it does not adjust.
Tested
amd64_only_converter_testsfrom the CMake source list; the newrewriterReferenceSitescases (MOVABS imm64, VEX RIP load,66 0F 38 00RIP load, LOOP rel8) fail on currentmainand pass with the fix. The rest of the suite, including the*Executiontests, passes.DecodeInstruction's RIP-relative flag/offset and branch displacement match Capstone 5 on 2.6M instructions from system DLLs and 27k synthetic encodings including EVEX.mainafter #1218 was merged; its TechnicalDebt edit is on the adjacent line and both edits are kept. #1163, #1168, #1303 and #1381 are already inmain.python tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T13:03:45Z.
Checked: build + full ctest on this head merged onto current
main(452/452). With the code change reverted and the test kept,amd64_only_converterfails, so the newrewriterReferenceSitescases (imm6405, VEX and0F 38RIP loads, LOOP rel8) pin the fix.ClassifyInstructiononly receives the matched instruction length, so the decoder never reads past it;FF /2andFF /4RIP-relative still go through the RIP branch. The TechnicalDebt line is correct. Merging once CI is green.