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_symbol_table.ml.html
Source file elf_symbol_table.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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
(*Generated by Lem from elf_symbol_table.lem.*) (** [elf_symbol_table] provides types, functions and other definitions for * working with ELF symbol tables. *) open Lem_basic_classes open Lem_bool open Lem_list open Lem_maybe open Lem_num open Lem_string open Lem_tuple (*import Set*) open Byte_sequence open Error open Missing_pervasives open Show open Elf_header open Elf_types_native_uint open Endianness open String_table (** Undefined symbol index *) let stn_undef : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Symbol binding *) (** Local symbols are not visible outside of the object file containing their * definition. *) let stb_local : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Global symbols are visible to all object files being combined. *) let stb_global : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** Weak symbols resemble global symbols but their definitions have lower * precedence. *) let stb_weak : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** Values in the following range have reserved OS specific semantics. *) let stb_loos : Nat_big_num.num= ( (Nat_big_num.of_int 10)) let stb_hios : Nat_big_num.num= ( (Nat_big_num.of_int 12)) (** Values in the following range have reserved processor specific semantics. *) let stb_loproc : Nat_big_num.num= ( (Nat_big_num.of_int 13)) let stb_hiproc : Nat_big_num.num= ( (Nat_big_num.of_int 15)) (** string_of_symbol_binding b os proc] produces a string representation of * binding [m] using printing functions [os] and [proc] for OS- and processor- * specific values respectively. * OCaml specific definition. *) (*val string_of_symbol_binding : natural -> (natural -> string) -> (natural -> string) -> string*) let string_of_symbol_binding m os proc:string= (if Nat_big_num.equal m stb_local then "LOCAL" else if Nat_big_num.equal m stb_global then "GLOBAL" else if Nat_big_num.equal m stb_weak then "WEAK" else if Nat_big_num.greater_equal m stb_loos && Nat_big_num.less_equal m stb_hios then os m else if Nat_big_num.greater_equal m stb_loproc && Nat_big_num.less_equal m stb_hiproc then proc m else "Invalid symbol binding") (** Symbol types *) (** The symbol's type is not specified. *) let stt_notype : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** The symbol is associated with a data object such as a variable. *) let stt_object : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** The symbol is associated with a function or other executable code. *) let stt_func : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** The symbol is associated with a section. *) let stt_section : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** Conventionally the symbol's value gives the name of the source file associated * with the object file. *) let stt_file : Nat_big_num.num= ( (Nat_big_num.of_int 4)) (** The symbol is an uninitialised common block. *) let stt_common : Nat_big_num.num= ( (Nat_big_num.of_int 5)) (** The symbol specified a Thread Local Storage (TLS) entity. *) let stt_tls : Nat_big_num.num= ( (Nat_big_num.of_int 6)) (** Values in the following range are reserved solely for OS-specific semantics. *) let stt_loos : Nat_big_num.num= ( (Nat_big_num.of_int 10)) let stt_hios : Nat_big_num.num= ( (Nat_big_num.of_int 12)) (** Values in the following range are reserved solely for processor-specific * semantics. *) let stt_loproc : Nat_big_num.num= ( (Nat_big_num.of_int 13)) let stt_hiproc : Nat_big_num.num= ( (Nat_big_num.of_int 15)) (** [string_of_symbol_type sym os proc] produces a string representation of * symbol type [m] using [os] and [proc] to pretty-print values reserved for * OS- and processor-specific functionality. *) (*val string_of_symbol_type : natural -> (natural -> string) -> (natural -> string) -> string*) let string_of_symbol_type m os proc:string= (if Nat_big_num.equal m stt_notype then "NOTYPE" else if Nat_big_num.equal m stt_object then "OBJECT" else if Nat_big_num.equal m stt_func then "FUNC" else if Nat_big_num.equal m stt_section then "SECTION" else if Nat_big_num.equal m stt_file then "FILE" else if Nat_big_num.equal m stt_common then "COMMON" else if Nat_big_num.equal m stt_tls then "TLS" else if Nat_big_num.greater_equal m stt_loos && Nat_big_num.less_equal m stt_hios then os m else if Nat_big_num.greater_equal m stt_loproc && Nat_big_num.less_equal m stt_hiproc then proc m else "Invalid symbol type") (** Symbol visibility *) (** The visibility of the symbol is as specified by the symbol's binding type. *) let stv_default : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** The meaning of this visibility may be defined by processor supplements to * further constrain hidden symbols. *) let stv_internal : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** The symbol's name is not visible in other components. *) let : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** The symbol is visible in other components but not pre-emptable. That is, * references to the symbol in the same component resolve to this symbol even * if other symbols of the same name in other components would normally be * resolved to instead if we followed the normal rules of symbol resolution. *) let stv_protected : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** [string_of_symbol_visibility m] produces a string representation of symbol * visibility [m]. *) (*val string_of_symbol_visibility : natural -> string*) let string_of_symbol_visibility m:string= (if Nat_big_num.equal m stv_default then "DEFAULT" else if Nat_big_num.equal m stv_internal then "INTERNAL" else if Nat_big_num.equal m stv_hidden then "HIDDEN" else if Nat_big_num.equal m stv_protected then "PROTECTED" else "Invalid symbol visibility") (** Symbol table entry type *) (** [elf32_symbol_table_entry] is an entry in a symbol table. *) type elf32_symbol_table_entry = { elf32_st_name : Uint32_wrapper.uint32 (** Index into the object file's string table *) ; elf32_st_value : Uint32_wrapper.uint32 (** Gives the value of the associated symbol *) ; elf32_st_size : Uint32_wrapper.uint32 (** Size of the associated symbol *) ; elf32_st_info : Uint32_wrapper.uint32 (** Specifies the symbol's type and binding attributes *) ; elf32_st_other : Uint32_wrapper.uint32 (** Currently specifies the symbol's visibility *) ; elf32_st_shndx : Uint32_wrapper.uint32 (** Section header index symbol is defined with respect to *) } (** [elf32_symbol_table_entry_compare ent1 ent2] is an ordering-comparison function * for symbol table entries suitable for constructing sets, finite maps and other * ordered data structures from. *) (*val elf32_symbol_table_entry_compare : elf32_symbol_table_entry -> elf32_symbol_table_entry -> ordering*) let elf32_symbol_table_entry_compare ent1 ent2:int= (sextupleCompare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare (Uint32_wrapper.to_bigint ent1.elf32_st_name, Uint32_wrapper.to_bigint ent1.elf32_st_value, Uint32_wrapper.to_bigint ent1.elf32_st_size, Uint32_wrapper.to_bigint ent1.elf32_st_info, Uint32_wrapper.to_bigint ent1.elf32_st_other, Uint32_wrapper.to_bigint ent1.elf32_st_shndx) (Uint32_wrapper.to_bigint ent2.elf32_st_name, Uint32_wrapper.to_bigint ent2.elf32_st_value, Uint32_wrapper.to_bigint ent2.elf32_st_size, Uint32_wrapper.to_bigint ent2.elf32_st_info, Uint32_wrapper.to_bigint ent2.elf32_st_other, Uint32_wrapper.to_bigint ent2.elf32_st_shndx)) let instance_Basic_classes_Ord_Elf_symbol_table_elf32_symbol_table_entry_dict:(elf32_symbol_table_entry)ord_class= ({ compare_method = elf32_symbol_table_entry_compare; isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf32_symbol_table_entry_compare f1 f2) (-1)))); isLessEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf32_symbol_table_entry_compare f1 f2)(Pset.from_list compare [(-1); 0]))); isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf32_symbol_table_entry_compare f1 f2) 1))); isGreaterEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf32_symbol_table_entry_compare f1 f2)(Pset.from_list compare [1; 0])))}) (** [elf64_symbol_table_entry] is an entry in a symbol table. *) type elf64_symbol_table_entry = { elf64_st_name : Uint32_wrapper.uint32 (** Index into the object file's string table *) ; elf64_st_info : Uint32_wrapper.uint32 (** Specifies the symbol's type and binding attributes *) ; elf64_st_other : Uint32_wrapper.uint32 (** Currently specifies the symbol's visibility *) ; elf64_st_shndx : Uint32_wrapper.uint32 (** Section header index symbol is defined with respect to *) ; elf64_st_value : Uint64_wrapper.uint64 (** Gives the value of the associated symbol *) ; elf64_st_size : Uint64_wrapper.uint64 (** Size of the associated symbol *) } (** [elf64_symbol_table_entry_compare ent1 ent2] is an ordering-comparison function * for symbol table entries suitable for constructing sets, finite maps and other * ordered data structures from. *) (*val elf64_symbol_table_entry_compare : elf64_symbol_table_entry -> elf64_symbol_table_entry -> ordering*) let elf64_symbol_table_entry_compare ent1 ent2:int= (sextupleCompare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare Nat_big_num.compare (Uint32_wrapper.to_bigint ent1.elf64_st_name, Ml_bindings.nat_big_num_of_uint64 ent1.elf64_st_value, Ml_bindings.nat_big_num_of_uint64 ent1.elf64_st_size, Uint32_wrapper.to_bigint ent1.elf64_st_info, Uint32_wrapper.to_bigint ent1.elf64_st_other, Uint32_wrapper.to_bigint ent1.elf64_st_shndx) (Uint32_wrapper.to_bigint ent2.elf64_st_name, Ml_bindings.nat_big_num_of_uint64 ent2.elf64_st_value, Ml_bindings.nat_big_num_of_uint64 ent2.elf64_st_size, Uint32_wrapper.to_bigint ent2.elf64_st_info, Uint32_wrapper.to_bigint ent2.elf64_st_other, Uint32_wrapper.to_bigint ent2.elf64_st_shndx)) let instance_Basic_classes_Ord_Elf_symbol_table_elf64_symbol_table_entry_dict:(elf64_symbol_table_entry)ord_class= ({ compare_method = elf64_symbol_table_entry_compare; isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf64_symbol_table_entry_compare f1 f2) (-1)))); isLessEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf64_symbol_table_entry_compare f1 f2)(Pset.from_list compare [(-1); 0]))); isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf64_symbol_table_entry_compare f1 f2) 1))); isGreaterEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf64_symbol_table_entry_compare f1 f2)(Pset.from_list compare [1; 0])))}) type elf32_symbol_table = elf32_symbol_table_entry list type elf64_symbol_table = elf64_symbol_table_entry list (** Extraction of symbol table data *) (* Functions below common to 32- and 64-bit! *) (** [extract_symbol_binding u] extracts a symbol table entry's symbol binding. [u] * in this case is the [elfXX_st_info] field from a symbol table entry. *) (*val extract_symbol_binding : unsigned_char -> natural*) let extract_symbol_binding entry:Nat_big_num.num= (Uint32_wrapper.to_bigint (Uint32_wrapper.shift_right entry 4)) (** [extract_symbol_type u] extracts a symbol table entry's symbol type. [u] * in this case is the [elfXX_st_info] field from a symbol table entry. *) (*val extract_symbol_type : unsigned_char -> natural*) let extract_symbol_type entry:Nat_big_num.num= (Uint32_wrapper.to_bigint (Uint32_wrapper.logand entry (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 15))))) (* 0xf *) (** [get_symbol_info u] extracts a symbol table entry's symbol info. [u] * in this case is the [elfXX_st_info] field from a symbol table entry. *) (*val make_symbol_info : natural -> natural -> unsigned_char*) let make_symbol_info binding1 symtype:Uint32_wrapper.uint32= (Uint32_wrapper.add (Uint32_wrapper.shift_left (Uint32_wrapper.of_bigint binding1) 4) (Uint32_wrapper.logand (Uint32_wrapper.of_bigint symtype) (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 15))))) (*0xf*) (** [get_symbol_visibility u] extracts a symbol table entry's symbol visibility. [u] * in this case is the [elfXX_st_other] field from a symbol table entry. *) (*val get_symbol_visibility : unsigned_char -> natural*) let get_symbol_visibility info:Nat_big_num.num= (Uint32_wrapper.to_bigint (Uint32_wrapper.logand info (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 3))))) (* 0x3*) (** [make_symbol_other m] converts a natural [m] to an unsigned char suitable * for use in a symbol table entry's "other" field. * XXX: WHY? *) (*val make_symbol_other : natural -> unsigned_char*) let make_symbol_other visibility:Uint32_wrapper.uint32= (Uint32_wrapper.of_bigint visibility) (** [is_elf32_shndx_too_large ent] tests whether the symbol table entry's * [shndx] field is equal to SHN_XINDEX, in which case the real value is stored * elsewhere. *) (*val is_elf32_shndx_too_large : elf32_symbol_table_entry -> bool*) let is_elf32_shndx_too_large syment:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint syment.elf32_st_shndx) shn_xindex) (** [is_elf64_shndx_too_large ent] tests whether the symbol table entry's * [shndx] field is equal to SHN_XINDEX, in which case the real value is stored * elsewhere. *) (*val is_elf64_shndx_too_large : elf64_symbol_table_entry -> bool*) let is_elf64_shndx_too_large syment:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint syment.elf64_st_shndx) shn_xindex) (** NULL tests *) (** [is_elf32_null_entry ent] tests whether [ent] is a null symbol table entry, * i.e. all fields set to [0]. *) (*val is_elf32_null_entry : elf32_symbol_table_entry -> bool*) let is_elf32_null_entry ent:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint ent.elf32_st_name)( (Nat_big_num.of_int 0)) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf32_st_value)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf32_st_size)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf32_st_info)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf32_st_other)( (Nat_big_num.of_int 0))) && ( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf32_st_shndx)( (Nat_big_num.of_int 0)))))))) (** [is_elf64_null_entry ent] tests whether [ent] is a null symbol table entry, * i.e. all fields set to [0]. *) (*val is_elf64_null_entry : elf64_symbol_table_entry -> bool*) let is_elf64_null_entry ent:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint ent.elf64_st_name)( (Nat_big_num.of_int 0)) && (( Nat_big_num.equal(Ml_bindings.nat_big_num_of_uint64 ent.elf64_st_value)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Ml_bindings.nat_big_num_of_uint64 ent.elf64_st_size)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf64_st_info)( (Nat_big_num.of_int 0))) && (( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf64_st_other)( (Nat_big_num.of_int 0))) && ( Nat_big_num.equal(Uint32_wrapper.to_bigint ent.elf64_st_shndx)( (Nat_big_num.of_int 0)))))))) (** Printing symbol table entries *) type symtab_print_bundle = (Nat_big_num.num -> string) * (Nat_big_num.num -> string) (** [string_of_elf32_symbol_table_entry ent] produces a string based representation * of symbol table entry [ent]. *) (*val string_of_elf32_symbol_table_entry : elf32_symbol_table_entry -> string*) let string_of_elf32_symbol_table_entry entry:string= (unlines [ ("\t" ^ ("Name: " ^ Uint32_wrapper.to_string entry.elf32_st_name)) ; ("\t" ^ ("Value: " ^ Uint32_wrapper.to_string entry.elf32_st_value)) ; ("\t" ^ ("Size: " ^ Uint32_wrapper.to_string entry.elf32_st_size)) ; ("\t" ^ ("Info: " ^ Uint32_wrapper.to_string entry.elf32_st_info)) ; ("\t" ^ ("Other: " ^ Uint32_wrapper.to_string entry.elf32_st_other)) ; ("\t" ^ ("Shndx: " ^ Uint32_wrapper.to_string entry.elf32_st_shndx)) ]) (** [string_of_elf64_symbol_table_entry ent] produces a string based representation * of symbol table entry [ent]. *) (*val string_of_elf64_symbol_table_entry : elf64_symbol_table_entry -> string*) let string_of_elf64_symbol_table_entry entry:string= (unlines [ ("\t" ^ ("Name: " ^ Uint32_wrapper.to_string entry.elf64_st_name)) ; ("\t" ^ ("Info: " ^ Uint32_wrapper.to_string entry.elf64_st_info)) ; ("\t" ^ ("Other: " ^ Uint32_wrapper.to_string entry.elf64_st_other)) ; ("\t" ^ ("Shndx: " ^ Uint32_wrapper.to_string entry.elf64_st_shndx)) ; ("\t" ^ ("Value: " ^ Uint64_wrapper.to_string entry.elf64_st_value)) ; ("\t" ^ ("Size: " ^ Uint64_wrapper.to_string entry.elf64_st_size)) ]) (** [string_of_elf32_symbol_table stbl] produces a string based representation * of symbol table [stbl]. *) (*val string_of_elf32_symbol_table : elf32_symbol_table -> string*) let string_of_elf32_symbol_table symtab:string= (unlines (Lem_list.map string_of_elf32_symbol_table_entry symtab)) (** [elf64_null_symbol_table_entry] is the null symbol table entry, with all * fields set to zero. *) (*val elf64_null_symbol_table_entry : elf64_symbol_table_entry*) let elf64_null_symbol_table_entry:elf64_symbol_table_entry= ({ elf64_st_name = (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))) ; elf64_st_info = (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))) ; elf64_st_other = (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))) ; elf64_st_shndx = (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))) ; elf64_st_value = (Uint64_wrapper.of_bigint( (Nat_big_num.of_int 0))) ; elf64_st_size = (Uint64_wrapper.of_bigint( (Nat_big_num.of_int 0))) }) (*val string_of_elf64_symbol_table : elf64_symbol_table -> string*) let string_of_elf64_symbol_table symtab:string= (unlines (Lem_list.map string_of_elf64_symbol_table_entry symtab)) let instance_Show_Show_Elf_symbol_table_elf32_symbol_table_entry_dict:(elf32_symbol_table_entry)show_class= ({ show_method = string_of_elf32_symbol_table_entry}) let instance_Show_Show_Elf_symbol_table_elf64_symbol_table_entry_dict:(elf64_symbol_table_entry)show_class= ({ show_method = string_of_elf64_symbol_table_entry}) (** Reading in symbol table (entries) *) (** [read_elf32_symbol_table_entry endian bs0] reads an ELF symbol table entry * record from byte sequence [bs0] assuming endianness [endian], returning the * remainder of the byte sequence. Fails if the byte sequence is not long enough. *) (*val read_elf32_symbol_table_entry : endianness -> byte_sequence -> error (elf32_symbol_table_entry * byte_sequence)*) let read_elf32_symbol_table_entry endian bs0:(elf32_symbol_table_entry*Byte_sequence_wrapper.byte_sequence)error= (bind (read_elf32_word endian bs0) (fun (st_name, bs0) -> bind (read_elf32_addr endian bs0) (fun (st_value, bs0) -> bind (read_elf32_word endian bs0) (fun (st_size, bs0) -> bind (read_unsigned_char endian bs0) (fun (st_info, bs0) -> bind (read_unsigned_char endian bs0) (fun (st_other, bs0) -> bind (read_elf32_half endian bs0) (fun (st_shndx, bs0) -> return ({ elf32_st_name = st_name; elf32_st_value = st_value; elf32_st_size = st_size; elf32_st_info = st_info; elf32_st_other = st_other; elf32_st_shndx = st_shndx }, bs0)))))))) (*val bytes_of_elf32_symbol_table_entry : endianness -> elf32_symbol_table_entry -> byte_sequence*) let bytes_of_elf32_symbol_table_entry endian entry:Byte_sequence_wrapper.byte_sequence= (Byte_sequence.from_byte_lists [ bytes_of_elf32_word endian entry.elf32_st_name ; bytes_of_elf32_addr endian entry.elf32_st_value ; bytes_of_elf32_word endian entry.elf32_st_size ; bytes_of_unsigned_char entry.elf32_st_info ; bytes_of_unsigned_char entry.elf32_st_other ; bytes_of_elf32_half endian entry.elf32_st_shndx ]) (** [read_elf64_symbol_table_entry endian bs0] reads an ELF symbol table entry * record from byte sequence [bs0] assuming endianness [endian], returning the * remainder of the byte sequence. Fails if the byte sequence is not long enough. *) (*val read_elf64_symbol_table_entry : endianness -> byte_sequence -> error (elf64_symbol_table_entry * byte_sequence)*) let read_elf64_symbol_table_entry endian bs0:(elf64_symbol_table_entry*Byte_sequence_wrapper.byte_sequence)error= (bind (read_elf64_word endian bs0) (fun (st_name, bs0) -> bind (read_unsigned_char endian bs0) (fun (st_info, bs0) -> bind (read_unsigned_char endian bs0) (fun (st_other, bs0) -> bind (read_elf64_half endian bs0) (fun (st_shndx, bs0) -> bind (read_elf64_addr endian bs0) (fun (st_value, bs0) -> bind (read_elf64_xword endian bs0) (fun (st_size, bs0) -> return ({ elf64_st_name = st_name; elf64_st_info = st_info; elf64_st_other = st_other; elf64_st_shndx = st_shndx; elf64_st_value = st_value; elf64_st_size = st_size }, bs0)))))))) (*val bytes_of_elf64_symbol_table_entry : endianness -> elf64_symbol_table_entry -> byte_sequence*) let bytes_of_elf64_symbol_table_entry endian entry:Byte_sequence_wrapper.byte_sequence= (Byte_sequence.from_byte_lists [ bytes_of_elf64_word endian entry.elf64_st_name ; bytes_of_unsigned_char entry.elf64_st_info ; bytes_of_unsigned_char entry.elf64_st_other ; bytes_of_elf64_half endian entry.elf64_st_shndx ; bytes_of_elf64_addr endian entry.elf64_st_value ; bytes_of_elf64_xword endian entry.elf64_st_size ]) (** [read_elf32_symbol_table endian bs0] reads a symbol table from byte sequence * [bs0] assuming endianness [endian]. Assumes [bs0]'s length modulo the size * of a symbol table entry is 0. Fails otherwise. *) (*val read_elf32_symbol_table : endianness -> byte_sequence -> error elf32_symbol_table*) let rec read_elf32_symbol_table endian bs0:((elf32_symbol_table_entry)list)error= (if Nat_big_num.equal (Byte_sequence.length0 bs0)( (Nat_big_num.of_int 0)) then return [] else bind (read_elf32_symbol_table_entry endian bs0) (fun (head, bs0) -> bind (read_elf32_symbol_table endian bs0) (fun tail -> return (head::tail)))) (** [read_elf64_symbol_table endian bs0] reads a symbol table from byte sequence * [bs0] assuming endianness [endian]. Assumes [bs0]'s length modulo the size * of a symbol table entry is 0. Fails otherwise. *) (*val read_elf64_symbol_table : endianness -> byte_sequence -> error elf64_symbol_table*) let rec read_elf64_symbol_table endian bs0:((elf64_symbol_table_entry)list)error= (if Nat_big_num.equal (Byte_sequence.length0 bs0)( (Nat_big_num.of_int 0)) then return [] else bind (read_elf64_symbol_table_entry endian bs0) (fun (head, bs0) -> bind (read_elf64_symbol_table endian bs0) (fun tail -> return (head::tail)))) (** Association map of symbol name, symbol type, symbol size, symbol address * and symbol binding. * A PPCMemism. *) type symbol_address_map = (string * (Nat_big_num.num * Nat_big_num.num * Nat_big_num.num * Nat_big_num.num)) list (** [get_elf32_symbol_image_address symtab stbl] extracts the symbol address map * from the symbol table [symtab] using the string table [stbl]. * A PPCMemism. *) (*val get_elf32_symbol_image_address : elf32_symbol_table -> string_table -> error symbol_address_map*) let get_elf32_symbol_image_address symtab strtab:((string*(Nat_big_num.num*Nat_big_num.num*Nat_big_num.num*Nat_big_num.num))list)error= (mapM (fun entry -> let name1 = (Uint32_wrapper.to_bigint entry.elf32_st_name) in let addr = (Uint32_wrapper.to_bigint entry.elf32_st_value) in let size2 = (Nat_big_num.mul (Uint32_wrapper.to_bigint entry.elf32_st_size)( (Nat_big_num.of_int 8))) in let typ = (extract_symbol_type entry.elf32_st_info) in let bnd = (extract_symbol_binding entry.elf32_st_info) in bind (String_table.get_string_at name1 strtab) (fun str -> return (str, (typ, size2, addr, bnd))) ) symtab) (** [get_elf64_symbol_image_address symtab stbl] extracts the symbol address map * from the symbol table [symtab] using the string table [stbl]. * A PPCMemism. *) (*val get_elf64_symbol_image_address : elf64_symbol_table -> string_table -> error symbol_address_map*) let get_elf64_symbol_image_address symtab strtab:((string*(Nat_big_num.num*Nat_big_num.num*Nat_big_num.num*Nat_big_num.num))list)error= (mapM (fun entry -> let name1 = (Uint32_wrapper.to_bigint entry.elf64_st_name) in let addr = (Ml_bindings.nat_big_num_of_uint64 entry.elf64_st_value) in let size2 = (Ml_bindings.nat_big_num_of_uint64 entry.elf64_st_size) in let typ = (extract_symbol_type entry.elf64_st_info) in let bnd = (extract_symbol_binding entry.elf64_st_info) in bind (String_table.get_string_at name1 strtab) (fun str -> return (str, (typ, size2, addr, bnd))) ) symtab) (** [get_el32_symbol_type ent] extracts the symbol type from symbol table entry * [ent]. *) (*val get_elf32_symbol_type : elf32_symbol_table_entry -> natural*) let get_elf32_symbol_type syment:Nat_big_num.num= (extract_symbol_type syment.elf32_st_info) (** [get_el64_symbol_type ent] extracts the symbol type from symbol table entry * [ent]. *) (*val get_elf64_symbol_type : elf64_symbol_table_entry -> natural*) let get_elf64_symbol_type syment:Nat_big_num.num= (extract_symbol_type syment.elf64_st_info) (** [get_el32_symbol_binding ent] extracts the symbol binding from symbol table entry * [ent]. *) (*val get_elf32_symbol_binding : elf32_symbol_table_entry -> natural*) let get_elf32_symbol_binding syment:Nat_big_num.num= (extract_symbol_binding syment.elf32_st_info) (** [get_el64_symbol_binding ent] extracts the symbol binding from symbol table entry * [ent]. *) (*val get_elf64_symbol_binding : elf64_symbol_table_entry -> natural*) let get_elf64_symbol_binding syment:Nat_big_num.num= (extract_symbol_binding syment.elf64_st_info)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>