Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file elf_interpreted_section.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305(*Generated by Lem from elf_interpreted_section.lem.*)(** Module [elf_interpreted_section] provides a record of "interpreted" sections,
* i.e. the data stored in the section header table converted to more amenable
* infinite precision types, and operation on those records.
*)openLem_basic_classesopenLem_boolopenLem_listopenLem_maybeopenLem_numopenLem_stringopenByte_sequenceopenErroropenString_tableopenElf_types_native_uintopenElf_section_header_tableopenMissing_pervasivesopenShow(** [elf32_interpreted_section] exactly mirrors the structure of a section header
* table entry, barring the conversion of all fields to more amenable types.
*)typeelf32_interpreted_section={elf32_section_name:Nat_big_num.num(** Name of the section *);elf32_section_type:Nat_big_num.num(** Type of the section *);elf32_section_flags:Nat_big_num.num(** Flags associated with the section *);elf32_section_addr:Nat_big_num.num(** Base address of the section in memory *);elf32_section_offset:Nat_big_num.num(** Offset from beginning of file *);elf32_section_size:Nat_big_num.num(** Section size in bytes *);elf32_section_link:Nat_big_num.num(** Section header table index link *);elf32_section_info:Nat_big_num.num(** Extra information, depends on section type *);elf32_section_align:Nat_big_num.num(** Alignment constraints for section *);elf32_section_entsize:Nat_big_num.num(** Size of each entry in table, if section is one *);elf32_section_body:byte_sequence0(** Body of section *);elf32_section_name_as_string:string(** Name of the section, as a string; "" for no name (name = 0) *)}(** [elf32_interpreted_section_equal s1 s2] is an equality test on interpreted
* sections [s1] and [s2].
*)(*val elf32_interpreted_section_equal : elf32_interpreted_section -> elf32_interpreted_section -> bool*)letelf32_interpreted_section_equalxy:bool=(Nat_big_num.equalx.elf32_section_namey.elf32_section_name&&(Nat_big_num.equalx.elf32_section_typey.elf32_section_type&&(Nat_big_num.equalx.elf32_section_flagsy.elf32_section_flags&&(Nat_big_num.equalx.elf32_section_addry.elf32_section_addr&&(Nat_big_num.equalx.elf32_section_offsety.elf32_section_offset&&(Nat_big_num.equalx.elf32_section_sizey.elf32_section_size&&(Nat_big_num.equalx.elf32_section_linky.elf32_section_link&&(Nat_big_num.equalx.elf32_section_infoy.elf32_section_info&&(Nat_big_num.equalx.elf32_section_aligny.elf32_section_align&&(Nat_big_num.equalx.elf32_section_entsizey.elf32_section_entsize&&(Byte_sequence_wrapper.equalx.elf32_section_bodyy.elf32_section_body&&(x.elf32_section_name_as_string=y.elf32_section_name_as_string))))))))))))letinstance_Basic_classes_Eq_Elf_interpreted_section_elf32_interpreted_section_dict:(elf32_interpreted_section)eq_class=({isEqual_method=elf32_interpreted_section_equal;isInequal_method=(funxy->not(elf32_interpreted_section_equalxy))})(** [elf64_interpreted_section] exactly mirrors the structure of a section header
* table entry, barring the conversion of all fields to more amenable types.
*)typeelf64_interpreted_section={elf64_section_name:Nat_big_num.num(** Name of the section *);elf64_section_type:Nat_big_num.num(** Type of the section *);elf64_section_flags:Nat_big_num.num(** Flags associated with the section *);elf64_section_addr:Nat_big_num.num(** Base address of the section in memory *);elf64_section_offset:Nat_big_num.num(** Offset from beginning of file *);elf64_section_size:Nat_big_num.num(** Section size in bytes *);elf64_section_link:Nat_big_num.num(** Section header table index link *);elf64_section_info:Nat_big_num.num(** Extra information, depends on section type *);elf64_section_align:Nat_big_num.num(** Alignment constraints for section *);elf64_section_entsize:Nat_big_num.num(** Size of each entry in table, if section is one *);elf64_section_body:byte_sequence0(** Body of section *);elf64_section_name_as_string:string(** Name of the section, as a string; "" for no name (name = 0) *)}(** [compare_elf64_interpreted_section s1 s2] is an ordering comparison function
* on interpreted sections suitable for use in sets, finite maps and other
* ordered structures.
*)(*val compare_elf64_interpreted_section : elf64_interpreted_section -> elf64_interpreted_section ->
ordering*)letcompare_elf64_interpreted_sections1s2:int=(pairCompare(lexicographic_compareNat_big_num.compare)Byte_sequence_wrapper.compare([s1.elf64_section_name;s1.elf64_section_type;s1.elf64_section_flags;s1.elf64_section_addr;s1.elf64_section_offset;s1.elf64_section_size;s1.elf64_section_link;s1.elf64_section_info;s1.elf64_section_align;s1.elf64_section_entsize],s1.elf64_section_body)([s2.elf64_section_name;s2.elf64_section_type;s2.elf64_section_flags;s2.elf64_section_addr;s2.elf64_section_offset;s2.elf64_section_size;s2.elf64_section_link;s2.elf64_section_info;s2.elf64_section_align;s2.elf64_section_entsize],s2.elf64_section_body))letinstance_Basic_classes_Ord_Elf_interpreted_section_elf64_interpreted_section_dict:(elf64_interpreted_section)ord_class=({compare_method=compare_elf64_interpreted_section;isLess_method=(funf1->(funf2->(Lem.orderingEqual(compare_elf64_interpreted_sectionf1f2)(-1))));isLessEqual_method=(funf1->(funf2->Pset.mem(compare_elf64_interpreted_sectionf1f2)(Pset.from_listcompare[(-1);0])));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(compare_elf64_interpreted_sectionf1f2)1)));isGreaterEqual_method=(funf1->(funf2->Pset.mem(compare_elf64_interpreted_sectionf1f2)(Pset.from_listcompare[1;0])))})(** [elf64_interpreted_section_equal s1 s2] is an equality test on interpreted
* sections [s1] and [s2].
*)(*val elf64_interpreted_section_equal : elf64_interpreted_section -> elf64_interpreted_section -> bool*)letelf64_interpreted_section_equalxy:bool=(Nat_big_num.equalx.elf64_section_namey.elf64_section_name&&(Nat_big_num.equalx.elf64_section_typey.elf64_section_type&&(Nat_big_num.equalx.elf64_section_flagsy.elf64_section_flags&&(Nat_big_num.equalx.elf64_section_addry.elf64_section_addr&&(Nat_big_num.equalx.elf64_section_offsety.elf64_section_offset&&(Nat_big_num.equalx.elf64_section_sizey.elf64_section_size&&(Nat_big_num.equalx.elf64_section_linky.elf64_section_link&&(Nat_big_num.equalx.elf64_section_infoy.elf64_section_info&&(Nat_big_num.equalx.elf64_section_aligny.elf64_section_align&&(Nat_big_num.equalx.elf64_section_entsizey.elf64_section_entsize&&(Byte_sequence_wrapper.equalx.elf64_section_bodyy.elf64_section_body&&(x.elf64_section_name_as_string=y.elf64_section_name_as_string))))))))))))(** [null_elf32_interpreted_section] --- the null interpreted section.
*)(*val null_elf32_interpreted_section : elf32_interpreted_section*)letnull_elf32_interpreted_section:elf32_interpreted_section=({elf32_section_name=((Nat_big_num.of_int0));elf32_section_type=((Nat_big_num.of_int0));elf32_section_flags=((Nat_big_num.of_int0));elf32_section_addr=((Nat_big_num.of_int0));elf32_section_offset=((Nat_big_num.of_int0));elf32_section_size=((Nat_big_num.of_int0));elf32_section_link=((Nat_big_num.of_int0));elf32_section_info=((Nat_big_num.of_int0));elf32_section_align=((Nat_big_num.of_int0));elf32_section_entsize=((Nat_big_num.of_int0));elf32_section_body=Byte_sequence.empty;elf32_section_name_as_string=""})(** [null_elf64_interpreted_section] --- the null interpreted section.
*)(*val null_elf64_interpreted_section : elf64_interpreted_section*)letnull_elf64_interpreted_section:elf64_interpreted_section=({elf64_section_name=((Nat_big_num.of_int0));elf64_section_type=((Nat_big_num.of_int0));elf64_section_flags=((Nat_big_num.of_int0));elf64_section_addr=((Nat_big_num.of_int0));elf64_section_offset=((Nat_big_num.of_int0));elf64_section_size=((Nat_big_num.of_int0));elf64_section_link=((Nat_big_num.of_int0));elf64_section_info=((Nat_big_num.of_int0));elf64_section_align=((Nat_big_num.of_int0));elf64_section_entsize=((Nat_big_num.of_int0));elf64_section_body=Byte_sequence.empty;elf64_section_name_as_string=""})letinstance_Basic_classes_Eq_Elf_interpreted_section_elf64_interpreted_section_dict:(elf64_interpreted_section)eq_class=({isEqual_method=elf64_interpreted_section_equal;isInequal_method=(funxy->not(elf64_interpreted_section_equalxy))})(** [elf64_interpreted_section_matches_section_header sect ent] checks whether
* the interpreted section and the corresponding section header table entry
* match.
*)(*val elf64_interpreted_section_matches_section_header :
elf64_interpreted_section
-> elf64_section_header_table_entry
-> bool*)letelf64_interpreted_section_matches_section_headerish:bool=(Nat_big_num.equali.elf64_section_name(Uint32_wrapper.to_bigintsh.elf64_sh_name)&&(Nat_big_num.equali.elf64_section_type(Uint32_wrapper.to_bigintsh.elf64_sh_type)&&(Nat_big_num.equali.elf64_section_flags(Ml_bindings.nat_big_num_of_uint64sh.elf64_sh_flags)&&(Nat_big_num.equali.elf64_section_addr(Ml_bindings.nat_big_num_of_uint64sh.elf64_sh_addr)&&(Nat_big_num.equali.elf64_section_offset(Uint64_wrapper.to_bigintsh.elf64_sh_offset)&&(Nat_big_num.equali.elf64_section_size(Ml_bindings.nat_big_num_of_uint64sh.elf64_sh_size)&&(Nat_big_num.equali.elf64_section_link(Uint32_wrapper.to_bigintsh.elf64_sh_link)&&(Nat_big_num.equali.elf64_section_info(Uint32_wrapper.to_bigintsh.elf64_sh_info)&&(Nat_big_num.equali.elf64_section_align(Ml_bindings.nat_big_num_of_uint64sh.elf64_sh_addralign)(* WHY? *)&&Nat_big_num.equali.elf64_section_entsize(Ml_bindings.nat_big_num_of_uint64sh.elf64_sh_entsize))))))))))(* Don't compare the name as a string, because it's implied by the shshtrtab index. *)(* NOTE that we can have multiple sections *indistinguishable*
* except by their section header table index. Imagine
* multiple zero-size bss sections at the same address with the same name.
* That's why in elf_memory_image we always label each ElfSection
* with its SHT index.
*)typeelf32_interpreted_sections=elf32_interpreted_sectionlisttypeelf64_interpreted_sections=elf64_interpreted_sectionlist(** [string_of_elf32_interpreted_section sect] returns a string-based representation
* of interpreted section, [sect].
*)(*val string_of_elf32_interpreted_section : elf32_interpreted_section -> string*)letstring_of_elf32_interpreted_sectionis:string=(unlines[("Name: "^(is.elf32_section_name_as_string^("("^((Nat_big_num.to_stringis.elf32_section_name)^")"))));("Type: "^Nat_big_num.to_stringis.elf32_section_type);("Flags: "^Nat_big_num.to_stringis.elf32_section_type);("Base address: "^Nat_big_num.to_stringis.elf32_section_addr);("Section offset: "^Nat_big_num.to_stringis.elf32_section_offset);("Section size: "^Nat_big_num.to_stringis.elf32_section_size);("Link: "^Nat_big_num.to_stringis.elf32_section_link);("Info: "^Nat_big_num.to_stringis.elf32_section_info);("Section alignment: "^Nat_big_num.to_stringis.elf32_section_align);("Entry size: "^Nat_big_num.to_stringis.elf32_section_entsize)])(** [string_of_elf64_interpreted_section sect] returns a string-based representation
* of interpreted section, [sect].
*)(*val string_of_elf64_interpreted_section : elf64_interpreted_section -> string*)letstring_of_elf64_interpreted_sectionis:string=(unlines[("Name: "^(is.elf64_section_name_as_string^("("^((Nat_big_num.to_stringis.elf64_section_name)^")"))));("Type: "^Nat_big_num.to_stringis.elf64_section_type);("Flags: "^Nat_big_num.to_stringis.elf64_section_type);("Base address: "^Nat_big_num.to_stringis.elf64_section_addr);("Section offset: "^Nat_big_num.to_stringis.elf64_section_offset);("Section size: "^Nat_big_num.to_stringis.elf64_section_size);("Link: "^Nat_big_num.to_stringis.elf64_section_link);("Info: "^Nat_big_num.to_stringis.elf64_section_info);("Section alignment: "^Nat_big_num.to_stringis.elf64_section_align);("Entry size: "^Nat_big_num.to_stringis.elf64_section_entsize)])(** [is_valid_elf32_section_header_table_entry sect stab] checks whether a
* interpreted section conforms with the prescribed flags and types declared
* in the "special sections" table of the ELF specification.
* TODO: some of these entries in the table are overridden by ABI supplements.
* Make sure it is these that are passed in rather than the default table
* declared in the spec?
*)(*val is_valid_elf32_section_header_table_entry : elf32_interpreted_section ->
string_table -> bool*)letis_valid_elf32_section_header_table_entryentstbl:bool=((matchString_table.get_string_atent.elf32_section_namestblwith|Failf->false|Successname1->(matchPmap.lookupname1elf_special_sectionswith|None->false(* ??? *)|Some(typ,flags)->Nat_big_num.equaltypent.elf32_section_type&&Nat_big_num.equalflagsent.elf32_section_flags)))(** [is_valid_elf64_section_header_table_entry sect stab] checks whether a
* interpreted section conforms with the prescribed flags and types declared
* in the "special sections" table of the ELF specification.
* TODO: some of these entries in the table are overridden by ABI supplements.
* Make sure it is these that are passed in rather than the default table
* declared in the spec?
*)(*val is_valid_elf64_section_header_table_entry : elf64_interpreted_section ->
string_table -> bool*)letis_valid_elf64_section_header_table_entryentstbl:bool=((matchString_table.get_string_atent.elf64_section_namestblwith|Failf->false|Successname1->(matchPmap.lookupname1elf_special_sectionswith|None->false(* ??? *)|Some(typ,flags)->Nat_big_num.equaltypent.elf64_section_type&&Nat_big_num.equalflagsent.elf64_section_flags)))(** [is_valid_elf32_section_header_table sects] checks whether all entries in
* [sect] are valid.
*)(*val is_valid_elf32_section_header_table : list elf32_interpreted_section ->
string_table -> bool*)letis_valid_elf32_section_header_table0entsstbl:bool=(List.for_all(funx->is_valid_elf32_section_header_table_entryxstbl)ents)(** [is_valid_elf64_section_header_table sects] checks whether all entries in
* [sect] are valid.
*)(*val is_valid_elf64_section_header_table : list elf64_interpreted_section ->
string_table -> bool*)letis_valid_elf64_section_header_table0entsstbl:bool=(List.for_all(funx->is_valid_elf64_section_header_table_entryxstbl)ents)