From 285da41e2202f37dcec2ad4e409d9d7297166178 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 21 Feb 2019 17:05:19 +0000 Subject: [PATCH] [WebAssembly] Don't create MSSymbolWasm object for non-symbols `__linear_memory` and `__indirect_function_table` are both generated as imports in wasm object files but are actually symbols and don't appear in any symbols table or relocation entry. Indeed we don't have any symbol type to meaningfully represent either of them. Differential Revision: https://reviews.llvm.org/D58487 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354599 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/WasmObjectWriter.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/MC/WasmObjectWriter.cpp b/lib/MC/WasmObjectWriter.cpp index 10f16ba3c8f..d8dfc57c416 100644 --- a/lib/MC/WasmObjectWriter.cpp +++ b/lib/MC/WasmObjectWriter.cpp @@ -1148,7 +1148,6 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, uint64_t StartOffset = W.OS.tell(); LLVM_DEBUG(dbgs() << "WasmObjectWriter::writeObject\n"); - MCContext &Ctx = Asm.getContext(); // Collect information from the available symbols. SmallVector Functions; @@ -1164,22 +1163,18 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, // For now, always emit the memory import, since loads and stores are not // valid without it. In the future, we could perhaps be more clever and omit // it if there are no loads or stores. - auto *MemorySym = - cast(Ctx.getOrCreateSymbol("__linear_memory")); wasm::WasmImport MemImport; - MemImport.Module = MemorySym->getImportModule(); - MemImport.Field = MemorySym->getImportName(); + MemImport.Module = "env"; + MemImport.Field = "__linear_memory"; MemImport.Kind = wasm::WASM_EXTERNAL_MEMORY; Imports.push_back(MemImport); // For now, always emit the table section, since indirect calls are not // valid without it. In the future, we could perhaps be more clever and omit // it if there are no indirect calls. - auto *TableSym = - cast(Ctx.getOrCreateSymbol("__indirect_function_table")); wasm::WasmImport TableImport; - TableImport.Module = TableSym->getImportModule(); - TableImport.Field = TableSym->getImportName(); + TableImport.Module = "env"; + TableImport.Field = "__indirect_function_table"; TableImport.Kind = wasm::WASM_EXTERNAL_TABLE; TableImport.Table.ElemType = wasm::WASM_TYPE_FUNCREF; Imports.push_back(TableImport); -- 2.40.0