<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Bitcode files should have a symbol table similar to object files"
   href="https://llvm.org/bugs/show_bug.cgi?id=27551">27551</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bitcode files should have a symbol table similar to object files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Bitcode Writer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mehdi.amini@apple.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using bitcode files in contexts where one normally uses an object file is a bit
odd.

For example, during symbol resolution part of a linker, the linker can look at
just the symbol table of the object file and the names it looks up can be
StringRefs pointing to the underlying mmap.

The situation is very different with bitcode files

* The names are stored in a bitcode record and we have to parse quite a bit to
make them available.
* The names are compressed (char6), so one cannot just point a StringRef at
them.
* Given the mentioned complexity, it we would have to duplicate quite a bit of
code to read the names, so everyone just builds a Module.
* The names are not final in some case. For example, in MachO they are missing
a leading _ and so have to be passed to the Mangler before the linker can use
them in symbol resolution.
* Symbol names from inline assembly are not included anywhere. One has to parse
the assembly to get them.

This creates amusing issues like lib/Object depending on MC and llvm-nm
depending on Target.

I think the solution to these problem is to add a blob with a symbol table to
the bitcode file. The table would
* Include the *final* name symbols (_foo, not foo).
* Not be compressed so that be can drop the IRObjectFile and still keep
StringRef.
* Be easy to parse without a LLVMContext.
* Include names created by inline assembly.
* Include other information a linker or nm would want: linkage, visbility,
comdat</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>