Index: test/wasm/init-fini.ll =================================================================== --- test/wasm/init-fini.ll +++ test/wasm/init-fini.ll @@ -108,41 +108,59 @@ ; RELOC: Name: linking ; RELOC-NEXT: DataSize: 0 ; RELOC-NEXT: SymbolInfo: -; RELOC-NEXT: - Name: func1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 0 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: func2 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 1 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: func3 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 2 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: func4 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 3 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: _start +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 5 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: .Lcall_dtors.101 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 6 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lregister_call_dtors.101 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 7 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lbitcast +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 8 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lcall_dtors.1001 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 9 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lregister_call_dtors.1001 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 10 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: myctor +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 11 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: mydtor +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 12 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: - Name: .Lcall_dtors.101.1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 13 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lregister_call_dtors.101.1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 14 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lcall_dtors.202 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 15 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lregister_call_dtors.202 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 16 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lcall_dtors.2002 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 17 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lregister_call_dtors.2002 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 18 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] ; RELOC-NEXT: InitFunctions: ; RELOC-NEXT: - Priority: 101 Index: test/wasm/locals-duplicate.test =================================================================== --- test/wasm/locals-duplicate.test +++ test/wasm/locals-duplicate.test @@ -463,21 +463,29 @@ ; RELOC-NEXT: Name: linking ; RELOC-NEXT: DataSize: 24 ; RELOC-NEXT: SymbolInfo: -; RELOC-NEXT: - Name: colliding_func1.1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 0 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_func3 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 2 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_func2.1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 10 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_func3.1 +; RELOC-NEXT: - Kind: FUNCTION +; RELOC-NEXT: Index: 11 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_global1.1 +; RELOC-NEXT: - Kind: GLOBAL +; RELOC-NEXT: Index: 0 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_global3 +; RELOC-NEXT: - Kind: GLOBAL +; RELOC-NEXT: Index: 2 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_global2.1 +; RELOC-NEXT: - Kind: GLOBAL +; RELOC-NEXT: Index: 4 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: colliding_global3.1 +; RELOC-NEXT: - Kind: GLOBAL +; RELOC-NEXT: Index: 5 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] ; RELOC-NEXT: SegmentInfo: ; RELOC-NEXT: - Index: 0 Index: test/wasm/relocatable.ll =================================================================== --- test/wasm/relocatable.ll +++ test/wasm/relocatable.ll @@ -201,19 +201,26 @@ ; CHECK-NEXT: Name: linking ; CHECK-NEXT: DataSize: 23 ; CHECK-NEXT: SymbolInfo: -; CHECK-NEXT: - Name: hello +; CHECK-NEXT: - Kind: FUNCTION +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: - Name: my_func +; CHECK-NEXT: - Kind: FUNCTION +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: - Name: func_comdat +; CHECK-NEXT: - Kind: FUNCTION +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: Flags: [ BINDING_WEAK ] -; CHECK-NEXT: - Name: data_comdat +; CHECK-NEXT: - Kind: GLOBAL +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: Flags: [ BINDING_WEAK ] -; CHECK-NEXT: - Name: func_addr1 +; CHECK-NEXT: - Kind: GLOBAL +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: - Name: func_addr2 +; CHECK-NEXT: - Kind: GLOBAL +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: - Name: data_addr1 +; CHECK-NEXT: - Kind: GLOBAL +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: SegmentInfo: ; CHECK-NEXT: - Index: 0 Index: test/wasm/stack-pointer.ll =================================================================== --- test/wasm/stack-pointer.ll +++ test/wasm/stack-pointer.ll @@ -55,7 +55,8 @@ ; CHECK-NEXT: Name: linking ; CHECK-NEXT: DataSize: 0 ; CHECK-NEXT: SymbolInfo: -; CHECK-NEXT: - Name: _start +; CHECK-NEXT: - Kind: FUNCTION +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -393,21 +393,25 @@ if (!Config->Relocatable) return; - std::vector> SymbolInfo; + std::vector> SymbolInfo; for (const WasmExportEntry &E : ExportedSymbols) { uint32_t Flags = (E.Symbol->isLocal() ? WASM_SYMBOL_BINDING_LOCAL : E.Symbol->isWeak() ? WASM_SYMBOL_BINDING_WEAK : 0) | (E.Symbol->isHidden() ? WASM_SYMBOL_VISIBILITY_HIDDEN : 0); - if (Flags) - SymbolInfo.emplace_back(E.FieldName, Flags); + if (Flags) { + uint32_t Kind = E.Symbol->isFunction() ? WASM_EXTERNAL_FUNCTION + : WASM_EXTERNAL_GLOBAL; + SymbolInfo.emplace_back(Kind, E.Symbol->getOutputSymbolIndex(), Flags); + } } if (!SymbolInfo.empty()) { SubSection SubSection(WASM_SYMBOL_INFO); writeUleb128(SubSection.getStream(), SymbolInfo.size(), "num sym info"); - for (auto Pair: SymbolInfo) { - writeStr(SubSection.getStream(), Pair.first, "sym name"); - writeUleb128(SubSection.getStream(), Pair.second, "sym flags"); + for (auto Tuple: SymbolInfo) { + writeUleb128(SubSection.getStream(), std::get<0>(Tuple), "sym kind"); + writeUleb128(SubSection.getStream(), std::get<1>(Tuple), "sym index"); + writeUleb128(SubSection.getStream(), std::get<2>(Tuple), "sym flags"); } SubSection.finalizeContents(); SubSection.writeToStream(OS);