Index: test/wasm/init-fini.ll =================================================================== --- test/wasm/init-fini.ll +++ test/wasm/init-fini.ll @@ -108,6 +108,8 @@ ; RELOC: Name: linking ; RELOC-NEXT: DataSize: 0 ; RELOC-NEXT: SymbolInfo: +; RELOC-NEXT: - Name: __dso_handle +; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ] ; RELOC-NEXT: - Name: func1 ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; RELOC-NEXT: - Name: func2 Index: test/wasm/relocatable.ll =================================================================== --- test/wasm/relocatable.ll +++ test/wasm/relocatable.ll @@ -229,6 +229,8 @@ ; CHECK-NEXT: Name: linking ; CHECK-NEXT: DataSize: 31 ; CHECK-NEXT: SymbolInfo: +; CHECK-NEXT: - Name: bar_import +; CHECK-NEXT: Flags: [ BINDING_WEAK ] ; CHECK-NEXT: - Name: hello ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: - Name: my_func Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -386,14 +386,21 @@ return; std::vector> SymbolInfo; - for (const WasmExportEntry &E : ExportedSymbols) { + auto addSymInfo = [&](const Symbol *Sym, StringRef ExternalName) { uint32_t Flags = - (E.Sym->isLocal() ? WASM_SYMBOL_BINDING_LOCAL : - E.Sym->isWeak() ? WASM_SYMBOL_BINDING_WEAK : 0) | - (E.Sym->isHidden() ? WASM_SYMBOL_VISIBILITY_HIDDEN : 0); + (Sym->isLocal() ? WASM_SYMBOL_BINDING_LOCAL : + Sym->isWeak() ? WASM_SYMBOL_BINDING_WEAK : 0) | + (Sym->isHidden() ? WASM_SYMBOL_VISIBILITY_HIDDEN : 0); if (Flags) - SymbolInfo.emplace_back(E.FieldName, Flags); - } + SymbolInfo.emplace_back(ExternalName, Flags); + }; + // (Imports can't have internal linkage, their names don't need to be budged.) + for (const Symbol *Sym : ImportedFunctions) + addSymInfo(Sym, Sym->getName()); + for (const Symbol *Sym : ImportedGlobals) + addSymInfo(Sym, Sym->getName()); + for (const WasmExportEntry &E : ExportedSymbols) + addSymInfo(E.Sym, E.FieldName); if (!SymbolInfo.empty()) { SubSection SubSection(WASM_SYMBOL_INFO); writeUleb128(SubSection.getStream(), SymbolInfo.size(), "num sym info");