Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcode files should have a symbol table similar to object files #27925

Closed
llvmbot opened this issue Apr 28, 2016 · 4 comments
Closed

Bitcode files should have a symbol table similar to object files #27925

llvmbot opened this issue Apr 28, 2016 · 4 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla llvm:bitcode

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 28, 2016

Bugzilla Link 27551
Resolution FIXED
Resolved on Jun 27, 2017 16:51
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @joker-eph,@pcc

Extended Description

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
@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 28, 2016

assigned to @joker-eph

@joker-eph
Copy link
Collaborator

I have exactly the same reasoning and I have plan to do that, this year hopefully.

@joker-eph
Copy link
Collaborator

As a first step: abstracting away the IR when manipulating a bitcode files as an object file (llvm-nm, ranlib, libLTO symbol resolution…)

Patch out for review: https://reviews.llvm.org/D23132

@pcc
Copy link
Contributor

pcc commented Jun 27, 2017

This was fixed in a series of changes that ended in r306488.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:bitcode
Projects
None yet
Development

No branches or pull requests

3 participants