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.
Summary
Mode
CS_ARCH_BPF, CS_MODE_BPF_EXTENDED
does not correctly handle some forms of thelddw
instruction.Expected
Actual
Background
The
BPF_CLASS_LD
opcode class allows three modes of operation and four sizes (b
,h
,w
,dw
).For all four sizes, the following two "legacy" modes are supported. Capstone disassembles these 8 opcodes correctly. These are one of the few opcodes that have an implicit write operation (move to
r0
)BPF_MODE_ABS
:lddw [0x1234]
: Load value at immediate absolute address into implicit r0BPF_MODE_IND
:lddw [r3+0x1234]
: Load value at address in source register plus immediate offset into implicit r0For
dw
only, there is a third possible mode.BPF_MODE_IMM
:lddw r5, 0x1234123412341234
: Move immediate value into destination register (dw
size only)Capstone incorrectly disassembles
lddw
withBPF_MODE_IMM
aslddw <imm>
with implicit r0 instead of the destination register. Expected islddw <reg> <imm>
.Changes
This patch introduces the following changes for this opcode:
lddw r*, <imm>