<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 - OUTPUT_FORMAT from linker script doesn't override the -m flag"
href="https://bugs.llvm.org/show_bug.cgi?id=37432">37432</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>OUTPUT_FORMAT from linker script doesn't override the -m flag
</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>dima@golovin.in
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>For GNU ld OUTPUT_FORMAT overrides the -m flag (and Linux relies on this
behavior when linking realmode.elf on x86_64), for LLD it doesn't.
How to reproduce (on modern x86_64 Linux with recent clang and lld):
- create an example object file for i386:
clang -c -m32 -x c -o test.o /dev/null
- create an example linker script with the following content:
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386)
SECTIONS {
. = 0x00000000;
.text : {
test.o (.text);
}
}
- try linking using wrong -m flag: ld.lld -m elf_x86_64 -T test.lds -o
test.elf test.o
Expected result:
Output format information from the linker script is used (the -m flag is
ignored) and an ELF binary is produced. This is at least how bfd and gold from
GNU binutils 2.29.1 behave.
Actual result:
Output format from -m flag is used (OUTPUT_FORMAT in the linker script is
ignored) and the following error is produced: ld.lld: error: test.o is
incompatible with elf_x86_64
I don't insist that GNU implementation is correct and lld is not, I don't know
if any standard actually covers this, I just think that ld.lld should be
compatible with GNU utilities, so it can be used as a drop-in replacement.</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>