/usr/share/doc/libbitstring-ocaml-dev/examples/elf.ml is in libbitstring-ocaml-dev 2.0.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | (* Read an ELF (Linux binary) header.
* $Id: elf.ml 142 2008-07-17 15:45:56Z richard.wm.jones $
*)
open Printf
let () =
let filename = "/bin/ls" in
let bits = Bitstring.bitstring_of_file filename in
bitmatch bits with
| { 0x7f : 8; "ELF" : 24 : string; (* ELF magic number *)
_ : 12*8 : bitstring; (* ELF identifier *)
e_type : 16 : littleendian; (* object file type *)
e_machine : 16 : littleendian (* architecture *)
} ->
printf "%s: ELF binary, type %d, arch %d\n" filename e_type e_machine
| { _ } ->
eprintf "%s: Not an ELF binary\n" filename
|