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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312294
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
}
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
Kind: GLOBAL
Index: 0x00000002
-# CHECK: 00000002 D bar
+# CHECK: 00000400 D bar
# CHECK: 00000004 T foo
- 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
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