[lld] r322994 - [WebAssembly] Include SYMBOL_INFO for imports as well as exports
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 13:49:41 PST 2018
Author: sbc
Date: Fri Jan 19 13:49:41 2018
New Revision: 322994
URL: http://llvm.org/viewvc/llvm-project?rev=322994&view=rev
Log:
[WebAssembly] Include SYMBOL_INFO for imports as well as exports
Only effects --emit-relocs/--relocatable
Patch by Nicholas Wilson!
Differential Revision: https://reviews.llvm.org/D42306
Modified:
lld/trunk/test/wasm/init-fini.ll
lld/trunk/test/wasm/relocatable.ll
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/init-fini.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/init-fini.ll?rev=322994&r1=322993&r2=322994&view=diff
==============================================================================
--- lld/trunk/test/wasm/init-fini.ll (original)
+++ lld/trunk/test/wasm/init-fini.ll Fri Jan 19 13:49:41 2018
@@ -108,6 +108,8 @@ entry:
; 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
Modified: lld/trunk/test/wasm/relocatable.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/relocatable.ll?rev=322994&r1=322993&r2=322994&view=diff
==============================================================================
--- lld/trunk/test/wasm/relocatable.ll (original)
+++ lld/trunk/test/wasm/relocatable.ll Fri Jan 19 13:49:41 2018
@@ -229,6 +229,8 @@ entry:
; 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
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=322994&r1=322993&r2=322994&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Jan 19 13:49:41 2018
@@ -386,14 +386,21 @@ void Writer::createLinkingSection() {
return;
std::vector<std::pair<StringRef, uint32_t>> 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");
More information about the llvm-commits
mailing list