[llvm-bugs] [Bug 28967] New: No relocation emitted for hidden visibility using lld -r

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 13 09:11:00 PDT 2016


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

            Bug ID: 28967
           Summary: No relocation emitted for hidden visibility using lld
                    -r
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: rink at rink.nu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16942
  --> https://llvm.org/bugs/attachment.cgi?id=16942&action=edit
Small program to show the problem

If using lld -r to combine multiple object files, the resulting object will not
correctly reference hidden symbols (linking to such an object file will have
offset 0 inserted).

To reproduce, try the attached archive - it works with GNU LD 2.26.1 which
yields:

00000000004000b0 <_start>:
  4000b0:    e8 0e 00 00 00           callq  4000c3 <doit>
  4000b5:    48 c7 c0 3c 00 00 00     mov    $0x3c,%rax
  4000bc:    48 31 ff                 xor    %rdi,%rdi
  4000bf:    0f 05                    syscall 
  4000c1:    c3                       retq   

00000000004000c2 <foo>:
  4000c2:    c3                       retq   

00000000004000c3 <doit>:
  4000c3:    55                       push   %rbp
  4000c4:    48 89 e5                 mov    %rsp,%rbp
  4000c7:    e8 f6 ff ff ff           callq  4000c2 <foo>
  4000cc:    90                       nop
  4000cd:    5d                       pop    %rbp
  4000ce:    c3                       retq  

However, Clang LLD (r278597) gives:

0000000000011000 <_start>:
   11000:    e8 0e 00 00 00           callq  11013 <doit>
   11005:    48 c7 c0 3c 00 00 00     mov    $0x3c,%rax
   1100c:    48 31 ff                 xor    %rdi,%rdi
   1100f:    0f 05                    syscall 
   11011:    c3                       retq   

0000000000011012 <foo>:
   11012:    c3                       retq   

0000000000011013 <doit>:
   11013:    55                       push   %rbp
   11014:    48 89 e5                 mov    %rsp,%rbp
   11017:    e8 e4 ef fe ff           callq  0 <_start-0x11000>  <-- WRONG
   1101c:    90                       nop
   1101d:    5d                       pop    %rbp
   1101e:    c3                       retq   

And the resulting binary crashes in the LLD-case.

This may have to do with the 'foo' symbol being marked 'l' (local) in the rel.o
file (objdump -x rel.o), but that is just my guesswork.

-- 
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/20160813/d76cf2b5/attachment.html>


More information about the llvm-bugs mailing list