<html>
<head>
<base href="http://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/COFF should not allow absolute symbols to be exported"
href="http://bugs.llvm.org/show_bug.cgi?id=32775">32775</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLD/COFF should not allow absolute symbols to be exported
</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>Windows NT
</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>COFF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter@pcc.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I don't think it's possible to represent an exported absolute symbol in the PE
format because all exported RVAs are adjusted to the image base. And indeed,
the MSVC linker rejects attempts to do so:
<span class="quote">>type 2.s</span >
.globl i
i = 42
<span class="quote">>\src\llvm-project\ra\bin\llvm-mc -filetype=obj -o 2.obj 2.s</span >
<span class="quote">>link /dll /export:i 2.obj /defaultlib:libcmt</span >
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library 2.lib and object 2.exp
2.exp : error LNK2016: absolute symbol 'i' used as target of ADDR32NB
relocation in section 1
LINK : fatal error LNK1165: link failed because of fixup errors
But we don't:
<span class="quote">>..\llvm-project\ra\bin\lld-link /dll /export:i 2.obj /defaultlib:libcmt</span >
And we create a bogus RVA:
<span class="quote">>dumpbin /exports 2.dll</span >
Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file 2.dll
File Type: DLL
Section contains the following exports for 2.dll
00000000 characteristics
0 time date stamp
0.00 version
0 ordinal base
2 number of functions
1 number of names
ordinal hint RVA name
1 0 8000002A i
Summary
1000 .00cfg
2000 .bss
1000 .data
1000 .edata
1000 .gfids
1000 .idata
1000 .pdata
7000 .rdata
1000 .reloc
B000 .text
2000 .xdata</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>