Read the ELF header from the first 64 bytes
(read-elf-header file-header) → header
Function:
(defun read-elf-header (file-header) (declare (xargs :guard (byte-listp file-header))) (let ((__function__ 'read-elf-header)) (declare (ignorable __function__)) (b* (((mv e_magic file-header) (split-bytes 4 file-header)) ((mv e_class file-header) (merge-first-split-bytes 1 file-header)) (w (if (equal e_class 1) 4 8)) ((mv e_dataenc file-header) (merge-first-split-bytes 1 file-header)) ((mv e_identver file-header) (merge-first-split-bytes 1 file-header)) ((mv e_osabi file-header) (merge-first-split-bytes 1 file-header)) ((mv e_abiver file-header) (merge-first-split-bytes 1 file-header)) ((mv e_padding file-header) (split-bytes 7 file-header)) ((mv e_type file-header) (merge-first-split-bytes 2 file-header)) ((mv e_machine file-header) (merge-first-split-bytes 2 file-header)) ((mv e_version file-header) (merge-first-split-bytes 4 file-header)) ((mv e_entry file-header) (merge-first-split-bytes w file-header)) ((mv e_phoff file-header) (merge-first-split-bytes w file-header)) ((mv e_shoff file-header) (merge-first-split-bytes w file-header)) ((mv e_flags file-header) (merge-first-split-bytes 4 file-header)) ((mv e_ehsize file-header) (merge-first-split-bytes 2 file-header)) ((mv e_phentsize file-header) (merge-first-split-bytes 2 file-header)) ((mv e_phnum file-header) (merge-first-split-bytes 2 file-header)) ((mv e_shentsize file-header) (merge-first-split-bytes 2 file-header)) ((mv e_shnum file-header) (merge-first-split-bytes 2 file-header)) ((mv e_shstrndx &) (merge-first-split-bytes 2 file-header))) (make-elf-header :magic e_magic :class e_class :dataenc e_dataenc :identver e_identver :osabi e_osabi :abiver e_abiver :padding e_padding :type e_type :machine e_machine :version e_version :entry e_entry :phoff e_phoff :shoff e_shoff :flags e_flags :ehsize e_ehsize :phentsize e_phentsize :phnum e_phnum :shentsize e_shentsize :shnum e_shnum :shstrndx e_shstrndx))))
Theorem:
(defthm elf-header-p-of-read-elf-header (b* ((header (read-elf-header file-header))) (elf-header-p header)) :rule-classes :rewrite)