<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 - Improve handling of invalid symbol indexes in relocations"
   href="https://bugs.llvm.org/show_bug.cgi?id=40801">40801</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve handling of invalid symbol indexes in relocations
          </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>Currently, llvm-readobj emits an error if it encounters a relocation which
references a symbol index for a symbol that doesn't exist:

c:\Work>llvm-readobj --relocations bad.o
Relocation section '.rela.text' at offset 0x1d0 contains 2 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000100000002 R_X86_64_PC32          0000000000000000 foo
+ 0

Error reading file: invalid section offset
.

This error message is not particularly helpful. In particular, the fact that it
is talking about a section offset is confusing. Also, the trailing full stop is
not in the right location. We could improve things in two ways: 1) Changing the
error message to give more information (e.g. something like "invalid symbol
index '0x42' referenced by relocation 3 in .rela.text"), 2) Don't emit an error
at all, and in llvm-readobj print the symbol index without trying to decode it
(perhaps with an associated warning message).

For refernece, GNU output does the latter (the relocations have been reordered
to show that output continues):

c:\Work>llvm-readobj --relocations bad.o
Relocation section '.rela.text' at offset 0x1d0 contains 2 entries:
  Offset          Info           Type           Sym. Value    Sym. Name +
Addend
000000000000  004200000002 R_X86_64_PC32    readelf: Error:  bad symbol index:
00000042 in reloc
000000000000  000100000002 R_X86_64_PC32     0000000000000000 foo + 0</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>