[WebAssembly] Handle weak undefined functions with a synthetic stub
This error case is described in Linking.md. The operand for call requires
generation of a synthetic stub.
Differential Revision: https://reviews.llvm.org/D44028
llvm-svn: 327151
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 2c65c7b..12ee9ec 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -65,14 +65,8 @@
uint32_t ObjFile::calcNewValue(const WasmRelocation &Reloc) const {
switch (Reloc.Type) {
case R_WEBASSEMBLY_TABLE_INDEX_I32:
- case R_WEBASSEMBLY_TABLE_INDEX_SLEB: {
- // The null case is possible, if you take the address of a weak function
- // that's simply not supplied.
- FunctionSymbol *Sym = getFunctionSymbol(Reloc.Index);
- if (Sym->hasTableIndex())
- return Sym->getTableIndex();
- return 0;
- }
+ case R_WEBASSEMBLY_TABLE_INDEX_SLEB:
+ return getFunctionSymbol(Reloc.Index)->getTableIndex();
case R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
case R_WEBASSEMBLY_MEMORY_ADDR_I32:
case R_WEBASSEMBLY_MEMORY_ADDR_LEB: