Open ivg opened 7 years ago
The impact of the current strategy is limited by the 16-byte size of the memory buffer being passed in. That being said, using the second interface seems nice assuming that a single bap_basic_disasm_t
object can be used arbitrarily (my intent would be to hide this inside bap-rust
and have it just create it once and keep reusing it).
It looks like that you're calling a disasm function with one root, and taking only the first instruction. However, depending on the place of the root, you may actually get the whole binary disassembled, and you will take only first instruction). Algorithmically, it makes your disassembler to be O(N^2). With a huge constant factor.
What you really need is a function of type
There is no such function in
Bap.Std
however it can be relatively easy implemented usingDisasm_expert
interface (that is currently not exposed in bindings, and most likely will not be exposed - as the interface is a thin wrapper on top of the C interface, that only adds strict type discipline). Here is a prototype (untested):This approach has a slight overhead, as we need to create a disassembler every time, and lookup for a target, etc. Given that insn disassembly is a very tight loop, then the following interface would be nicer:
that will map to
However, this interface would require some changes from your side (you need to pass the disassembler handler.
So it's your call which interface you prefer, I can push it quite fast to the bindings.