[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;
}

View File

@ -62,7 +62,7 @@ COFF32-NEXT: U _puts
WASM: U SomeOtherFunction
WASM-NEXT: 00000002 T main
WASM-NEXT: U puts
WASM-NEXT: 00000001 D var
WASM-NEXT: 00000010 D var
COFF64: 00000000 d .data
COFF64-NEXT: 00000000 t .text

View File

@ -40,5 +40,5 @@ Sections:
Kind: GLOBAL
Index: 0x00000002
# CHECK: 00000002 D bar
# CHECK: 00000400 D bar
# CHECK: 00000004 T foo

View File

@ -64,7 +64,7 @@ Sections:
- Name: weak_import_data
Flags: 1
# CHECK: 00000002 W weak_global_data
# CHECK: 00000400 W weak_global_data
# CHECK: 00000004 W weak_global_func
# CHECK: w weak_import_data
# CHECK: w weak_import_func

View File

@ -4,7 +4,7 @@ CHECK: SYMBOL TABLE:
CHECK-NEXT: 00000000 l F IMPORT puts
CHECK-NEXT: 00000000 l F IMPORT SomeOtherFunction
CHECK-NEXT: 00000002 g F EXPORT main
CHECK-NEXT: 00000001 g EXPORT var
CHECK-NEXT: 00000010 g EXPORT var
CHECK-NEXT: 00000000 l F name puts
CHECK-NEXT: 00000001 l F name SomeOtherFunction
CHECK-NEXT: 00000002 l F name main