[WebAssembly] Fix getSymbolValue() for data symbols

This is mostly a fix for the output of `llvm-nm`

See Bug 34392: https://bugs.llvm.org//show_bug.cgi?id=34392

Differential Revision: https://reviews.llvm.org/D37359

llvm-svn: 312294
This commit is contained in:
Sam Clegg
2017-08-31 23:22:44 +00:00
parent 5372fb8cc1
commit b09cfa5104
5 changed files with 10 additions and 5 deletions

View File

@@ -786,8 +786,13 @@ uint64_t WasmObjectFile::getSymbolValueImpl(DataRefImpl Symb) const {
case WasmSymbol::SymbolType::GLOBAL_IMPORT:
return 0;
case WasmSymbol::SymbolType::FUNCTION_EXPORT:
case WasmSymbol::SymbolType::GLOBAL_EXPORT:
return Exports[Sym.ElementIndex].Index;
case WasmSymbol::SymbolType::GLOBAL_EXPORT: {
uint32_t GlobalIndex = Exports[Sym.ElementIndex].Index;
assert(GlobalIndex < Globals.size());
const wasm::WasmGlobal& Global = Globals[GlobalIndex];
return Global.InitExpr.Value.Int32;
}
case WasmSymbol::SymbolType::DEBUG_FUNCTION_NAME:
return Sym.ElementIndex;
}