Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file elf_interpreted_segment.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141(*Generated by Lem from elf_interpreted_segment.lem.*)(** [elf_interpreted_segment] defines interpreted segments, i.e. the contents of
* a program header table entry converted to more amenable types, and operations
* built on top of them.
*)openLem_basic_classesopenLem_boolopenLem_numopenLem_stringopenElf_types_native_uintopenElf_program_header_tableopenByte_sequenceopenMissing_pervasivesopenShowopenHex_printing(** [elf32_interpreted_segment] represents an ELF32 interpreted segment, i.e. the
* contents of an ELF program header table entry converted into more amenable
* (infinite precision) types, for manipulation.
* Invariant: the nth entry of the program header table corresponds to the nth
* entry of the list of interpreted segments in an [elf32_file] record. The
* lengths of the two lists are exactly the same.
*)typeelf32_interpreted_segment={elf32_segment_body:byte_sequence0(** Body of the segment *);elf32_segment_type:Nat_big_num.num(** Type of the segment *);elf32_segment_size:Nat_big_num.num(** Size of the segment in bytes *);elf32_segment_memsz:Nat_big_num.num(** Size of the segment in memory in bytes *);elf32_segment_base:Nat_big_num.num(** Base address of the segment *);elf32_segment_paddr:Nat_big_num.num(** Physical address of segment *);elf32_segment_align:Nat_big_num.num(** Alignment of the segment *);elf32_segment_offset:Nat_big_num.num(** Offset of the segment *);elf32_segment_flags:(bool*bool*bool)(** READ, WRITE, EXECUTE flags. *)}(** [elf64_interpreted_segment] represents an ELF64 interpreted segment, i.e. the
* contents of an ELF program header table entry converted into more amenable
* (infinite precision) types, for manipulation.
* Invariant: the nth entry of the program header table corresponds to the nth
* entry of the list of interpreted segments in an [elf64_file] record. The
* lengths of the two lists are exactly the same.
*)typeelf64_interpreted_segment={elf64_segment_body:byte_sequence0(** Body of the segment *);elf64_segment_type:Nat_big_num.num(** Type of the segment *);elf64_segment_size:Nat_big_num.num(** Size of the segment in bytes *);elf64_segment_memsz:Nat_big_num.num(** Size of the segment in memory in bytes *);elf64_segment_base:Nat_big_num.num(** Base address of the segment *);elf64_segment_paddr:Nat_big_num.num(** Physical address of segment *);elf64_segment_align:Nat_big_num.num(** Alignment of the segment *);elf64_segment_offset:Nat_big_num.num(** Offset of the segment *);elf64_segment_flags:(bool*bool*bool)(** READ, WRITE, EXECUTE flags. *)}(** [compare_elf64_interpreted_segment seg1 seg2] is an ordering comparison function
* on interpreted segments suitable for constructing sets, finite maps and other
* ordered data types out of.
*)(*val compare_elf64_interpreted_segment : elf64_interpreted_segment ->
elf64_interpreted_segment -> ordering*)letcompare_elf64_interpreted_segments1s2:int=(tripleCompareByte_sequence_wrapper.compare(Lem_list.lexicographic_compareNat_big_num.compare)(Lem_list.lexicographic_compareNat_big_num.compare)(s1.elf64_segment_body,[s1.elf64_segment_type;s1.elf64_segment_size;s1.elf64_segment_memsz;s1.elf64_segment_base;s1.elf64_segment_paddr;s1.elf64_segment_align;s1.elf64_segment_offset],(let(f1,f2,f3)=(s1.elf64_segment_flags)inLem_list.mapnatural_of_bool[f1;f2;f3]))(s2.elf64_segment_body,[s2.elf64_segment_type;s2.elf64_segment_size;s2.elf64_segment_memsz;s2.elf64_segment_base;s2.elf64_segment_paddr;s2.elf64_segment_align;s2.elf64_segment_offset],(let(f1,f2,f3)=(s2.elf64_segment_flags)inLem_list.mapnatural_of_bool[f1;f2;f3])))letinstance_Basic_classes_Ord_Elf_interpreted_segment_elf64_interpreted_segment_dict:(elf64_interpreted_segment)ord_class=({compare_method=compare_elf64_interpreted_segment;isLess_method=(funf1->(funf2->(Lem.orderingEqual(compare_elf64_interpreted_segmentf1f2)(-1))));isLessEqual_method=(funf1->(funf2->letresult=(compare_elf64_interpreted_segmentf1f2)inLem.orderingEqualresult(-1)||Lem.orderingEqualresult0));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(compare_elf64_interpreted_segmentf1f2)1)));isGreaterEqual_method=(funf1->(funf2->letresult=(compare_elf64_interpreted_segmentf1f2)inLem.orderingEqualresult1||Lem.orderingEqualresult0))})typeelf32_interpreted_segments=elf32_interpreted_segmentlisttypeelf64_interpreted_segments=elf64_interpreted_segmentlist(** [string_of_flags bs] produces a string-based representation of an interpreted
* segments flags (represented as a boolean triple).
*)(*val string_of_flags : (bool * bool * bool) -> string*)letstring_of_flagsflags:string=((matchflagswith|(read,write,execute)->bracket[string_of_boolread;string_of_boolwrite;string_of_boolexecute]))(** [string_of_elf32_interpreted_segment seg] produces a string-based representation
* of interpreted segment [seg].
*)(*val string_of_elf32_interpreted_segment : elf32_interpreted_segment -> string*)letstring_of_elf32_interpreted_segmentseg:string=(unlines[("Body of length: "^unsafe_hex_string_of_natural16(Byte_sequence.length0seg.elf32_segment_body));("Segment type: "^string_of_segment_type(fun_->"ABI specific")(fun_->"ABI specific")seg.elf32_segment_type);("Segment size: "^unsafe_hex_string_of_natural16seg.elf32_segment_size);("Segment memory size: "^unsafe_hex_string_of_natural16seg.elf32_segment_memsz);("Segment base address: "^unsafe_hex_string_of_natural16seg.elf32_segment_base);("Segment physical address: "^unsafe_hex_string_of_natural16seg.elf32_segment_paddr);("Segment flags: "^string_of_flagsseg.elf32_segment_flags)])(** [string_of_elf64_interpreted_segment seg] produces a string-based representation
* of interpreted segment [seg].
*)(*val string_of_elf64_interpreted_segment : elf64_interpreted_segment -> string*)letstring_of_elf64_interpreted_segmentseg:string=(unlines[("Body of length: "^unsafe_hex_string_of_natural16(Byte_sequence.length0seg.elf64_segment_body));("Segment type: "^string_of_segment_type(fun_->"ABI specific")(fun_->"ABI specific")seg.elf64_segment_type);("Segment size: "^unsafe_hex_string_of_natural16seg.elf64_segment_size);("Segment memory size: "^unsafe_hex_string_of_natural16seg.elf64_segment_memsz);("Segment base address: "^unsafe_hex_string_of_natural16seg.elf64_segment_base);("Segment physical address: "^unsafe_hex_string_of_natural16seg.elf64_segment_paddr);("Segment flags: "^string_of_flagsseg.elf64_segment_flags)])