Initialize the ELF stobj with
(populate-elf-contents contents elf state) → (mv new-elf state)
Function:
(defun populate-elf-contents (contents elf state) (declare (xargs :stobjs (elf state))) (declare (xargs :guard (byte-listp contents))) (let ((__function__ 'populate-elf-contents)) (declare (ignorable __function__)) (b* (((mv okp header state) (is-elf-content-p contents state)) ((unless okp) (prog2$ (raise "Bad ELF contents!") (mv elf state))) (elf (!elf-header header elf)) (file-byte-list contents) (elf-file-size (len file-byte-list)) (elf (!elf-file-size elf-file-size elf)) ((elf-header header)) (class header.class) (elf-header-size (if (equal class 1) 52 64)) (elf (!elf-header-size elf-header-size elf)) (segment-header-offset header.phoff) (segment-headers (nthcdr segment-header-offset file-byte-list)) ((unless (byte-listp segment-headers)) (prog2$ (er hard? 'elf-file-read "Not enough bytes to read ELF segment headers!") (mv elf state))) (nsegments header.phnum) (?segments (if (equal class 1) (read-segment-headers-32 nsegments segment-headers nil) (read-segment-headers-64 nsegments segment-headers nil))) (section-headers (get-named-section-headers header file-byte-list)) (elf (!sections-num header.shnum elf)) (elf (set-elf-stobj-fields section-headers file-byte-list elf))) (mv elf state))))
Theorem:
(defthm good-elf-p-of-populate-elf-contents.new-elf (implies (good-elf-p elf) (b* (((mv ?new-elf acl2::?state) (populate-elf-contents contents elf state))) (good-elf-p new-elf))) :rule-classes :rewrite)