summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/obj2yaml/wasm2yaml.cpp8
-rw-r--r--llvm/tools/yaml2obj/yaml2wasm.cpp11
2 files changed, 17 insertions, 2 deletions
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index 27398e5b00b..1bf8149493c 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -80,11 +80,15 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
for (const object::SymbolRef& Sym: Obj.symbols()) {
const object::WasmSymbol Symbol = Obj.getWasmSymbol(Sym);
if (Symbol.Flags != 0) {
- WasmYAML::SymbolInfo Info = { Symbol.Name, Symbol.Flags };
- LinkingSec->SymbolInfos.push_back(Info);
+ WasmYAML::SymbolInfo Info{Symbol.Name, Symbol.Flags};
+ LinkingSec->SymbolInfos.emplace_back(Info);
}
}
LinkingSec->DataSize = Obj.linkingData().DataSize;
+ for (const wasm::WasmInitFunc &Func : Obj.linkingData().InitFunctions) {
+ WasmYAML::InitFunction F{Func.Priority, Func.FunctionIndex};
+ LinkingSec->InitFunctions.emplace_back(F);
+ }
CustomSec = std::move(LinkingSec);
} else {
CustomSec = make_unique<WasmYAML::CustomSection>(WasmSec.Name);
diff --git a/llvm/tools/yaml2obj/yaml2wasm.cpp b/llvm/tools/yaml2obj/yaml2wasm.cpp
index 3eae8727b60..792f7c108bc 100644
--- a/llvm/tools/yaml2obj/yaml2wasm.cpp
+++ b/llvm/tools/yaml2obj/yaml2wasm.cpp
@@ -162,6 +162,17 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S
}
SubSection.Done();
}
+
+ // INIT_FUNCS subsection
+ if (Section.InitFunctions.size()) {
+ encodeULEB128(wasm::WASM_INIT_FUNCS, OS);
+ encodeULEB128(Section.InitFunctions.size(), SubSection.GetStream());
+ for (const WasmYAML::InitFunction &Func : Section.InitFunctions) {
+ encodeULEB128(Func.Priority, SubSection.GetStream());
+ encodeULEB128(Func.FunctionIndex, SubSection.GetStream());
+ }
+ SubSection.Done();
+ }
return 0;
}
OpenPOWER on IntegriCloud