<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 - -z combreloc sorts only by symbol index, not address"
href="https://bugs.llvm.org/show_bug.cgi?id=41692">41692</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-z combreloc sorts only by symbol index, not address
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>URL</th>
<td>https://storage.googleapis.com/fuchsia-build/reproducer/lld-combreloc+comdat.tar.gz
</td>
</tr>
<tr>
<th>OS</th>
<td>other
</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>roland@hack.frob.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jakehehrlich@google.com, llvm-bugs@lists.llvm.org, peter.smith@linaro.org, phosek@chromium.org
</td>
</tr></table>
<p>
<div>
<pre>The --reproduce tarball at
<a href="https://storage.googleapis.com/fuchsia-build/reproducer/lld-combreloc+comdat.tar.gz">https://storage.googleapis.com/fuchsia-build/reproducer/lld-combreloc+comdat.tar.gz</a>
demonstrates the issue
with ld.lld from monorepo rev 2efd30571bcc53003376410d4221f7e4dd19f4c3.
In the `readelf -Wr libc.so.debug` output see e.g.:
0000000000385f80 0000026700000001 R_X86_64_64 00000000001a8880
__execvpe + 0
00000000002924f0 0000026700000006 R_X86_64_GLOB_DAT 00000000001a8880
__execvpe + 0
These two relocs have the same symbol index and so are adjacent. But the one
with the lower r_offset is after the one with the higher offset.
lld sorts only on symbol index (see SyntheticSections.cpp::compRelocations).
The GNU linkers sort for on symbol index, then on reloc address (r_offset).
Gold finally sorts on reloc type, though BFD doesn't. The comment in Gold's
code seems to suggest that this is just meant to stand in for a stable sort.
(I don't know why it doesn't just use a stable sort instead.) Probably that
bit doesn't matter if the sort is stable, and lld uses std::stable_sort for
this already.</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>