<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - LLD relocates weak symbols in static library incorrectly when using version script"
href="https://bugs.llvm.org/show_bug.cgi?id=33738">33738</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLD relocates weak symbols in static library incorrectly when using version script
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>smeenai@fb.com
</td>
</tr>
<tr>
<th>CC</th>
<td>compnerd@compnerd.org, grimar@accesssoftek.com, llvm-bugs@lists.llvm.org, rafael.espindola@gmail.com, ruiu@google.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18773" name="attach_18773" title="Reduced test case">attachment 18773</a> <a href="attachment.cgi?id=18773&action=edit" title="Reduced test case">[details]</a></span>
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@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@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.</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>