Coder Social home page Coder Social logo

Support Compressed Instructions about bn-riscv HOT 10 OPEN

f0rki avatar f0rki commented on September 25, 2024
Support Compressed Instructions

from bn-riscv.

Comments (10)

f0rki avatar f0rki commented on September 25, 2024 1

@fabianfreyer curl https://keybase.io/f0rki/pgp_keys.asc | gpg --import then [email protected] if you really insist on pgp :P

from bn-riscv.

fabianfreyer avatar fabianfreyer commented on September 25, 2024

capstone-engine/capstone#1682 was merged, closing capstone-engine/capstone#1594. What would need to happen for this to work?

from bn-riscv.

f0rki avatar f0rki commented on September 25, 2024

You're right. I missed that. I did a quick check with the latest capstone from the next branch and adapted the lifter a bit.

The compressed instructions are prefixed with c. and mostly omit the first parameter compared to the uncompressed version, i.e. c.add rX, rY is equal to add rX, rX, rY so the lifting should work for many of the compressed instructions by simply prepending op[0] to the list of operands.

Check out the latest commit, which contains some progress but is far from complete.

from bn-riscv.

fabianfreyer avatar fabianfreyer commented on September 25, 2024

hmm, I'm having trouble even getting these disassembled. For example, the following compressed bytes disassemble fine using capstone directly:
image

>>> CODE=b"]q\x86\xc6\xa2\xc4\xa6\xc2\xca\xc0."
>>> from capstone import *
>>> md = Cs(CS_ARCH_RISCV, CS_MODE_RISCV64 | CS_MODE_RISCVC)
>>> list(md.disasm(CODE, 0xffd005be))
[<CsInsn 0xffd005be [5d71]: c.addi16sp sp, -0x50>, <CsInsn 0xffd005c0 [86c6]: c.swsp ra, 0x4c(sp)>, <CsInsn 0xffd005c2 [a2c4]: c.swsp s0, 0x48(sp)>, <CsInsn 0xffd005c4 [a6c2]: c.swsp s1, 0x44(sp)>, <CsInsn 0xffd005c6 [cac0]: c.swsp s2, 0x40(sp)>]

However, in the disassembly view, they don't appear:
image

from bn-riscv.

f0rki avatar f0rki commented on September 25, 2024

@fabianfreyer could you post the binary you are testing on here in this issue? otherwise it is hard to reproduce the problem.

I think addi16sp is not lifted at all currently, but this doesn't explain what you are seeing as it should be disassembled. However, I am also not sure what you are seeing is an issue of this plugin? Is bn-riscv using the right capstone?

from bn-riscv.

fabianfreyer avatar fabianfreyer commented on September 25, 2024

I'll send you a binary that exhibits this problem - to the email address at https://f0rki.at/pages/about.html?

Is bn-riscv using the right capstone?

the IL above is from the bn python view, so yes, it seems so?

I don't mind adding to the lifter, I'd just like to see it disassemble first ;)

from bn-riscv.

f0rki avatar f0rki commented on September 25, 2024

strange. Yeah you can send it to me via mail or directly attach it to this issue if the binary is public (just drag and drop should work).

from bn-riscv.

fabianfreyer avatar fabianfreyer commented on September 25, 2024

Ah, can't find it on the webpage - there seems to be no sidebar? Also your gpg key 404's ;)

from bn-riscv.

f0rki avatar f0rki commented on September 25, 2024

@fabianfreyer I can't reproduce this. I am using binary ninja 2.1.2475-dev (Build ID c7d4e572) + today's capstone next branch.

image

from bn-riscv.

fabianfreyer avatar fabianfreyer commented on September 25, 2024

weird, also using the same capstone, just installed it again.
image

Either way, you're probably right and this is not an issue with this plugin. I'll dig into that separately then. Thanks for double-checking!

from bn-riscv.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.