<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 - --only-keep-debug crash with no section header table"
   href="https://bugs.llvm.org/show_bug.cgi?id=50160">50160</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>--only-keep-debug crash with no section header table
          </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>Linux
          </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-objcopy/strip
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rupprecht@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>alexander.v.shaposhnikov@gmail.com, jake.h.ehrlich@gmail.com, jh7370.2008@my.bristol.ac.uk, llvm-bugs@lists.llvm.org, rupprecht@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Found this on an internal binary. llvm-objcopy --only-keep-debug crashes here,
although the input file is weird -- we should probably have a similar error
message as GNU objcopy.

$ cat /tmp/x.yaml 
--- !ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_EXEC
Sections:
  - Name:    .foo
    Type:    SHT_PROGBITS
    Flags:   [ SHF_ALLOC ]
    Size:    0x01000
ProgramHeaders:
  - Type:            PT_NULL
    Flags:           [  ]
    FileSize:        0x01000
$ bin/yaml2obj /tmp/x.yaml > /tmp/x.o
$ bin/llvm-strip --strip-sections /tmp/x.o
$ bin/llvm-objcopy --only-keep-debug /tmp/x.o /tmp/y.o
<crash>
$ objcopy /tmp/x.o /tmp/y.o  # Note: GNU objcopy
objcopy: error: the input file '/tmp/x.o' has no sections</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>