<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 - Symbol index in symbol table printing is not reset"
   href="https://bugs.llvm.org/show_bug.cgi?id=46777">46777</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Symbol index in symbol table printing is not reset
          </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>normal
          </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>If multiple ELF objects are passed to llvm-readelf (either independently or
within an archive) when dumping symbol tables, the index of the symbols
continues incrementing across all inputs:

C:\Work\TempWork> llvm-readelf -s bar.o bar2.o

File: bar.o

Symbol table '.symtab' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS bar.cpp
     2: 0000000000000000     4 OBJECT  GLOBAL HIDDEN     4 bar
     3: 0000000000000000     4 OBJECT  GLOBAL HIDDEN     3 baz

File: bar2.o

Symbol table '.symtab' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     4: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     5: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS bar2.cpp
     6: 0000000000000000     4 OBJECT  GLOBAL HIDDEN     3 foo
     7: 0000000000000000     4 OBJECT  GLOBAL HIDDEN     4 four

This is incorrect - the "Num" column should start from 0 at the start of every
section printing (this is what GNU readelf does). The problem is the use of a
local static variable in the printSymbol function which is used to track the
index - nothing resets this for regular object files, and it only gets reset
when switching between dumping static and dynamic symbol tables.

The fix will require a little bit of refactoring, but it should be a fairly
simple thing to do.</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>