Created
January 28, 2021 21:17
-
-
Save ivg/d3d844f75a7783545bbc8cfb6dc3d1e1 to your computer and use it in GitHub Desktop.
implements a `lisp-demo` command in bap that translates lisp programs into BIL programs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Core_kernel | |
open Bap.Std | |
open Bap_core_theory | |
open Bap_main | |
open Bap_primus.Std | |
open KB.Syntax | |
let show name = | |
Toplevel.exec @@ begin | |
Primus.Lisp.Unit.create Theory.Target.unknown >>= fun unit -> | |
KB.Object.scoped Theory.Program.cls @@ fun obj -> | |
KB.sequence [ | |
KB.provide Theory.Label.unit obj (Some unit); | |
KB.provide Theory.Label.name obj (Some name); | |
] >>= fun () -> | |
KB.collect Theory.Semantics.slot obj >>| fun sema -> | |
Format.eprintf "%s:@ %a@." name Bil.pp (Insn.bil sema) | |
end | |
let () = | |
let open Extension in | |
let names = Command.arguments Type.string in | |
Extension.Command.(declare "lisp-demo" (args $ names)) | |
@@ fun names _ctxt -> | |
List.iter ~f:show names; | |
Ok () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Building
Running
--primus-lisp-load
parameter and passing the list of definitions that you like to be printed,It shall print something like this (give the example above),