[llvm-bugs] [Bug 30609] New: Handling weakundef symbol

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 4 09:08:49 PDT 2016


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

            Bug ID: 30609
           Summary: Handling weakundef symbol
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: davidxl at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

LLVM gold plugin set the visibility of weakundef symbol to be default while GCC
lto plugin sets it to hidden.

With LLVM gold plugin and bfd linker, the weak attribute of 'hello' will be
dropped in the final shared object:


 clang  -fuse-ld=bfd -flto=thin -O2 -shared -fPIC -o libt.so test.c


If the program is compiled with -DHIDDEN, linker reports the following error
(for both bfd and Gold linker): (happens with both llvm lto and thinlto)

/usr/bin/ld: /tmp/lto-llvm-e9a305.o: relocation R_X86_64_PC32 against undefined
hidden symbol `hello_world' can not be used when making a shared object

/usr/bin/ld.gold: error: /tmp/lto-llvm-9dad7e.o: requires dynamic R_X86_64_PC32
reloc against 'hello_world' which may overflow at runtime; recompile with -fPIC


GCC LTO is fine (with both linkers)



#ifdef HIDDEN
__attribute__((weak,visibility("hidden"))) int hello_world();
#else
__attribute__((weak)) int hello_world();
#endif

int test() {
  if (hello_world)
      return hello_world();
  return 0;
}

-- 
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/20161004/59306de1/attachment.html>


More information about the llvm-bugs mailing list