Skip to content

Commit 6c0306f

Browse files
committed
makes all plugins compilable under modern BAP and Core
this all mostly about ~equal and polymorphic compare
1 parent 3a89828 commit 6c0306f

29 files changed

+61
-187
lines changed

checkpath/checkpath.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ let string_of_point project point =
2626
(** [touches point block] true if block ends up with a call to
2727
[point] *)
2828
let touches point block =
29-
Bil.exists (object
30-
inherit [unit] Bil.finder
31-
method enter_int target search =
32-
if in_jmp && target = point then
33-
search.return (Some ());
34-
search
35-
end) (Insn.bil (Block.terminator block))
29+
Insn.bil (Block.terminator block) |>
30+
List.exists ~f:(Stmt.exists (object
31+
inherit [unit] Stmt.finder
32+
method enter_int target search =
33+
if in_jmp && target = point then
34+
search.return (Some ());
35+
search
36+
end))
3637

3738

3839
let dfs cfg blk =

fold_consts/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let stack_offset = 0x40000000L
77

88
let simpl_load lookup =
99
Exp.map (object(self)
10-
inherit Bil.mapper as super
10+
inherit Stmt.mapper as super
1111
method! map_load ~mem ~addr endian size =
1212
match lookup ~mem ~addr endian size with
1313
| None -> super#map_load ~mem ~addr endian size

minos/color.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ let to_terminal = function
3131
| Purple -> "\x1b[35m"
3232
| White -> "\x1b[37m"
3333

34-
let make_color_map l c =
35-
List.fold l ~init:[] ~f:(fun acc name ->
36-
List.Assoc.add acc name c)
3734

3835
let (!) = to_int
3936
let (!!) = to_terminal

minos/ctxt.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ type t = {
1515
trim : trim;
1616
max_depth : int; (** depth to go to before terminating path *)
1717
sample: int; (** number of paths to sample *)
18-
g : (module Graphlib.Graph with type edge = Graphs.Tid.edge and
18+
g : (module Graph with type edge = Graphs.Tid.edge and
1919
type node = tid and type t = Graphs.Tid.t)
2020
}

minos/dependence.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ let inter_dep deps1 deps2 =
104104
Tid.Set.inter (Tid.Set.of_list (Seq.to_list deps2)) |>
105105
Tid.Set.to_sequence
106106

107+
let equal = Polymorphic_compare.equal
108+
107109
let highlight_cli ?(highlight=[]) (ctxt : Check.ctxt) sub dependence =
108110
let open Color in
109111
let output = "" in
@@ -127,15 +129,15 @@ let highlight_cli ?(highlight=[]) (ctxt : Check.ctxt) sub dependence =
127129
Seq.fold ~init:output ~f:(fun output elt ->
128130
match elt with
129131
| `Def def ->
130-
(match List.Assoc.find highlight (Term.tid def) with
132+
(match List.Assoc.find ~equal highlight (Term.tid def) with
131133
| Some color ->
132134
let s = Format.sprintf "%s\n" (color^to_string_def def^no) in
133135
output^s
134136
| None ->
135137
let s = Format.sprintf "%s\n" @@ to_string_def def in
136138
output^s)
137139
| `Jmp jmp ->
138-
(match List.Assoc.find highlight (Term.tid jmp) with
140+
(match List.Assoc.find ~equal highlight (Term.tid jmp) with
139141
| Some color ->
140142
let s = Format.sprintf "%s\n" (color^to_string_jmp jmp^no) in
141143
output^s
@@ -150,7 +152,7 @@ let highlight_cli ?(highlight=[]) (ctxt : Check.ctxt) sub dependence =
150152
let output sub' arg_dependence jmp_dependence sink_intersect_dependence jmp_tids
151153
(ctxt : Check.ctxt) =
152154
let open Color in
153-
let add_color = List.Assoc.add in
155+
let add_color = List.Assoc.add ~equal in
154156
let add_aqua l tid = add_color l tid !!Aqua in
155157
let add_red l tid = add_color l tid !!Red in
156158
let add_green l tid = add_color l tid !!Green in

minos/interprocedural.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ let inline_sub_called_by_blk project ccall callsite_tid blk sub =
9999
(** For a blk with a call, inline the call and return an updated
100100
global sub. Skip recursive. *)
101101
let inline_update_blk project sub blk_name (filtr: Filter.t) =
102-
let blk = Util.blk_of_tid sub @@ Tid.(!blk_name) in
102+
let blk = Util.blk_of_tid sub @@ Tid.(!!blk_name) in
103103
match Util.calls_of_blk_with_tid blk with
104104
| [] -> sub,[]
105105
| [(callsite_tid,ccall)] when not (filtered_call ~f:filtr ccall) ->
@@ -119,7 +119,7 @@ let inline project sub (filtr : Filter.t) =
119119

120120
let make_color_map l c =
121121
List.fold l ~init:[] ~f:(fun acc name ->
122-
List.Assoc.add acc name c)
122+
List.Assoc.add ~equal:Polymorphic_compare.equal acc name c)
123123

124124
(** Inline n times. Note we don't have to fail if we detect mutually
125125
recursive calls. Just warn. *)

minos/mem_to_reg.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let print_store_map =
1313
(* We might see:
1414
000000f4: t_167 := mem64[0x601050:64, el]:u8*)
1515
let mem_read_to_var exp =
16-
(object inherit Bil.mapper
16+
(object inherit Stmt.mapper
1717
method! map_load ~mem ~addr endian size =
1818
match addr with
1919
| Bil.Int addr ->
@@ -22,7 +22,7 @@ let mem_read_to_var exp =
2222
| exp ->
2323
(* binop mapper so we hit every instance of a mem read in an
2424
expression *)
25-
(object inherit Bil.mapper
25+
(object inherit Stmt.mapper
2626
method! map_binop op o1 o2 =
2727
let orig = Bil.binop op o1 o2 in
2828
match (op,o1,o2) with

minos/path_producer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ let produce project options path_dir trim_dir trim check =
272272
*)
273273
let sub' = view_to_sub filtered_graph graph sub |> kill_non_existing_jmps in
274274

275-
let module G' = (val filtered_graph : Graphlib.Graph with
275+
let module G' = (val filtered_graph : Graph with
276276
type edge = Graphs.Tid.edge and
277277
type node = tid and
278278
type t = Graphs.Tid.t) in

minos/pathlib.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ let debug succs blk =
6969
Format.printf "\n%!"
7070

7171
let rec fold_paths_graph ?(rev=false)
72-
(module G : Graphlib.Graph with
72+
(module G : Graph with
7373
type edge = Graphs.Tid.edge and
7474
type node = tid and
7575
type t = Graphs.Tid.t)

minos/pathlib.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val fold_paths:
3131
representation. Supports reverse traversal. *)
3232
val fold_paths_graph :
3333
?rev:bool ->
34-
(module Graphlib.Graph
34+
(module Graph
3535
with type edge = Graphs.Tid.edge and
3636
type node = tid and
3737
type t = Graphs.Tid.t) ->

0 commit comments

Comments
 (0)