(* Step 3: the project's own C stubs, in the same link as the compiler. lib/dynload_stubs.c is taken verbatim from 9e0ae3a (the unmerged dlopen branch) -- it is the only C the compiler itself is built from, and it is the case that -output-complete-obj has to carry through. *) external dl_open : string -> nativeint = "flan_dl_open" external dl_sym : nativeint -> string -> nativeint = "flan_dl_sym" external mem_alloc : int -> nativeint = "flan_mem_alloc" external mem_free : nativeint -> unit = "flan_mem_free" external poke_i64 : nativeint -> int -> int64 -> unit = "flan_poke_i64" external peek_i64 : nativeint -> int -> int64 = "flan_peek_i64" let () = Callback.register "spike_stubs" (fun () -> (* peek/poke: the raw memory the marshaller lays a Form image out in. *) let p = mem_alloc 64 in poke_i64 p 8 0xfeedfacedeadbeefL; let got = peek_i64 p 8 in mem_free p; (* dlopen from inside the embedded runtime, on the process's own image. *) let h = dl_open "libm.so.6" in let s = dl_sym h "sqrt" in Printf.sprintf "peek/poke %s; dlopen+dlsym %s" (if got = 0xfeedfacedeadbeefL then "ok" else "WRONG") (if s <> 0n then "ok" else "WRONG")); ignore dl_open