package linksem
A formalisation of the core ELF and DWARF file formats written in Lem
Install
Dune Dependency
Authors
Maintainers
Sources
0.8.tar.gz
md5=2075c56715539b3b8f54ae65cc808b8c
sha512=f7c16e4036a1440a6a8d13707a43f0f9f9db0c68489215f948cc300b6a164dba5bf852e58f89503e9d9f38180ee658d9478156ca1a1ef64d6861eec5f9cf43d2
doc/src/linksem_zarith/elf_interpreted_segment.ml.html
Source file elf_interpreted_segment.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
(*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. *) open Lem_basic_classes open Lem_bool open Lem_num open Lem_string open Elf_types_native_uint open Elf_program_header_table open Byte_sequence open Missing_pervasives open Show open Hex_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. *) type elf32_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. *) type elf64_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*) let compare_elf64_interpreted_segment s1 s2:int= (tripleCompare Byte_sequence_wrapper.compare (Lem_list.lexicographic_compare Nat_big_num.compare) (Lem_list.lexicographic_compare Nat_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) in Lem_list.map natural_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) in Lem_list.map natural_of_bool [f1; f2; f3]))) let instance_Basic_classes_Ord_Elf_interpreted_segment_elf64_interpreted_segment_dict:(elf64_interpreted_segment)ord_class= ({ compare_method = compare_elf64_interpreted_segment; isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(compare_elf64_interpreted_segment f1 f2) (-1)))); isLessEqual_method = (fun f1 -> (fun f2 -> let result = (compare_elf64_interpreted_segment f1 f2) in Lem.orderingEqual result (-1) || Lem.orderingEqual result 0)); isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(compare_elf64_interpreted_segment f1 f2) 1))); isGreaterEqual_method = (fun f1 -> (fun f2 -> let result = (compare_elf64_interpreted_segment f1 f2) in Lem.orderingEqual result 1 || Lem.orderingEqual result 0))}) type elf32_interpreted_segments = elf32_interpreted_segment list type elf64_interpreted_segments = elf64_interpreted_segment list (** [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*) let string_of_flags flags:string= ((match flags with | (read, write, execute) -> bracket [string_of_bool read; string_of_bool write; string_of_bool execute] )) (** [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*) let string_of_elf32_interpreted_segment seg:string= (unlines [ ("Body of length: " ^ unsafe_hex_string_of_natural 16 (Byte_sequence.length0 seg.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_natural 16 seg.elf32_segment_size) ; ("Segment memory size: " ^ unsafe_hex_string_of_natural 16 seg.elf32_segment_memsz) ; ("Segment base address: " ^ unsafe_hex_string_of_natural 16 seg.elf32_segment_base) ; ("Segment physical address: " ^ unsafe_hex_string_of_natural 16 seg.elf32_segment_paddr) ; ("Segment flags: " ^ string_of_flags seg.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*) let string_of_elf64_interpreted_segment seg:string= (unlines [ ("Body of length: " ^ unsafe_hex_string_of_natural 16 (Byte_sequence.length0 seg.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_natural 16 seg.elf64_segment_size) ; ("Segment memory size: " ^ unsafe_hex_string_of_natural 16 seg.elf64_segment_memsz) ; ("Segment base address: " ^ unsafe_hex_string_of_natural 16 seg.elf64_segment_base) ; ("Segment physical address: " ^ unsafe_hex_string_of_natural 16 seg.elf64_segment_paddr) ; ("Segment flags: " ^ string_of_flags seg.elf64_segment_flags) ])
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>