• 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-elf-header
          • Read-section-headers
          • Read-segment-headers-64
          • Read-segment-headers-32
          • Read-section-names
          • Elf64_sym-info
          • Elf32_sym-info
          • Parse-symtab-entries
          • Is-elf-content-p
          • Populate-elf-contents
          • Get-string-section-data
          • Get-section-info1
          • Set-elf-stobj-fields
            • Get-named-section-headers
            • Elf-read-mem-null-term
            • Get-section-info
            • Find-label-address-from-elf-symtab-info
            • Section-names
            • Get-symtab-entries
            • Populate-elf
            • Get-label-addresses
            • Get-label-address
            • Elf-read-string-null-term
            • 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
          • Charlist->bytes
          • Take-till-zero
          • Merge-bytes
          • Bytes->charlist
          • Bytes->string
          • String->bytes
        • Axe
      • Testing-utilities
      • Math
    • Elf-reader

    Set-elf-stobj-fields

    Populate ELF stobj with bytes corresponding to each section

    Signature
    (set-elf-stobj-fields sec-headers file-bytes elf) → new-elf
    Arguments
    sec-headers — Guard (elf-section-headers-p sec-headers).
    file-bytes — Guard (byte-listp file-bytes).
    Returns
    new-elf — Type (good-elf-p new-elf), given (good-elf-p elf).

    Definitions and Theorems

    Function: set-elf-stobj-fields

    (defun
     set-elf-stobj-fields
     (sec-headers file-bytes elf)
     (declare (xargs :stobjs (elf)))
     (declare (xargs :guard (and (elf-section-headers-p sec-headers)
                                 (byte-listp file-bytes))))
     (let
      ((__function__ 'set-elf-stobj-fields))
      (declare (ignorable __function__))
      (if
       (atom sec-headers)
       elf
       (b*
        ((sec-header (car sec-headers))
         ((elf-section-header sec-header))
         (bytes (take sec-header.size
                      (nthcdr sec-header.offset file-bytes)))
         (elf
          (if
           (byte-listp bytes)
           (b* ((section (make-section-info :header sec-header
                                            :bytes bytes)))
               (!sections (cons section (@sections elf))
                          elf))
           (prog2$
            (cw
             "~% Insufficient number of bytes in the file to grab section ~s0!~% ~
      This could be a problem later, but we're moving on anyway..."
             sec-header.name-str)
            elf))))
        (set-elf-stobj-fields (cdr sec-headers)
                              file-bytes elf)))))

    Theorem: good-elf-p-of-set-elf-stobj-fields

    (defthm
     good-elf-p-of-set-elf-stobj-fields
     (implies
       (good-elf-p elf)
       (b* ((new-elf (set-elf-stobj-fields sec-headers file-bytes elf)))
           (good-elf-p new-elf)))
     :rule-classes :rewrite)