1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*Generated by Lem from abis/amd64/abi_amd64.lem.*)(** [abi_amd64] contains top-level definition for the AMD64 ABI.
*)openLem_basic_classesopenLem_boolopenLem_listopenLem_numopenLem_maybeopenErroropenLem_mapopenLem_assert_extraopenMissing_pervasivesopenElf_headeropenElf_types_native_uintopenElf_fileopenElf_interpreted_segmentopenElf_interpreted_sectionopenEndiannessopenMemory_image(* open import Elf_memory_image *)openAbi_classesopenAbi_amd64_relocationopenAbi_amd64_elf_header(** [abi_amd64_compute_program_entry_point segs entry] computes the program
* entry point using ABI-specific conventions. On AMD64 the entry point in
* the ELF header ([entry] here) is the real entry point. On other ABIs, e.g.
* PowerPC64, the entry point [entry] is a pointer into one of the segments
* constituting the process image (passed in as [segs] here for a uniform
* interface).
*)(*val abi_amd64_compute_program_entry_point : list elf64_interpreted_segments -> elf64_addr -> error natural*)letabi_amd64_compute_program_entry_pointsegsentry:(Nat_big_num.num)error=(return(Ml_bindings.nat_big_num_of_uint64entry))(*val header_is_amd64 : elf64_header -> bool*)letheader_is_amd64h:bool=(is_valid_elf64_headerh&&((Lem.option_equal(=)(Lem_list.list_indexh.elf64_ident(Nat_big_num.to_intelf_ii_data))(Some(Uint32_wrapper.of_bigintelf_data_2lsb)))&&(is_valid_abi_amd64_machine_architecture(Uint32_wrapper.to_biginth.elf64_machine)&&is_valid_abi_amd64_magic_numberh.elf64_ident)))letshf_x86_64_large:Nat_big_num.num=(Nat_big_num.mul((Nat_big_num.of_int256))((Nat_big_num.of_int1048576)))(* 0x10000000 a.k.a. 2^28 *)(* We model the PLT as a list of symbol name, maybe def, and a function
* - from the PLT slot offset and the whole with-addresses image (overkill)
* - to... what? currently it's the address of the named symbol *)type'abifeatureplt_entry_content_fn=Nat_big_num.num->Nat_big_num.num->(Nat_big_num.num*charlist)(* PLT base addr, GOT base addr (the rest is closure-captured) -> slot_addr, slot contents *)type'abifeatureamd64_abi_feature=GOT0of((string*(symbol_definitionoption))list)|PLT0of((string*(symbol_definitionoption)*'abifeatureplt_entry_content_fn)list)(*val abiFeatureCompare : forall 'abifeature. amd64_abi_feature 'abifeature -> amd64_abi_feature 'abifeature -> Basic_classes.ordering*)letabiFeatureCompare0f1f2:int=((match(f1,f2)with(GOT0(_),GOT0(_))->0|(GOT0(_),PLT0(_))->(-1)|(PLT0(_),PLT0(_))->0|(PLT0(_),GOT0(_))->1))(*val abiFeatureTagEq : forall 'abifeature. amd64_abi_feature 'abifeature -> amd64_abi_feature 'abifeature -> bool*)letabiFeatureTagEq0f1f2:bool=((match(f1,f2)with(GOT0(_),GOT0(_))->true|(PLT0(_),PLT0(_))->true|(_,_)->false))letinstance_Abi_classes_AbiFeatureTagEquiv_Abi_amd64_amd64_abi_feature_dict:('abifeatureamd64_abi_feature)abiFeatureTagEquiv_class=({abiFeatureTagEquiv_method=abiFeatureTagEq0})letinstance_Basic_classes_Ord_Abi_amd64_amd64_abi_feature_dict:('abifeatureamd64_abi_feature)ord_class=({compare_method=abiFeatureCompare0;isLess_method=(funf1->(funf2->(Lem.orderingEqual(abiFeatureCompare0f1f2)(-1))));isLessEqual_method=(funf1->(funf2->Pset.mem(abiFeatureCompare0f1f2)(Pset.from_listcompare[(-1);0])));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(abiFeatureCompare0f1f2)1)));isGreaterEqual_method=(funf1->(funf2->Pset.mem(abiFeatureCompare0f1f2)(Pset.from_listcompare[1;0])))})(*val section_is_special : forall 'abifeature. elf64_interpreted_section -> annotated_memory_image 'abifeature -> bool*)letsection_is_special1simg2:bool=(elf_section_is_specialsimg2||(matchs.elf64_section_name_as_stringwith".eh_frame"->true(* HACK needed because SHT_X86_64_UNWIND is often not used *)|_->false))