<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 - assignments made before SECTIONS do not reflect final values after section parsing"
href="https://bugs.llvm.org/show_bug.cgi?id=42990">42990</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>assignments made before SECTIONS do not reflect final values after section parsing
</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>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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>keescook@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
</td>
</tr></table>
<p>
<div>
<pre>The following poc.lds links differently between bfd and lld:
__efistub__end = _end;
SECTIONS
{
. = 0xffff;
. += ((_end >> 8) - 0xff );
_end = .;
}
Linking with an empty .o file:
$ ld.lld -maarch64elf -shared -o vmlinux.lld -T poc.lds /tmp/test.o && readelf
-Ws vmlinux.lld | egrep '\b(__init_pg_size|(__efistub_|)_end)\b'
2: 000000000000ffff 0 NOTYPE GLOBAL DEFAULT 1 _end
3: 000000000000ff00 0 NOTYPE GLOBAL DEFAULT 1 __efistub__end
i.e. __efistub__end is calculated before _end is known. Moving the
__efistub__end assignment to after the SECTIONS {} works around this bug.
bfd produces the same results with either ordering:
$ aarch64-linux-gnu-ld.bfd -maarch64elf -shared -o vmlinux.bfd -T poc.lds
/tmp/test.o && readelf -Ws vmlinux.bfd | egrep
'\b(__init_pg_size|(__efistub_|)_end)\b'
2: 000000000000ffff 0 NOTYPE GLOBAL DEFAULT 1 _end
4: 000000000000ffff 0 NOTYPE GLOBAL DEFAULT ABS __efistub__end</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>