fix(relinker): decode UD1 as a trap #1457
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1457"
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 drk1rd on 2026-10-08T07:39:51Z.
What
UD1(0F B9 /r) always raises #UD, likeUD2(Intel SDM Vol. 2B "UD—Undefined Instruction"; AMD APM Vol. 3 "UD1"), butDecodeInstructionreported it asSequential. The control-flow walk and the strict reachability analysis then followed the bytes after it, so an import reachable only through that fallthrough was kept by the strict unused NID filter.UD1is now aTrap. It keeps its ModRM, so a RIP-relative operand is still reported.Found by comparing
X64InstructionDecoderagainst iced-x86 (AMD decoder options) over ~326k encodings: lengths and RIP-relative offsets matched except for opcodes already fixed in #1163, #1168 and #1381. Clang emitsUD1for-fsanitize-trap.UD0is left alone: its ModRM differs between Intel and AMD.Tested
Windows 11 (10.0.26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
-DBUILD_TESTING=ON. Fullctest: 419/419 pass. The new checks instrict_nid_filterandamd64_only_converterfail without the decoder change.check_conventions.pyandpr_overlap.py --branchare clean.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 Zheorgyan on 2026-10-08T08:43:16Z.
heads up, this and #1381 merge cleanly but don't build together. #1381 changes the
readModRmlambda inDecodeInstructionto take(modrmPos, registerOnly), and the new UD1 branch here still callsreadModRm(pos), so whichever lands second breaks main. if #1381 goes in first the fix is justreadModRm(pos, false)I checked by merging both heads into current main and building
X64InstructionDecoder.cppwith GCC 14, each one builds fine on its ownImported from boykopovar/AnyPS5. Originally posted by drk1rd on 2026-10-08T09:58:06Z.
Thanks for catching this. #1381 is merged now, so I rebased onto main and the UD1 branch calls
readModRm(pos, false). Rebuilt and ran the fullcteston Windows (GCC 15.2.0): 429/429 pass.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T14:17:03Z.
Checked on current
main(PR merged on top): build + full ctest 459/459. With the decoder change reverted,amd64_only_converterandstrict_nid_filterboth fail, so the new cases pin the fix. UD1 raising #UD matches the SDM/APM, the ModRM/RIP-relative operand is kept, andreadModRm(pos, false)is consistent with #1381. Merging once CI is green.