diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp --- a/lld/wasm/SymbolTable.cpp +++ b/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 {