[lld] [lld][WebAssembly] Report undefined symbols by default -shared/-pie builds (PR #75242)
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 21 10:55:26 PST 2023
================
@@ -305,13 +306,88 @@ static bool shouldReplace(const Symbol *existing, InputFile *newFile,
return true;
}
+ // Similarly with shared symbols
+ if (existing->isShared()) {
+ LLVM_DEBUG(dbgs() << "replacing existing shared symbol\n");
+ return true;
+ }
+
// Neither symbol is week. They conflict.
error("duplicate symbol: " + toString(*existing) + "\n>>> defined in " +
toString(existing->getFile()) + "\n>>> defined in " +
toString(newFile));
return true;
}
+Symbol *SymbolTable::addSharedFunction(StringRef name, uint32_t flags,
+ InputFile *file,
+ const WasmSignature *sig) {
+ LLVM_DEBUG(dbgs() << "addSharedFunction: " << name << " [" << toString(*sig)
+ << "]\n");
+ Symbol *s;
+ bool wasInserted;
+ std::tie(s, wasInserted) = insert(name, file);
+
+ auto replaceSym = [&](Symbol *sym) {
+ replaceSymbol<SharedFunctionSymbol>(sym, name, flags, file, sig);
+ };
+
+ if (wasInserted) {
+ replaceSym(s);
+ return s;
+ }
+
+ auto existingFunction = dyn_cast<FunctionSymbol>(s);
+ if (!existingFunction) {
+ reportTypeError(s, file, WASM_SYMBOL_TYPE_FUNCTION);
+ return s;
+ }
+
+ // Shared symbols should never deplace locally-defined ones
----------------
dschuff wrote:
```suggestion
// Shared symbols should never replace locally-defined ones
```
https://github.com/llvm/llvm-project/pull/75242
More information about the llvm-commits
mailing list