<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - No relocation emitted for hidden visibility using lld -r"
   href="https://llvm.org/bugs/show_bug.cgi?id=28967">28967</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No relocation emitted for hidden visibility using lld -r
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rink@rink.nu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16942" name="attach_16942" title="Small program to show the problem">attachment 16942</a> <a href="attachment.cgi?id=16942&action=edit" title="Small program to show the problem">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>