<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 - Wasm backend: crash on address of aliased function name"
href="https://bugs.llvm.org/show_bug.cgi?id=35625">35625</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wasm backend: crash on address of aliased function name
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ncw@realvnc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Discovered while prodding the libcxx build along a bit further...
Compiling the following equivalent test-cases causes an assertion failure, in
WasmObjectWriter::getRelocationIndexValue, with the message "symbol not found
table index space".
==== Test file
void exportedFn(void) {}
extern void aliasFn() __attribute__((alias("exportedFn")));
int takePtr() { return (int)&aliasFn; }
====
The symbol "aliasFn" is not added to IndirectSymbolIndices, even though
IsAddressTaken returns true for it, because WS.isVariable() is true (it's an
MCExpr::SymbolRef). Later on, the relocation attempts to reference the table
index for aliasFn, but no index was assigned because we skipped processing for
it.
The following (extremely common) C++ code will trigger the same bug:
==== C++ testcase
class CtorClass {
public:
CtorClass();
~CtorClass();
};
CtorClass::CtorClass() {}
CtorClass::~CtorClass() {}
CtorClass createObject() { return CtorClass(); }
====
The problem is the same here. C++ codegen creates two functions,
"_ZN9CtorClassC2Ev" and "_ZN9CtorClassC1Ev", the latter of which is an alias of
the former. Hence, we have the same crash because a relocation is generated
against the aliased constructor.
(Oddly, I can't quite see why the address is taken in this case? When running
with "clang -emit-llvm" followed by "llc", the C++ case compiles fine! And
there's no address-of in the emitted bitcode.)</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>