Skip to content

x86: fix near RET decoding with 0x66 and REX.W - #3049

Open
raaller wants to merge 1 commit into
capstone-engine:nextfrom
raaller:fix/x86-ret-imm16-rexw
Open

x86: fix near RET decoding with 0x66 and REX.W#3049
raaller wants to merge 1 commit into
capstone-engine:nextfrom
raaller:fix/x86-ret-imm16-rexw

Conversation

@raaller

@raaller raaller commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

In 64-bit mode, 66 48 C2/C3 selected the 16-bit near-RET decoder entry. For C2, this also made the decoder expect a four-byte immediate even though RET always encodes its stack adjustment as imm16.

Test plan

Add regression tests for both C2 and C3 with the operand-size override and REX.W:

  • 66 48 C2 3B 01 decodes as ret 0x13b with a two-byte immediate and the mode64 group.
  • 66 48 C3 decodes as ret with the mode64 group.

All tests passed

Closing issues

Closes #3038.

@github-actions github-actions Bot added the X86 Arch label Aug 28, 2026
@raaller
raaller force-pushed the fix/x86-ret-imm16-rexw branch from 620dc73 to 2777dad Compare August 28, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

X86 Arch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X86-64 decode incorrectly for 0x66 RET

1 participant