(** [abi_aarch64_le] contains top-level definition for the AArch64 ABI (little-endian case). *) open import Basic_classes open import Bool open import List open import Num open import Maybe open import Assert_extra open import Error open import Missing_pervasives open import Elf_header open import Elf_types_native_uint open import Elf_file open import Elf_interpreted_segment open import Elf_interpreted_section open import Endianness (* open import Elf_memory_image *) open import Abi_classes open import Memory_image open import Abi_aarch64_relocation open import Abi_aarch64_le_elf_header (** [abi_aarch64_le_compute_program_entry_point segs entry] computes the program * entry point using ABI-specific conventions. On AArch64 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_aarch64_le_compute_program_entry_point : list elf64_interpreted_segments -> elf64_addr -> error natural let abi_aarch64_le_compute_program_entry_point segs entry = return (natural_of_elf64_addr entry) val header_is_aarch64_le : elf64_header -> bool let header_is_aarch64_le h = is_valid_elf64_header h && List.index h.elf64_ident (unsafe_nat_of_natural elf_ii_data) = Just (unsigned_char_of_natural elf_data_2lsb) && is_valid_abi_aarch64_le_machine_architecture (natural_of_elf64_half h.elf64_machine) && is_valid_abi_aarch64_le_magic_number h.elf64_ident type aarch64_le_abi_feature = GOT | PLT (* placeholder / FIXME *) val abiFeatureCompare : aarch64_le_abi_feature -> aarch64_le_abi_feature -> Basic_classes.ordering let abiFeatureCompare f1 f2 = match (f1, f2) with (GOT, GOT) -> EQ | (GOT, PLT) -> LT | (PLT, PLT) -> EQ | (PLT, GOT) -> GT end val abiFeatureTagEq : aarch64_le_abi_feature -> aarch64_le_abi_feature -> bool let abiFeatureTagEq f1 f2 = match (f1, f2) with (GOT, GOT) -> true | (PLT, PLT) -> true | (_, _) -> false end instance (Ord aarch64_le_abi_feature) let compare = abiFeatureCompare let (<) = fun f1 -> (fun f2 -> (abiFeatureCompare f1 f2 = LT)) let (<=) = fun f1 -> (fun f2 -> Set.member (abiFeatureCompare f1 f2) {LT; EQ}) let (>) = fun f1 -> (fun f2 -> (abiFeatureCompare f1 f2 = GT)) let (>=) = fun f1 -> (fun f2 -> Set.member (abiFeatureCompare f1 f2) {GT; EQ}) end instance (AbiFeatureTagEquiv aarch64_le_abi_feature) let abiFeatureTagEquiv = abiFeatureTagEq end val section_is_special : forall 'abifeature. elf64_interpreted_section -> annotated_memory_image 'abifeature -> bool let section_is_special s f = elf_section_is_special s f || (* FIXME *) false