• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
      • Execloader
        • Elf-reader
          • Elf64_sym
          • Elf32_sym
          • Elf-header
          • Elf-section-header
          • Elf64-segment-header
          • Elf32-segment-header
          • Elf_bits32
          • Elf_bits8
          • Elf_bits64
          • Elf_bits16
          • Section-info
          • Read-section-headers
          • Read-segment-headers-64
          • Read-segment-headers-32
            • Read-section-names
            • Elf64_sym-info
            • Elf32_sym-info
            • Read-elf-header
            • Parse-symtab-entries
            • Populate-elf-contents
            • Is-elf-content-p
            • Get-string-section-data
            • Get-section-info1
            • Set-elf-stobj-fields
            • Get-named-section-headers
            • Elf-read-mem-null-term
            • Get-section-info
            • Get-symtab-entries
            • Find-label-address-from-elf-symtab-info
            • Section-names
            • Populate-elf
            • Get-label-addresses
            • Elf-read-string-null-term
            • Get-label-address
            • Good-elf-p
            • Elf64_sym-equiv-under-mask
            • Elf64-segment-headers
            • Elf32_sym-equiv-under-mask
            • Elf32-segment-headers
            • Section-info-list
            • Elf64_sym-info-list
            • Elf32_sym-info-list
            • Elf-section-headers
            • Elf64_sym-debug
            • Elf32_sym-debug
          • Mach-o-reader
          • Merge-first-split-bytes
          • Split-bytes
          • Take-till-zero
          • Charlist->bytes
          • Merge-bytes
          • Bytes->charlist
          • String->bytes
          • Bytes->string
        • Axe
      • Testing-utilities
      • Math
    • Elf-reader

    Read-segment-headers-32

    Read 64-bit ELF segment headers

    Signature
    (read-segment-headers-32 nsegments rest-of-the-file acc) 
      → 
    32-bit-segments
    Arguments
    nsegments — Guard (natp nsegments).
    rest-of-the-file — Guard (byte-listp rest-of-the-file).
    acc — Guard (elf32-segment-headers-p acc).
    Returns
    32-bit-segments — Type (elf32-segment-headers-p 32-bit-segments), given (elf32-segment-headers-p acc).

    Definitions and Theorems

    Function: read-segment-headers-32

    (defun read-segment-headers-32 (nsegments rest-of-the-file acc)
      (declare (xargs :guard (and (natp nsegments)
                                  (byte-listp rest-of-the-file)
                                  (elf32-segment-headers-p acc))))
      (let ((__function__ 'read-segment-headers-32))
        (declare (ignorable __function__))
        (if (zp nsegments)
            (reverse acc)
          (b* (((mv p_type rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_offset rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_vaddr rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_paddr rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_filesz rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_memsz rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_flags rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               ((mv p_align rest-of-the-file)
                (merge-first-split-bytes 4 rest-of-the-file))
               (segment (make-elf32-segment-header :type p_type
                                                   :flags p_flags
                                                   :offset p_offset
                                                   :vaddr p_vaddr
                                                   :paddr p_paddr
                                                   :filesz p_filesz
                                                   :memsz p_memsz
                                                   :align p_align)))
            (read-segment-headers-32
                 (1- nsegments)
                 rest-of-the-file (cons segment acc))))))

    Theorem: elf32-segment-headers-p-of-read-segment-headers-32

    (defthm elf32-segment-headers-p-of-read-segment-headers-32
     (implies
       (elf32-segment-headers-p acc)
       (b*
        ((32-bit-segments
              (read-segment-headers-32 nsegments rest-of-the-file acc)))
        (elf32-segment-headers-p 32-bit-segments)))
     :rule-classes :rewrite)