From 82c93b49cf3d6217c0b4e3fc0f628d5d8a75f01e Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Fri, 5 Jun 2020 08:55:15 -0700 Subject: [PATCH 01/10] adds radare2 symbolizer --- oasis/radare2 | 15 ++++++++ opam/opam | 4 +++ plugins/radare2/.merlin | 4 +++ plugins/radare2/radare2_main.ml | 62 +++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 oasis/radare2 create mode 100644 plugins/radare2/.merlin create mode 100644 plugins/radare2/radare2_main.ml diff --git a/oasis/radare2 b/oasis/radare2 new file mode 100644 index 0000000000..cf74eea978 --- /dev/null +++ b/oasis/radare2 @@ -0,0 +1,15 @@ +Flag radare2 + Description: Build radare2 plugin + Default: false + +Library objdump_plugin + Build$: flag(everything) || flag(objdump) + Path: plugins/radare2 + FindlibName: bap-plugin-radare2 + CompiledObject: best + BuildDepends: bap, re.pcre, regular, bap-core-theory, + bap-future, core_kernel, bap-knowledge, + zarith, bitvec, radaer2, yojson + InternalModules: Radare2_main + XMETADescription: use radare2 to provide a symbolizer + XMETAExtraLines: tags="objdump, radare2" diff --git a/opam/opam b/opam/opam index 73582a43fb..dabd5defcb 100644 --- a/opam/opam +++ b/opam/opam @@ -32,6 +32,8 @@ depends: [ "parsexp" "bap-signatures" "z3" + "radare2" + "yojson" "result" {= "1.4"} ] depopts: ["conf-ida" "conf-binutils"] @@ -90,6 +92,7 @@ install: [ ["ocamlfind" "remove" "bap-plugin-emit_ida_script"] ["ocamlfind" "remove" "bap-plugin-ida"] ["ocamlfind" "remove" "bap-plugin-glibc_runtime"] + ["ocamlfind" "remove" "bap-plugin-radare2"] ["ocamlfind" "remove" "bap-plugin-objdump"] ["ocamlfind" "remove" "bap-plugin-llvm"] ["ocamlfind" "remove" "bap-plugin-legacy_llvm"] @@ -201,6 +204,7 @@ remove: [ ["ocamlfind" "remove" "bap-plugin-emit_ida_script"] ["ocamlfind" "remove" "bap-plugin-ida"] ["ocamlfind" "remove" "bap-plugin-glibc_runtime"] + ["ocamlfind" "remove" "bap-plugin-radare2"] ["ocamlfind" "remove" "bap-plugin-objdump"] ["ocamlfind" "remove" "bap-plugin-llvm"] ["ocamlfind" "remove" "bap-plugin-legacy_llvm"] diff --git a/plugins/radare2/.merlin b/plugins/radare2/.merlin new file mode 100644 index 0000000000..45cfd91b31 --- /dev/null +++ b/plugins/radare2/.merlin @@ -0,0 +1,4 @@ +PKG bap +PKG radare2 +B ../../_build/plugins/radare2 +REC diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml new file mode 100644 index 0000000000..5a0ab0a572 --- /dev/null +++ b/plugins/radare2/radare2_main.ml @@ -0,0 +1,62 @@ +open Bap_core_theory +open Core_kernel +open Bap_future.Std +open Bap.Std +include Self() + +open KB.Syntax + +let agent = + KB.Agent.register ~package:"bap.std" "radare2-symbolizer" + ~desc:"extracts symbols radare2" + +let provide_roots funcs = + let promise_property slot = + KB.promise slot @@ fun label -> + KB.collect Theory.Label.addr label >>| function + | None -> None + | Some addr -> + let addr = Bitvec.to_bigint addr in + Option.some_if (Hashtbl.mem funcs addr) true in + promise_property Theory.Label.is_valid; + promise_property Theory.Label.is_subroutine + +let provide_radare2 file = + let funcs = Hashtbl.create (module struct + type t = Z.t + let compare = Z.compare and hash = Z.hash + let sexp_of_t x = Sexp.Atom (Z.to_string x) + end) in + let accept name addr = Hashtbl.set funcs addr name in + let extract name json = Yojson.Basic.Util.member name json in + try + let symbol_list = Yojson.Basic.Util.to_list (R2.with_command_j "aaa;aflj" file) in + List.fold symbol_list ~init:() ~f:(fun () symbol -> + accept (Yojson.Basic.Util.to_string (extract "name" symbol)) (Yojson.Basic.Util.to_int (extract "offset" symbol) |> Z.of_int) + ); + if Hashtbl.length funcs = 0 + then warning "failed to obtain symbols"; + let symbolizer = Symbolizer.create @@ fun addr -> + Hashtbl.find funcs @@ + Bitvec.to_bigint (Word.to_bitvec addr) in + Symbolizer.provide agent symbolizer; + provide_roots funcs + with _ -> warning "failed to use radare2";() + + + +let main = Stream.observe Project.Info.file @@ provide_radare2 + +let () = + Config.manpage [ + `S "DESCRIPTION"; + `P "This plugin provides a symbolizer based on radare2."; + `S "EXAMPLES"; + `P "To view the symbols after running the plugin:"; + `P "$(b, bap) $(i,executable) --no-objdump --dump-symbols "; + `P "To view symbols without this plugin:"; + `P "$(b, bap) $(i,executable) --no-objdump -no-radare2-main --dump-symbols"; + `S "SEE ALSO"; + `P "$(b,bap-plugin-objdump)(1)" + ]; + Config.when_ready (fun {get=_} -> main) \ No newline at end of file From fc8e16ad466e011742477f98c07adec35c82b9a3 Mon Sep 17 00:00:00 2001 From: phosphorus Date: Sat, 6 Jun 2020 00:02:58 +0800 Subject: [PATCH 02/10] Fixes errors within oasis file --- oasis/radare2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oasis/radare2 b/oasis/radare2 index cf74eea978..47cc826c00 100644 --- a/oasis/radare2 +++ b/oasis/radare2 @@ -3,7 +3,7 @@ Flag radare2 Default: false Library objdump_plugin - Build$: flag(everything) || flag(objdump) + Build$: flag(everything) Path: plugins/radare2 FindlibName: bap-plugin-radare2 CompiledObject: best @@ -12,4 +12,4 @@ Library objdump_plugin zarith, bitvec, radaer2, yojson InternalModules: Radare2_main XMETADescription: use radare2 to provide a symbolizer - XMETAExtraLines: tags="objdump, radare2" + XMETAExtraLines: tags="symbol, radare2" From c2cf0de847e2e487ff76f62cc4da7f894db59667 Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Fri, 5 Jun 2020 23:01:25 -0700 Subject: [PATCH 03/10] fixes silly mistakes --- oasis/radare2 | 8 ++++---- plugins/radare2/radare2_main.ml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/oasis/radare2 b/oasis/radare2 index 47cc826c00..4610686baf 100644 --- a/oasis/radare2 +++ b/oasis/radare2 @@ -2,14 +2,14 @@ Flag radare2 Description: Build radare2 plugin Default: false -Library objdump_plugin - Build$: flag(everything) +Library radare2_plugin + Build$: flag(everything) || flag(radare2) Path: plugins/radare2 FindlibName: bap-plugin-radare2 CompiledObject: best BuildDepends: bap, re.pcre, regular, bap-core-theory, bap-future, core_kernel, bap-knowledge, - zarith, bitvec, radaer2, yojson + zarith, bitvec, radare2, yojson InternalModules: Radare2_main XMETADescription: use radare2 to provide a symbolizer - XMETAExtraLines: tags="symbol, radare2" + XMETAExtraLines: tags="symbolizer, radare2" diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index 5a0ab0a572..6710e7f07a 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -55,7 +55,7 @@ let () = `P "To view the symbols after running the plugin:"; `P "$(b, bap) $(i,executable) --no-objdump --dump-symbols "; `P "To view symbols without this plugin:"; - `P "$(b, bap) $(i,executable) --no-objdump -no-radare2-main --dump-symbols"; + `P "$(b, bap) $(i,executable) --no-objdump --no-radare2 --dump-symbols"; `S "SEE ALSO"; `P "$(b,bap-plugin-objdump)(1)" ]; From 4b25bda6f874021f7af7dfaef96fc7bcb0afd8b3 Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Wed, 10 Jun 2020 13:07:36 +0800 Subject: [PATCH 04/10] use 'isj' to dump symbols --- plugins/radare2/radare2_main.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index 6710e7f07a..f63bdebdde 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -30,9 +30,9 @@ let provide_radare2 file = let accept name addr = Hashtbl.set funcs addr name in let extract name json = Yojson.Basic.Util.member name json in try - let symbol_list = Yojson.Basic.Util.to_list (R2.with_command_j "aaa;aflj" file) in + let symbol_list = Yojson.Basic.Util.to_list (R2.with_command_j "isj" file) in List.fold symbol_list ~init:() ~f:(fun () symbol -> - accept (Yojson.Basic.Util.to_string (extract "name" symbol)) (Yojson.Basic.Util.to_int (extract "offset" symbol) |> Z.of_int) + accept (Yojson.Basic.Util.to_string (extract "name" symbol)) (Yojson.Basic.Util.to_int (extract "vaddr" symbol) |> Z.of_int) ); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; @@ -53,9 +53,9 @@ let () = `P "This plugin provides a symbolizer based on radare2."; `S "EXAMPLES"; `P "To view the symbols after running the plugin:"; - `P "$(b, bap) $(i,executable) --no-objdump --dump-symbols "; + `P "$(b, bap) $(i,executable) --dump-symbols "; `P "To view symbols without this plugin:"; - `P "$(b, bap) $(i,executable) --no-objdump --no-radare2 --dump-symbols"; + `P "$(b, bap) $(i,executable) --no-radare2 --dump-symbols"; `S "SEE ALSO"; `P "$(b,bap-plugin-objdump)(1)" ]; From 970c85f7565fb2c2a8f7e3ce3da6dfaf1f70b3ab Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Sun, 14 Jun 2020 13:44:34 +0800 Subject: [PATCH 05/10] chop 'sym.imp' prefix --- plugins/radare2/radare2_main.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index f63bdebdde..01dd69d527 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -31,8 +31,13 @@ let provide_radare2 file = let extract name json = Yojson.Basic.Util.member name json in try let symbol_list = Yojson.Basic.Util.to_list (R2.with_command_j "isj" file) in + let strip str = let open String in + match chop_prefix str ~prefix:"sym.imp." with + | Some str -> str + | None -> str + in List.fold symbol_list ~init:() ~f:(fun () symbol -> - accept (Yojson.Basic.Util.to_string (extract "name" symbol)) (Yojson.Basic.Util.to_int (extract "vaddr" symbol) |> Z.of_int) + accept (Yojson.Basic.Util.to_string (extract "name" symbol) |> strip) (Yojson.Basic.Util.to_int (extract "vaddr" symbol) |> Z.of_int) ); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; From 8113bef8050028358536fc345d61dd6e1babb90c Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Wed, 17 Jun 2020 15:57:30 +0800 Subject: [PATCH 06/10] code style clean-up --- plugins/radare2/radare2_main.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index 01dd69d527..d06b7fdd2d 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -34,10 +34,11 @@ let provide_radare2 file = let strip str = let open String in match chop_prefix str ~prefix:"sym.imp." with | Some str -> str - | None -> str - in + | None -> str in + let open Yojson.Basic.Util in List.fold symbol_list ~init:() ~f:(fun () symbol -> - accept (Yojson.Basic.Util.to_string (extract "name" symbol) |> strip) (Yojson.Basic.Util.to_int (extract "vaddr" symbol) |> Z.of_int) + accept (to_string (extract "name" symbol) |> strip) + (to_int (extract "vaddr" symbol) |> Z.of_int) ); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; From a8f46b863b464ed854d2a44d0d710acec20fbf94 Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Sun, 21 Jun 2020 22:17:44 +0800 Subject: [PATCH 07/10] refactor for new radare2-ocaml interface --- plugins/radare2/radare2_main.ml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index d06b7fdd2d..50fa4fc444 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -21,6 +21,8 @@ let provide_roots funcs = promise_property Theory.Label.is_valid; promise_property Theory.Label.is_subroutine +exception Radare2_failed + let provide_radare2 file = let funcs = Hashtbl.create (module struct type t = Z.t @@ -28,17 +30,35 @@ let provide_radare2 file = let sexp_of_t x = Sexp.Atom (Z.to_string x) end) in let accept name addr = Hashtbl.set funcs addr name in - let extract name json = Yojson.Basic.Util.member name json in + let extract name json = let open Yojson in + match json with + | `Assoc list -> + (match List.find list ~f:(fun (key, _) -> String.equal key name) with + | Some (_, v) -> v + | _ -> raise Radare2_failed) + | _ -> raise Radare2_failed in try - let symbol_list = Yojson.Basic.Util.to_list (R2.with_command_j "isj" file) in + let symbol_list = let open Yojson in + match R2.with_command_j "isj" file with + | `List list -> list + | _ -> raise Radare2_failed in let strip str = let open String in match chop_prefix str ~prefix:"sym.imp." with | Some str -> str | None -> str in - let open Yojson.Basic.Util in + let open Yojson in + let to_string json = + match json with + | `String str -> str + | _ -> raise Radare2_failed in + let to_int json = + match json with + | `Int i -> Z.of_int i + | `Intlit s -> Z.of_string s + | _ -> raise Radare2_failed in List.fold symbol_list ~init:() ~f:(fun () symbol -> accept (to_string (extract "name" symbol) |> strip) - (to_int (extract "vaddr" symbol) |> Z.of_int) + (to_int (extract "vaddr" symbol)) ); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; From 9d3fc3186f6d84a0cbe3a7e4be6b0c960fdf887f Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Sun, 21 Jun 2020 22:35:56 +0800 Subject: [PATCH 08/10] lift symbol extracting to allow partial failure --- plugins/radare2/radare2_main.ml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index 50fa4fc444..e7695c1fd4 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -34,14 +34,14 @@ let provide_radare2 file = match json with | `Assoc list -> (match List.find list ~f:(fun (key, _) -> String.equal key name) with - | Some (_, v) -> v - | _ -> raise Radare2_failed) - | _ -> raise Radare2_failed in + | Some (_, v) -> Some v + | _ -> None) + | _ -> None in try let symbol_list = let open Yojson in match R2.with_command_j "isj" file with - | `List list -> list - | _ -> raise Radare2_failed in + | `List list -> Some list + | _ -> None in let strip str = let open String in match chop_prefix str ~prefix:"sym.imp." with | Some str -> str @@ -49,17 +49,19 @@ let provide_radare2 file = let open Yojson in let to_string json = match json with - | `String str -> str - | _ -> raise Radare2_failed in + | `String str -> Some str + | _ -> None in let to_int json = match json with - | `Int i -> Z.of_int i - | `Intlit s -> Z.of_string s - | _ -> raise Radare2_failed in - List.fold symbol_list ~init:() ~f:(fun () symbol -> - accept (to_string (extract "name" symbol) |> strip) - (to_int (extract "vaddr" symbol)) - ); + | `Int i -> Z.of_int i |> Some + | `Intlit s -> Z.of_string s |> Some + | _ -> None in + Option.(symbol_list >>| List.fold ~init:() ~f:(fun () symbol -> + both + (extract "name" symbol >>= to_string >>| strip) + (extract "vaddr" symbol >>= to_int) + |> value_map ~default:() ~f:(fun (name, addr) -> accept name addr) + ) |> value ~default:()); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; let symbolizer = Symbolizer.create @@ fun addr -> From d6da1b9062a0d59072cd0b81b939c1b1ebfd4ee0 Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Wed, 24 Jun 2020 23:45:15 +0800 Subject: [PATCH 09/10] clean-up refactor & indentation fix --- plugins/radare2/radare2_main.ml | 86 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index e7695c1fd4..c2538cedab 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -21,7 +21,31 @@ let provide_roots funcs = promise_property Theory.Label.is_valid; promise_property Theory.Label.is_subroutine -exception Radare2_failed +let extract_name (json : Yojson.t) = + match json with + | Yojson.(`Assoc list) -> + (match List.find list ~f:(fun (key, _) -> String.equal key "name") with + | Some (_, v) -> (match v with + | Yojson.(`String str) -> Some str + | _ -> None) + | _ -> None) + | _ -> None + +let extract_addr (json : Yojson.t) = + match json with + | Yojson.(`Assoc list) -> + (match List.find list ~f:(fun (key, _) -> String.equal key "vaddr") with + | Some (_, v) -> (match v with + | Yojson.(`Int i) -> Z.of_int i |> Some + | Yojson.(`Intlit s) -> Z.of_string s |> Some + | _ -> None) + | _ -> None) + | _ -> None + +let strip str = + match String.chop_prefix str ~prefix:"sym.imp." with + | Some str -> str + | None -> str let provide_radare2 file = let funcs = Hashtbl.create (module struct @@ -29,51 +53,25 @@ let provide_radare2 file = let compare = Z.compare and hash = Z.hash let sexp_of_t x = Sexp.Atom (Z.to_string x) end) in - let accept name addr = Hashtbl.set funcs addr name in - let extract name json = let open Yojson in - match json with - | `Assoc list -> - (match List.find list ~f:(fun (key, _) -> String.equal key name) with - | Some (_, v) -> Some v - | _ -> None) - | _ -> None in - try - let symbol_list = let open Yojson in - match R2.with_command_j "isj" file with - | `List list -> Some list - | _ -> None in - let strip str = let open String in - match chop_prefix str ~prefix:"sym.imp." with - | Some str -> str - | None -> str in - let open Yojson in - let to_string json = - match json with - | `String str -> Some str - | _ -> None in - let to_int json = - match json with - | `Int i -> Z.of_int i |> Some - | `Intlit s -> Z.of_string s |> Some - | _ -> None in - Option.(symbol_list >>| List.fold ~init:() ~f:(fun () symbol -> - both - (extract "name" symbol >>= to_string >>| strip) - (extract "vaddr" symbol >>= to_int) - |> value_map ~default:() ~f:(fun (name, addr) -> accept name addr) - ) |> value ~default:()); - if Hashtbl.length funcs = 0 - then warning "failed to obtain symbols"; - let symbolizer = Symbolizer.create @@ fun addr -> - Hashtbl.find funcs @@ - Bitvec.to_bigint (Word.to_bitvec addr) in - Symbolizer.provide agent symbolizer; - provide_roots funcs - with _ -> warning "failed to use radare2";() + let accept name addr = Hashtbl.set funcs addr name in + let symbol_list = match R2.with_command_j "isj" file with + | Yojson.(`List list) -> Some list + | s -> warning "unexpected radare2 output: %a" Yojson.pp s; None + | exception _ -> warning "failed to get symbols - radare2 command failed"; None in + Option.iter symbol_list ~f:(List.iter ~f:(fun s -> match extract_name s, extract_addr s with + | Some name, Some addr -> accept (strip name) addr + | _ -> debug "skipping json item %a" Yojson.pp s)); + if Hashtbl.length funcs = 0 + then warning "failed to obtain symbols"; + let symbolizer = Symbolizer.create @@ fun addr -> + Hashtbl.find funcs @@ + Bitvec.to_bigint (Word.to_bitvec addr) in + Symbolizer.provide agent symbolizer; + provide_roots funcs -let main = Stream.observe Project.Info.file @@ provide_radare2 +let main () = Stream.observe Project.Info.file @@ provide_radare2 let () = Config.manpage [ @@ -87,4 +85,4 @@ let () = `S "SEE ALSO"; `P "$(b,bap-plugin-objdump)(1)" ]; - Config.when_ready (fun {get=_} -> main) \ No newline at end of file + Config.when_ready (fun {get=_} -> main ()) \ No newline at end of file From 495c7a645f4f6429da1c3c5501bcb578661384b5 Mon Sep 17 00:00:00 2001 From: Phosphorus15 Date: Thu, 25 Jun 2020 13:38:42 +0800 Subject: [PATCH 10/10] polymorphic variant & pipe operator fix --- plugins/radare2/radare2_main.ml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/radare2/radare2_main.ml b/plugins/radare2/radare2_main.ml index c2538cedab..6c50eb8e14 100644 --- a/plugins/radare2/radare2_main.ml +++ b/plugins/radare2/radare2_main.ml @@ -23,21 +23,21 @@ let provide_roots funcs = let extract_name (json : Yojson.t) = match json with - | Yojson.(`Assoc list) -> + | `Assoc list -> (match List.find list ~f:(fun (key, _) -> String.equal key "name") with | Some (_, v) -> (match v with - | Yojson.(`String str) -> Some str + | `String str -> Some str | _ -> None) | _ -> None) | _ -> None let extract_addr (json : Yojson.t) = match json with - | Yojson.(`Assoc list) -> + | `Assoc list -> (match List.find list ~f:(fun (key, _) -> String.equal key "vaddr") with | Some (_, v) -> (match v with - | Yojson.(`Int i) -> Z.of_int i |> Some - | Yojson.(`Intlit s) -> Z.of_string s |> Some + | `Int i -> Some (Z.of_int i) + | `Intlit s -> Some (Z.of_string s) | _ -> None) | _ -> None) | _ -> None @@ -55,12 +55,13 @@ let provide_radare2 file = end) in let accept name addr = Hashtbl.set funcs addr name in let symbol_list = match R2.with_command_j "isj" file with - | Yojson.(`List list) -> Some list + | `List list -> Some list | s -> warning "unexpected radare2 output: %a" Yojson.pp s; None | exception _ -> warning "failed to get symbols - radare2 command failed"; None in - Option.iter symbol_list ~f:(List.iter ~f:(fun s -> match extract_name s, extract_addr s with - | Some name, Some addr -> accept (strip name) addr - | _ -> debug "skipping json item %a" Yojson.pp s)); + Option.iter symbol_list + ~f:(List.iter ~f:(fun s -> match extract_name s, extract_addr s with + | Some name, Some addr -> accept (strip name) addr + | _ -> debug "skipping json item %a" Yojson.pp s)); if Hashtbl.length funcs = 0 then warning "failed to obtain symbols"; let symbolizer = Symbolizer.create @@ fun addr ->