[PATCH] D42306: [WebAssembly] Symbol changes #4d: export import flags, LLD only
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 10:26:13 PST 2018
ncw created this revision.
ncw added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.
This fixes an issue Sam identified in https://reviews.llvm.org/D42105.
https://reviews.llvm.org/D42105 was landed without the fix, and this is the followup patch to correct the omission.
Changes:
- Symbol flags should be written out for imports as well as exports. D'oh.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D42306
Files:
test/wasm/init-fini.ll
test/wasm/relocatable.ll
wasm/Writer.cpp
Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -386,14 +386,21 @@
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");
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: 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42306.130652.patch
Type: text/x-patch
Size: 2488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/9f0c218c/attachment.bin>
More information about the llvm-commits
mailing list