[llvm-bugs] [Bug 33383] New: Linking static library does not resolve symbols as gold/ld

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 9 05:17:17 PDT 2017


            Bug ID: 33383
           Summary: Linking static library does not resolve symbols as
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: clang at martinien.de
                CC: llvm-bugs at lists.llvm.org

Created attachment 18602
  --> https://bugs.llvm.org/attachment.cgi?id=18602&action=edit

[ This is spawned from an earlier email thread, see here:
  and reply from Rui:
  http://lists.llvm.org/pipermail/llvm-dev/2017-April/112353.html ]

Hi Rui,

I finally managed to come up with a reduced example, please find it
attached. You need to have GOLDPATH and LLDPATH set to point to the
respective linkers.

What happens in build.sh is that an object file is partially linked ("-u")
with gold first, then this is linked with lld to another object file for
the final executable. The resulting executable 'repro' then crashes during
static initialization.

The following changes make it work:
1) Using ld instead of gold for the first step
2) Using ld or gold for the second step

2) makes me think there must be something those linkers are doing, but lld
is not, that makes the whole thing work. But note that the crash happens
in a constructor. I found this for the "-u" option in the ld manpage here:


"When linking C++ programs, this option will not resolve references to
constructors; to do that, use -Ur."

However, gold does not know that option (and ld already works without it)

Any idea what is going wrong here?

Thanks and best regards

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/20170609/78a0ba2c/attachment.html>

More information about the llvm-bugs mailing list