[PATCH] D43715: [WebAssembly] Simplify createLikingSection.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 27 16:31:48 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326279: [WebAssembly] Simplify createLikingSection. (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43715?vs=135773&id=136184#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43715
Files:
lld/trunk/wasm/Writer.cpp
Index: lld/trunk/wasm/Writer.cpp
===================================================================
--- lld/trunk/wasm/Writer.cpp
+++ lld/trunk/wasm/Writer.cpp
@@ -371,6 +371,19 @@
}
}
+static uint32_t getWasmFlags(const Symbol *Sym) {
+ uint32_t Flags = 0;
+ if (Sym->isLocal())
+ Flags |= WASM_SYMBOL_BINDING_LOCAL;
+ if (Sym->isWeak())
+ Flags |= WASM_SYMBOL_BINDING_WEAK;
+ if (Sym->isHidden())
+ Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN;
+ if (Sym->isUndefined())
+ Flags |= WASM_SYMBOL_UNDEFINED;
+ return Flags;
+}
+
// Create the custom "linking" section containing linker metadata.
// This is only created when relocatable output is requested.
void Writer::createLinkingSection() {
@@ -387,15 +400,11 @@
for (const Symbol *Sym : SymtabEntries) {
assert(Sym->isDefined() || Sym->isUndefined());
WasmSymbolType Kind = Sym->getWasmType();
- uint32_t Flags = Sym->isLocal() ? WASM_SYMBOL_BINDING_LOCAL : 0;
- if (Sym->isWeak())
- Flags |= WASM_SYMBOL_BINDING_WEAK;
- if (Sym->isHidden())
- Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN;
- if (Sym->isUndefined())
- Flags |= WASM_SYMBOL_UNDEFINED;
+ uint32_t Flags = getWasmFlags(Sym);
+
writeUleb128(SubSection.getStream(), Kind, "sym kind");
writeUleb128(SubSection.getStream(), Flags, "sym flags");
+
switch (Kind) {
case llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION:
case llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL:
@@ -415,6 +424,7 @@
break;
}
}
+
SubSection.finalizeContents();
SubSection.writeToStream(OS);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43715.136184.patch
Type: text/x-patch
Size: 1609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/d3bbb375/attachment.bin>
More information about the llvm-commits
mailing list