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: unassignedb...@nondot.org
          Reporter: davi...@google.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to