[llvm-bugs] [Bug 33738] New: LLD relocates weak symbols in static library incorrectly when using version script

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 10 20:36:53 PDT 2017


            Bug ID: 33738
           Summary: LLD relocates weak symbols in static library
                    incorrectly when using version script
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: compnerd at compnerd.org, grimar at accesssoftek.com,
                    llvm-bugs at lists.llvm.org, rafael.espindola at gmail.com,
                    ruiu at google.com

Created attachment 18773
  --> https://bugs.llvm.org/attachment.cgi?id=18773&action=edit
Reduced test case

Refer to the attached reproduction tarball. If you run make and then
disassemble libg.so, you should see something along the lines of

0000000000001000 <g>:
    1000:       55                      push   %rbp
    1001:       48 89 e5                mov    %rsp,%rbp
    1004:       b0 00                   mov    $0x0,%al
    1006:       e8 f5 ef ff ff          callq  0 <g-0x1000>
    100b:       5d                      pop    %rbp
    100c:       c3                      retq

The callq to 0 is incorrect. Both ld.bfd and ld.gold produce something along
the lines of

 226:   e8 e5 ff ff ff          callq  210 <f at plt>

Bizarrely (at least to me), it's the presence of the version script that causes
this problem. If I remove that, LLD also produces the call to f at plt.

The static library is also required to manifest the problem. Linking against
f.o directly works both with and without the version script (it just pulls f
into the library).

I personally also find it odd that the call to f with a static library goes
through the PLT instead of pulling f into the library, but it's consistent with
bfd and gold, at least.

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/20170711/1334596a/attachment.html>

More information about the llvm-bugs mailing list