Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eBPF bswap16/32/64 instruction #2323

Merged
merged 1 commit into from
Apr 23, 2024
Merged

Conversation

chengshuyi
Copy link
Contributor

@chengshuyi chengshuyi commented Apr 15, 2024

Your checklist for this pull request

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

Detailed description

Supports bswap16/32/64 instructions. Different from the le or be instructions, the opcode of bswap is BPF_ALU64.

// copy from: https://docs.kernel.org/bpf/standardization/instruction-set.html
BPF_ALU64 | BPF_TO_LE | BPF_END with imm = 16/32/64 means:

  dst = bswap16(dst)
  dst = bswap32(dst)
  dst = bswap64(dst)

...

Test plan

test case in suite/cs_test/issues.cs

...

Closing issues

None
...

@github-actions github-actions bot added the BPF Arch label Apr 15, 2024
Copy link
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition!

Please fill out the complete PR template. Not just the description. No need document the functions. Since this plugin gets refactored to auto-sync sooner or later anyways.

Necessary though is a test case in suite/cs_test/issues.cs.

arch/BPF/BPFMapping.c Show resolved Hide resolved
Signed-off-by: Shuyi Cheng <chengshuyi@linux.alibaba.com>
Copy link
Member

@kabeor kabeor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thank you!

@kabeor kabeor merged commit c4d0993 into capstone-engine:next Apr 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BPF Arch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants