From 06d5d5f1959df4e67ca695aa3dbfb77ddd70b5c0 Mon Sep 17 00:00:00 2001 From: ivg Date: Wed, 28 Oct 2020 17:17:37 -0400 Subject: [PATCH] hoists unit in the disassemble function The same justification - a single piece of memory always belong to the same unit. --- lib/bap_disasm/bap_disasm_driver.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bap_disasm/bap_disasm_driver.ml b/lib/bap_disasm/bap_disasm_driver.ml index 1019a5263..623f00e00 100644 --- a/lib/bap_disasm/bap_disasm_driver.ml +++ b/lib/bap_disasm/bap_disasm_driver.ml @@ -408,12 +408,13 @@ let switch encoding s = | Error _ -> s | Ok dis -> Dis.switch s dis - let disassemble ~code ~data ~funs debt base : Machine.state KB.t = + unit_for_mem base >>= fun unit -> let rec next_encoding state current mem f = let addr = Memory.min_addr mem in KB.Object.scoped Theory.Program.cls @@ fun obj -> KB.provide Theory.Label.addr obj (Some (Word.to_bitvec addr)) >>= fun () -> + KB.provide Theory.Label.unit obj unit >>= fun () -> get_encoding obj >>= fun encoding -> if Theory.Language.is_unknown encoding.coding then if Theory.Language.is_unknown current.coding