[llvm-bugs] [Bug 40804] New: Allow dumping of ELF header even if some elements are corrupt

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 21 08:19:28 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40804

            Bug ID: 40804
           Summary: Allow dumping of ELF header even if some elements are
                    corrupt
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-readobj
          Assignee: unassignedbugs at nondot.org
          Reporter: jh7370.2008 at my.bristol.ac.uk
                CC: jh7370.2008 at my.bristol.ac.uk, llvm-bugs at lists.llvm.org

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190221/46b1e465/attachment.html>


More information about the llvm-bugs mailing list