Add semantics for adc, ror, shld, shrd, rcl, rcr#3
Open
idkfrancis wants to merge 2 commits into
Open
Conversation
tests/x86_ops.asm assembles to a 1.5KB PE whose entry point uses each new opcode (ADC, ROR, SHLD, SHRD, RCL, RCR) in its imm, register and CL-count forms across 8/16/32/64-bit widths. lift.py picks it up at 0x140001000 so the CI smoke test now dispatches into the new code.
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.
Adds lifters for six x86 integer instructions encountered while lifting obfuscated VM handlers. All semantics follow the Intel SDM Vol 2 pseudocode and reuse the existing helpers (
masked_shift_count,flag_undef,flag_write_if,result_sign_bit,result_parity_even,result_is_zero,add_overflow,write_common_arith_flags).Instructions
DEST + SRC + CF. CF detects unsigned overflow with carry-in (ULT(result, dst) OR (EQ(result, dst) AND cf_in)). OF uses the standard add-overflow formula on(dst, src, result)— this stays correct under carry-in becausecf_inis a low-position addend and does not affect the sign-bit XOR pattern.2*width-bit concatenation (dst:srcfor SHLD,src:dstfor SHRD) shifted bycount. CF is the last bit shifted out ofdst. PF/ZF/SF/AF and the OF-on-1-bit case are handled by a shareddouble_shift_flagshelper.(width+1)-bit concatenation packing CF as the high bit. The effective rotation count iscount % (width + 1). New CF is the high bit of the rotated wide value. For 1-bit RCL, OF =MSB(result) XOR new_CF(post-rotation per SDM); for 1-bit RCR, OF =MSB(dst) XOR cf_in(pre-rotation per SDM).All instructions zero-update flags only when the masked count is non-zero, matching the existing SHL/SHR/SAR/ROL pattern. Stub semantics for instructions where state is not tracked (e.g. STD/CLD, RDTSC, string ops) are intentionally not part of this PR.
Verification
uv run lift.pyruns to completion against the existing sample binaries with no errors (14480 lines of IR emitted).src == 0xFFandcf == 1).