Adapt ocamlobjinfo
parent
34ff264937
commit
a8f05ad7af
|
@ -244,26 +244,11 @@ let dump_byte ic =
|
||||||
toc
|
toc
|
||||||
|
|
||||||
let find_dyn_offset filename =
|
let find_dyn_offset filename =
|
||||||
let helper_name = "objinfo_helper" ^ Config.ext_exe in
|
match Binutils.read filename with
|
||||||
let helper = Filename.concat Config.standard_library helper_name in
|
| Ok t ->
|
||||||
let tempfile = Filename.temp_file "objinfo" ".out" in
|
Binutils.symbol_offset t "caml_plugin_header"
|
||||||
match
|
| Error _ ->
|
||||||
Fun.protect
|
None
|
||||||
~finally:(fun () -> remove_file tempfile)
|
|
||||||
(fun () ->
|
|
||||||
let rc =
|
|
||||||
Sys.command
|
|
||||||
(Filename.quote_command helper ~stdout:tempfile [filename])
|
|
||||||
in
|
|
||||||
if rc <> 0 then failwith "cannot read";
|
|
||||||
let tc = Scanf.Scanning.from_file tempfile in
|
|
||||||
Fun.protect
|
|
||||||
~finally:(fun () -> Scanf.Scanning.close_in tc)
|
|
||||||
(fun () ->
|
|
||||||
Scanf.bscanf tc "%Ld" (fun x -> x)))
|
|
||||||
with
|
|
||||||
| offset -> Some offset
|
|
||||||
| exception (Failure _ | Sys_error _) -> None
|
|
||||||
|
|
||||||
let exit_err msg = print_endline msg; exit 2
|
let exit_err msg = print_endline msg; exit 2
|
||||||
let exit_errf fmt = Printf.ksprintf exit_err fmt
|
let exit_errf fmt = Printf.ksprintf exit_err fmt
|
||||||
|
|
Loading…
Reference in New Issue