[PATCH] D126554: [lld][WebAssembly] Fix crash on undefined/weak function symbols in LTO objects
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 08:41:40 PDT 2022
sbc100 created this revision.
Herald added subscribers: pmatos, asb, wingo, ecnelises, sunfish, jgravelle-google, inglorion, dschuff.
Herald added a project: All.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Symbols from LTO objects don't contain Wasm signatures, but we need a
signature when we create undefined/stub functions for missing weakly
undefined symbols.
Luckily, after LTO, we know that symbols that are not referenced by a
regular object file must not be needed in the final output so there
is no need to generate undefined/stub function for them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126554
Files:
lld/wasm/SymbolTable.cpp
Index: lld/wasm/SymbolTable.cpp
===================================================================
--- lld/wasm/SymbolTable.cpp
+++ lld/wasm/SymbolTable.cpp
@@ -842,7 +842,7 @@
void SymbolTable::replaceWithUndefined(Symbol *sym) {
// Add a synthetic dummy for weak undefined functions. These dummies will
// be GC'd if not used as the target of any "call" instructions.
- StringRef debugName = saver().save("undefined_weak:" + toString(*sym));
+ StringRef debugName = saver().save("undefined_weak:" + sym->getName());
replaceWithUnreachable(sym, *sym->getSignature(), debugName);
// Hide our dummy to prevent export.
sym->setHidden(true);
@@ -854,7 +854,7 @@
// the call instruction that passes Wasm validation.
void SymbolTable::handleWeakUndefines() {
for (Symbol *sym : getSymbols()) {
- if (sym->isUndefWeak()) {
+ if (sym->isUndefWeak() && sym->isUsedInRegularObj) {
if (sym->getSignature()) {
replaceWithUndefined(sym);
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126554.432573.patch
Type: text/x-patch
Size: 989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220527/b417ee65/attachment.bin>
More information about the llvm-commits
mailing list