Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/bap/bap_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ let union_memory m1 m2 =
Memmap.add m1 mem v)


let build ?state ~code ~data arch =
let build ?state ~file ~code ~data arch =
let init = match state with
| Some state -> state
| None -> Kernel.empty arch in
Expand All @@ -258,7 +258,7 @@ let build ?state ~code ~data arch =
program = Program.lift symbols;
symbols;
arch; memory=union_memory code data;
storage = Dict.empty;
storage = Dict.set Dict.empty filename file;
passes=[]
}

Expand All @@ -277,7 +277,7 @@ let create_exn
Signal.send Info.got_arch arch;
Signal.send Info.got_data data;
Signal.send Info.got_code code;
finish @@ build ?state ~code ~data arch
finish @@ build ?state ~file ~code ~data arch

let create
?state ?disassembler ?brancher ?symbolizer ?rooter ?reconstructor input =
Expand Down
7 changes: 6 additions & 1 deletion lib_test/bap_project/test_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ let test_substitute case =
KB.Agent.register name in
Symbolizer.provide agent symbolizer;
Rooter.provide rooter;
let file = "/dev/null" in
let input =
let file = "/dev/null" in
let mem =
Memory.create LittleEndian base (Bigstring.of_string case.code)
|> ok_exn in
Expand All @@ -79,6 +79,10 @@ let test_substitute case =
let s = Option.value_exn (Project.memory p |>
Memmap.find_map ~f:(Value.get tag)) in
expect >:: assert_normalized ~expect s in
let has_filename = "filename-is-provided" >:: fun ctxt ->
match Project.get p filename with
| None -> assert_failure "filename is not set"
| Some file' -> assert_equal ~ctxt ~printer:ident file file' in
[
test case.asm "$asm";
test case.bil "$bil";
Expand All @@ -92,6 +96,7 @@ let test_substitute case =
test min_addr "$addr";
test min_addr "$min_addr";
test max_addr "$max_addr";
has_filename;
]


Expand Down