[llvm-bugs] [Bug 46502] New: [lto] Module asm symbols don't show in IR symbol table

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 29 09:46:57 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46502

            Bug ID: 46502
           Summary: [lto] Module asm symbols don't show in IR symbol table
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: hans at chromium.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

For example:

$ cat /tmp/x.c
void foo() {}

asm(".globl bar      \n"
    "bar:            \n"
    "  xor %eax, %eax\n"
    "  ret           \n");

$ clang -c -flto=thin /tmp/x.c

$ llvm-nm x.o
---------------- T foo


I expected bar to show up in the symbol table. I can see it getting processed
by ModuleSymbolTable::CollectAsmSymbols() but it doesn't seem to make it all
the way?



But even though it's not showing in the symbol table, linking against it seems
to work:

$ cat /tmp/y.c
extern void foo();
extern void bar();

int main() {
  foo();
  bar();
  return 0;
};

$ clang -flto=thin /tmp/y.c /tmp/x.c -fuse-ld=lld

$ ./a.out && echo ok
ok


Isn't the symbol table needed to resolve the 'bar' reference? Or does it
somehow work because we're linking the LLVM modules together anyway?





pcc: I can't really tell if this is a bug or if I'm missing something about how
this works.

If it is a bug, maybe the problem is how Builder::addSymbol() in IRSymtab.cpp
bails out because the symbol isn't a GlobalValue?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200629/03550c5d/attachment-0001.html>


More information about the llvm-bugs mailing list