<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 sets interpreter even with -static"
href="https://bugs.llvm.org/show_bug.cgi?id=47455">47455</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld sets interpreter even with -static
</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>mforney@mforney.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
</td>
</tr></table>
<p>
<div>
<pre>I noticed that as of lld 10.0, if --dynamic-linker is specified on the
command-line, a PT_INTERP header gets added even if -static is used.
GNU ld does not add the interpreter header in this case. For example
$ ld.lld --version
LLD 10.0.1 (<a href="https://github.com/NetBSD/pkgsrc.git">https://github.com/NetBSD/pkgsrc.git</a>
375d1b4fafaee2e9c6003be296b6e92aae92e268) (compatible with GNU linkers)
$ ld.lld --dynamic-linker /lib/ld-musl-x86_64.so.1 -static -o t /lib/crt1.o
/lib/crti.o t.o /lib/libc.a /lib/crtn.o
$ readelf -l t | grep interpreter
[Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
$
$ ld --version | head -n 1
GNU ld (GNU Binutils) 2.35
$ ld --dynamic-linker /lib/ld-musl-x86_64.so.1 -static -o t /lib/crt1.o
/lib/crti.o t.o /lib/libc.a /lib/crtn.o
$ readelf -l t | grep interpreter
$
I believe this is caused by
<a href="https://github.com/llvm/llvm-project/commit/dce7a362bed866ceefc3c65924250233695d6fd4">https://github.com/llvm/llvm-project/commit/dce7a362bed866ceefc3c65924250233695d6fd4</a>.
The commit message of the referenced first attempt
<a href="https://github.com/llvm/llvm-project/commit/1417558e4a61794347c6bfbafaff7cd96985b2c3">https://github.com/llvm/llvm-project/commit/1417558e4a61794347c6bfbafaff7cd96985b2c3</a>
mentions improving compatibility with GNU ld, so this looks like an unintended
regression.
Perhaps this could be fixed by adding `&& !config->isStatic` to the condition
in ELF/Writer.cpp:needsInterpSection?
This issue was reported by a user of my hobby C compiler (cproc), which always
passes --dynamic-linker to ld, expecting it to add the PT_INTERP header only
when it is appropriate.</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>