[WebAssembly] Error on relocations against undefined data symbols.
We can't (currently) meaningfully resolve certain types of relocations
against undefined data symbols. Previously when `--allow-undefined` was
used we were treating such relocation much like weak data symbols and
simply inserting zeros. This change turns such use cases in to an
error.
This means that `--allow-undefined` is no longer effective for data
symbols.
Fixes https://bugs.llvm.org/show_bug.cgi?id=40364
Differential Revision: https://reviews.llvm.org/D60882
llvm-svn: 358899
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 6a835ce..d4014d7 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1170,6 +1170,20 @@
Sym->setGOTIndex(NumImportedGlobals++);
GOTSymbols.push_back(Sym);
}
+ break;
+ }
+ case R_WASM_MEMORY_ADDR_SLEB:
+ case R_WASM_MEMORY_ADDR_LEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB: {
+ if (!Config->Relocatable) {
+ auto* Sym = File->getSymbols()[Reloc.Index];
+ if (Sym->isUndefined() && !Sym->isWeak()) {
+ error(toString(File) + ": cannot resolve relocation of type " +
+ relocTypeToString(Reloc.Type) +
+ " against undefined (non-weak) data symbol: " + toString(*Sym));
+ }
+ }
+ break;
}
}