Unverified Commit 9f0bc45b by Melvin Klimke Committed by GitHub

Fixed a bug in the objdump output parsing in symbol_utils.ml (#83)

parent 52804195
...@@ -36,26 +36,12 @@ let call_finder_run = ref false ...@@ -36,26 +36,12 @@ let call_finder_run = ref false
(** Parse a line from the dyn-syms output table of objdump. Return the name of a symbol if the symbol is an extern function name. *) (** Parse a line from the dyn-syms output table of objdump. Return the name of a symbol if the symbol is an extern function name. *)
let parse_dyn_sym_line (line : string) : string option = let parse_dyn_sym_line (line : string) : string option =
let line = ref (String.strip line) in let columns = String.split_on_chars ~on:[ ' ' ; '\t' ; '\n' ; '\r' ] line
let str_list = ref [] in |> List.filter ~f:(fun x -> x <> "") in
while Option.is_some (String.rsplit2 !line ~on:' ') do (* Check whether the symbol is a function --> DF and if it is referenced in the file, but defined outside it --> *UND* *)
let (left, right) = Option.value_exn (String.rsplit2 !line ~on:' ') in match ((Stdlib.List.mem "DF" columns) && (Stdlib.List.mem "*UND*" columns)) with
line := String.strip left; | true -> List.last columns
str_list := right :: !str_list; | false -> None
done;
str_list := !line :: !str_list;
match !str_list with
| value :: func1 :: func2 :: _ -> begin
match ( String.strip ~drop:(fun x -> x = '0') value ) with
| "" -> begin
if (String.equal func1 "DF" || String.equal func2 "DF") then (
List.last !str_list
)
else None
end
| _ -> None (* The symbol has a nonzero value, so we assume that it is not an extern function symbol. *)
end
| _ -> None
let parse_dyn_syms (project : Project.t) : String.Set.t = let parse_dyn_syms (project : Project.t) : String.Set.t =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment