[WebAssembly] Add support for init functions linking metadata
Summary:
This change lays the groundwork lowering of @llvm.global_ctors
and @llvm.global_dtors for the wasm object format. Some parts
of this patch are subset of: https://reviews.llvm.org/D40759
See https://github.com/WebAssembly/tool-conventions/issues/25
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish
Differential Revision: https://reviews.llvm.org/D41208
llvm-svn: 320742
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index 27398e5..1bf8149 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -80,11 +80,15 @@
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);