Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file gnu_ext_section_header_table.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151(*Generated by Lem from gnu_extensions/gnu_ext_section_header_table.lem.*)(** The module [gnu_ext_section_header_table] implements function, definitions
* and types relating to the GNU extensions to the standard ELF section header
* table.
*)openLem_basic_classesopenLem_boolopenLem_mapopenLem_maybeopenLem_numopenLem_stringopenHex_printingopenErroropenString_tableopenShowopenElf_section_header_tableopenElf_interpreted_section(** GNU extended section types *)(** [GNU_HASH] does not appear to be defined in the LSB but is present in
* several ELF binaries collected in the wild...
*
* TODO: find out where this comes from?
* ANSW: a mailing list apparently! See here:
* https://sourceware.org/ml/binutils/2006-10/msg00377.html
*)letsht_gnu_hash:Nat_big_num.num=(Nat_big_num.mul((Nat_big_num.of_int2))((Nat_big_num.of_int939524091)))(* 0x6FFFFFF6 *)(** The following are all defined in Section 10.2.2.2 of the LSB as additional
* section types over the ones defined in the SCO ELF spec.
*)(** [sht_gnu_verdef] contains the symbol versions that are provided.
*)letsht_gnu_verdef:Nat_big_num.num=(Nat_big_num.sub_nat(Nat_big_num.mul((Nat_big_num.of_int2))((Nat_big_num.of_int939524095)))((Nat_big_num.of_int1)))(* 0x6ffffffd *)(** [sht_gnu_verneed] contains the symbol versions that are required.
*)letsht_gnu_verneed:Nat_big_num.num=(Nat_big_num.mul((Nat_big_num.of_int2))((Nat_big_num.of_int939524095)))(* 0x6ffffffe *)(** [sht_gnu_versym] contains the symbol version table.
*)letsht_gnu_versym:Nat_big_num.num=(Nat_big_num.add(Nat_big_num.mul((Nat_big_num.of_int2))((Nat_big_num.of_int939524095)))((Nat_big_num.of_int1)))(* 0x6fffffff *)(** [sht_gnu_liblist] appears to be undocumented but appears in PowerPC 64 ELF
* binaries in "the wild".
*)letsht_gnu_liblist:Nat_big_num.num=(Nat_big_num.add(Nat_big_num.mul((Nat_big_num.of_int2))((Nat_big_num.of_int939524091)))((Nat_big_num.of_int1)))(* 0x6FFFFFF7 *)(** [string_of_gnu_ext_section_type m] produces a string based representation of
* GNU extension section type [m].
*)(*val string_of_gnu_ext_section_type : natural -> string*)letstring_of_gnu_ext_section_typei:string=(ifNat_big_num.equalisht_gnu_hashthen"GNU_HASH"elseifNat_big_num.equalisht_gnu_verdefthen"VERDEF"elseifNat_big_num.equalisht_gnu_verneedthen"VERNEED"elseifNat_big_num.equalisht_gnu_versymthen"VERSYM"elseifNat_big_num.equalisht_gnu_liblistthen"GNU_LIBLIST"elseifNat_big_num.greater_equalisht_loos&&Nat_big_num.less_equalisht_hiosthenletdiff=(Nat_big_num.sub_natisht_loos)inletsuff=(unsafe_hex_string_of_natural0diff)in"LOOS+"^suffelse"Invalid GNU EXT section type: "^Nat_big_num.to_stringi)(** [gnu_ext_additionall_special_sections] records additional section names that
* map appear in GNU ELF binaries and their required associated types and
* attributes. See Section 10.3.1.1 of the LSB and the related map
* [elf_special_sections] in [Elf_section_header_table] which records section
* names and their required types and attributes that all ELF binaries share.
*)(*val gnu_ext_additional_special_sections : Map.map string (natural * natural)*)letgnu_ext_additional_special_sections:((string),(Nat_big_num.num*Nat_big_num.num))Pmap.map=(Lem_map.fromList(instance_Map_MapKeyType_var_dictinstance_Basic_classes_SetType_var_dict)[(".ctors",(sht_progbits,Nat_big_num.addshf_allocshf_write));(".data.rel.ro",(sht_progbits,Nat_big_num.addshf_allocshf_write));(".dtors",(sht_progbits,Nat_big_num.addshf_allocshf_write));(".eh_frame",(sht_progbits,shf_alloc));(".eh_frame_hdr",(sht_progbits,shf_alloc));(".gcc_execpt_table",(sht_progbits,shf_alloc));(".gnu.version",(sht_gnu_versym,shf_alloc));(".gnu.version_d",(sht_gnu_verdef,shf_alloc));(".gnu.version_r",(sht_gnu_verneed,shf_alloc));(".got.plt",(sht_progbits,Nat_big_num.addshf_allocshf_write));(".jcr",(sht_progbits,Nat_big_num.addshf_allocshf_write));(".note.ABI-tag",(sht_note,shf_alloc));(".stab",(sht_progbits,(Nat_big_num.of_int0)));(".stabstr",(sht_strtab,(Nat_big_num.of_int0)))])(** [is_valid_gnu_ext_elf32_section_header_table_entry scts stbl] checks whether
* sections [scts] conforms with the contents of the special sections table.
* Fails otherwise.
*)(*val is_valid_gnu_ext_elf32_section_header_table_entry : elf32_interpreted_section ->
string_table -> bool*)letis_valid_gnu_ext_elf32_section_header_table_entryentstbl:bool=((matchString_table.get_string_atent.elf32_section_namestblwith|Failf->false|Successname1->(matchPmap.lookupname1gnu_ext_additional_special_sectionswith|None->is_valid_elf32_section_header_table_entryentstbl|Some(typ,flags)->Nat_big_num.equaltypent.elf32_section_type&&Nat_big_num.equalflagsent.elf32_section_flags)))(** [is_valid_gnu_ext_elf32_section_header_table sht stbl] checks whether every
* member of the section header table [sht] conforms with the special sections
* table.
*)(*val is_valid_gnu_ext_elf32_section_header_table : list elf32_interpreted_section ->
string_table -> bool*)letis_valid_gnu_ext_elf32_section_header_tableentsstbl:bool=(List.for_all(funx->is_valid_gnu_ext_elf32_section_header_table_entryxstbl)ents)(** [is_valid_gnu_ext_elf64_section_header_table_entry scts stbl] checks whether
* sections [scts] conforms with the contents of the special sections table.
* Fails otherwise.
*)(*val is_valid_gnu_ext_elf64_section_header_table_entry : elf64_interpreted_section ->
string_table -> bool*)letis_valid_gnu_ext_elf64_section_header_table_entryentstbl:bool=((matchString_table.get_string_atent.elf64_section_namestblwith|Failf->false|Successname1->(matchPmap.lookupname1gnu_ext_additional_special_sectionswith|None->is_valid_elf64_section_header_table_entryentstbl|Some(typ,flags)->Nat_big_num.equaltypent.elf64_section_type&&Nat_big_num.equalflagsent.elf64_section_flags)))(** [is_valid_gnu_ext_elf64_section_header_table sht stbl] checks whether every
* member of the section header table [sht] conforms with the special sections
* table.
*)(*val is_valid_gnu_ext_elf64_section_header_table : list elf64_interpreted_section ->
string_table -> bool*)letis_valid_gnu_ext_elf64_section_header_tableentsstbl:bool=(List.for_all(funx->is_valid_gnu_ext_elf64_section_header_table_entryxstbl)ents)