<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 - 16-bit relocation problem (ELF32)"
href="https://bugs.llvm.org/show_bug.cgi?id=36927">36927</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>16-bit relocation problem (ELF32)
</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>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>nruslan_devel@yahoo.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Consider the following example
test.S:
.code16
.global _start
_start:
movw $_start+0x8300,%ax
Basically, it is 16-bit code inside ELF32. _start is 0x7C00. Therefore, the
instruction will use 0x7C00+0x8300=0xFF00 (i.e., still fits in a 16-bit
relocation).
1. Compile with clang:
clang -c -Wall -O2 -m32 test.S -o test.o
2. GNU linker works fine:
ld -melf_i386 -Ttext 0x7c00 -s --oformat binary test.o
and generates expected code: 0xB8 0x00 0xFF
3. However, ld.lld linker incorrectly calculates the relocation in this case
(it works with smaller offsets, though):
ld.lld -melf_i386 -Ttext 0x7c00 -s --oformat binary test.o
ld.lld: error: test.o:(.text+0x1): relocation R_386_16 out of range:
18446744073709551360 is not in [0, 65535]</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>