From 4194fb706279c1de6c059d2a57ade5f9fb623fde Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 1 Sep 2017 17:24:19 +0000 Subject: [WebAssembly] Fix getSymbolValue for exported globals The code wasn't previously taking into account that the global index space is not same as the into in the Globals array since the latter does not include imported globals. This fixes the WebAssembly waterfall failures. Differential Revision: https://reviews.llvm.org/D37384 llvm-svn: 312340 --- llvm/lib/Object/WasmObjectFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index ad8c2b7..e1bab72 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -788,7 +788,7 @@ uint64_t WasmObjectFile::getSymbolValueImpl(DataRefImpl Symb) const { case WasmSymbol::SymbolType::FUNCTION_EXPORT: return Exports[Sym.ElementIndex].Index; case WasmSymbol::SymbolType::GLOBAL_EXPORT: { - uint32_t GlobalIndex = Exports[Sym.ElementIndex].Index; + uint32_t GlobalIndex = Exports[Sym.ElementIndex].Index - NumImportedGlobals; assert(GlobalIndex < Globals.size()); const wasm::WasmGlobal& Global = Globals[GlobalIndex]; return Global.InitExpr.Value.Int32; -- cgit v1.1