-
Notifications
You must be signed in to change notification settings - Fork 9
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
lift_insn.c
yields an empty sequence of instructions
#19
Comments
The translation is pretty faithful, but you have to initialize bap before using it, e.g., I can't say right now what is wrong with the C example, I am on vacation, typing from a phone, but if after you add the initializations the OCaml version still doesn't work, then the problem is with the installation of BAP |
Thanks for the response (during your vacation, nonetheless!). I added a call to Following your advice, I did an entire clean installation of BAP (from I don't expect a swift response as I don't want to distract you from your vacation. I'll continue to play around with it in the meantime. Thanks. |
resolves #19 The example was buggy as the size of the pointer was specified incorrectly. It was acceptable before but is not longer tolerated after we enabled [interworking][1] (several architectures in the same binary). [1]: BinaryAnalysisPlatform/bap#1226
I am back :) Thanks to your failfull translation to OCaml it was easy to find the problem. The example was always buggy but up until 2.2.0 the bug was tolerated by bap. Thanks for reporting it and translating the example to OCaml! Besides, here is the OCaml code with proper initialization, just for the sake of completeness, open Bap.Std
open Core_kernel
open Result.Monad_infix
let code = "\x48\x8d\x00\x48\x83\xec\x08\x48\x83\xc4\x08\xe8\x47\xee\xff\xff"
let buff = Bigstring.of_string code
let base = Word.of_int ~width:64 0x80000
let (>>) f g x = g (f x)
let run_example () =
Memory.create LittleEndian base buff >>=
Disasm.of_mem `x86_64 >>| fun d ->
Seq.iter (Disasm.insns d) ~f:(fun (mem,insn) ->
Format.printf "%a: %s@\n"
Addr.pp (Memory.min_addr mem)
(Insn.asm insn))
let () = match Bap_main.init () with
| Error err ->
Format.eprintf "Failed to initialize bap: %a@."
Bap_main.Extension.Error.pp err
| Ok () -> match run_example () with
| Ok () ->
Format.printf "Done@.";
()
| Error err ->
Format.eprintf "The example failed: %a@." Error.pp err |
I'm currently using BAP 2.3.0 and the only program from
examples/
that doesn't work as expected islift_insn.c
.I'm not really familiar with the overall BAP API so this could just be a API-versioning/usage thing that I'm unaware of.
If you insert this immediately after
insns
's definition, it will printempty = 1
.As a result, running the compiled
lift_insn.native
executable only prints:Similarly, in my efforts to transliterate the example into OCaml, I also get the effect that the sequence is empty (in that nothing is printed):
I'm unsure if what I've done above is a faithful(-enough) translation.
Any assistance or clarification would be much appreciated.
Thanks.
The text was updated successfully, but these errors were encountered: