<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Allow dumping of ELF header even if some elements are corrupt"
   href="https://bugs.llvm.org/show_bug.cgi?id=40804">40804</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Allow dumping of ELF header even if some elements are corrupt
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llvm-readobj
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jh7370.2008@my.bristol.ac.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jh7370.2008@my.bristol.ac.uk, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Very few elements in the ELF header are actually required to be valid to be
able to interpret the ELF header theoretically. For example, the number of
program headers or the size of the section header fields. However, if you have
a corrupt ELF, e.g. because the e_shoff field value is larger than the file
size, llvm-readobj emits an error and exits when you try to print the ELF
header. This makes it impossible to use the tool to identify the corrupt field,
making it hard to debug. Ideally, we should only load what information we need
in the ObjectFile class to interpret what we are inspecting, and only emit an
error if we can't find that information.

Here's an example lit test, which results in an error rather than printing of
the ELF header:

# RUN: yaml2obj %s -o %t
# RUN: %python -c "with(open(r'%t','ab')) as f: f.truncate(64)"
# RUN: llvm-readobj %t --file-headers | FileCheck %s

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .text
    Type: SHT_PROGBITS</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>