Export.Kind == wasm::WASM_EXTERNAL_FUNCTION
? WasmSymbol::SymbolType::FUNCTION_EXPORT
: WasmSymbol::SymbolType::GLOBAL_EXPORT;
- auto Pair = SymbolMap.try_emplace(Export.Name, Symbols.size());
- if (Pair.second) {
- Symbols.emplace_back(Export.Name, ExportType,
- ExportSection, Export.Index);
- DEBUG(dbgs() << "Adding export: " << Symbols.back()
- << " sym index:" << Symbols.size() << "\n");
- } else {
- uint32_t SymIndex = Pair.first->second;
- Symbols[SymIndex] =
- WasmSymbol(Export.Name, ExportType, ExportSection, Export.Index);
- DEBUG(dbgs() << "Replacing existing symbol: " << Symbols[SymIndex]
- << " sym index:" << SymIndex << "\n");
- }
+ SymbolMap.try_emplace(Export.Name, Symbols.size());
+ Symbols.emplace_back(Export.Name, ExportType,
+ ExportSection, Export.Index);
+ DEBUG(dbgs() << "Adding export: " << Symbols.back()
+ << " sym index:" << Symbols.size() << "\n");
}
}
}
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: ReturnType: I32
; CHECK-NEXT: ParamTypes:
-
-; CHECK: - Type: IMPORT
-; CHECK-NEXT: Imports:
-; CHECK-NEXT: - Module: env
-; CHECK-NEXT: Field: foo_alias
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: SigIndex: 0
-; CHECK-NEXT: - Module: env
-; CHECK-NEXT: Field: bar_alias
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: GlobalType: I32
-; CHECK-NEXT: GlobalMutable: false
-
-; CHECK: - Type: FUNCTION
+; CHECK-NEXT: - Type: FUNCTION
; CHECK-NEXT: FunctionTypes: [ 0, 0 ]
-
-; CHECK: - Type: EXPORT
+; CHECK-NEXT: - Type: TABLE
+; CHECK-NEXT: Tables:
+; CHECK-NEXT: - ElemType: ANYFUNC
+; CHECK-NEXT: Limits:
+; CHECK-NEXT: Initial: 0x00000000
+; CHECK-NEXT: - Type: MEMORY
+; CHECK-NEXT: Memories:
+; CHECK-NEXT: - Initial: 0x00000001
+; CHECK-NEXT: - Type: GLOBAL
+; CHECK-NEXT: Globals:
+; CHECK-NEXT: - Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 0
+; CHECK-NEXT: - Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 8
+; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: call_alias
; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 1
+; CHECK-NEXT: Index: 0
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 2
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
+; CHECK-NEXT: Index: 0
; CHECK-NEXT: - Name: bar_alias_address
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: foo_alias
; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 2
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: bar_alias
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
+; CHECK-NEXT: Index: 0
; CHECK: - Type: DATA
; CHECK-NEXT: Relocations:
; CHECK-NEXT: Name: name
; CHECK-NEXT: FunctionNames:
; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: foo_alias
-; CHECK-NEXT: - Index: 1
; CHECK-NEXT: Name: call_alias
-; CHECK-NEXT: - Index: 2
+; CHECK-NEXT: - Index: 1
; CHECK-NEXT: Name: foo
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: ...
; CHECK-SYMS: SYMBOL TABLE:
-; CHECK-SYMS-NEXT: 00000000 g F name foo_alias
-; CHECK-SYMS-NEXT: 00000001 g F name call_alias
-; CHECK-SYMS-NEXT: 00000002 g F name foo
-; CHECK-SYMS-NEXT: 00000002 gw F EXPORT foo_alias
-; CHECK-SYMS-NEXT: 00000000 gw EXPORT bar_alias
-; CHECK-SYMS-NEXT: 00000001 g F EXPORT call_alias
-; CHECK-SYMS-NEXT: 00000002 g F EXPORT foo
+; CHECK-SYMS-NEXT: 00000000 g F name call_alias
+; CHECK-SYMS-NEXT: 00000001 g F name foo
+; CHECK-SYMS-NEXT: 00000000 g F EXPORT call_alias
+; CHECK-SYMS-NEXT: 00000001 g F EXPORT foo
; CHECK-SYMS-NEXT: 00000000 g EXPORT bar
; CHECK-SYMS-NEXT: 00000008 g EXPORT bar_alias_address
+; CHECK-SYMS-NEXT: 00000001 gw F EXPORT foo_alias
+; CHECK-SYMS-NEXT: 00000000 gw EXPORT bar_alias