summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp4
-rw-r--r--llvm/lib/ObjectYAML/WasmYAML.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 48f98df6f34..c33f4f68694 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -632,6 +632,7 @@ Error WasmObjectFile::parseGlobalSection(const uint8_t *Ptr, const uint8_t *End)
Globals.reserve(Count);
while (Count--) {
wasm::WasmGlobal Global;
+ Global.Index = NumImportedGlobals + Globals.size();
Global.Type = readVarint7(Ptr);
Global.Mutable = readVaruint1(Ptr);
if (Error Err = readInitExpr(Global.InitExpr, Ptr))
@@ -706,6 +707,7 @@ Error WasmObjectFile::parseCodeSection(const uint8_t *Ptr, const uint8_t *End) {
uint32_t Size = readVaruint32(Ptr);
const uint8_t *FunctionEnd = Ptr + Size;
+ Function.Index = NumImportedFunctions + Functions.size();
Function.CodeSectionOffset = FunctionStart - CodeSectionStart;
Function.Size = FunctionEnd - FunctionStart;
@@ -858,7 +860,7 @@ uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol& Sym) const {
case WasmSymbol::SymbolType::GLOBAL_EXPORT: {
uint32_t GlobalIndex = Sym.ElementIndex - NumImportedGlobals;
assert(GlobalIndex < Globals.size());
- const wasm::WasmGlobal& Global = Globals[GlobalIndex];
+ const wasm::WasmGlobal &Global = Globals[GlobalIndex];
// WasmSymbols correspond only to I32_CONST globals
assert(Global.InitExpr.Opcode == wasm::WASM_OPCODE_I32_CONST);
return Global.InitExpr.Value.Int32;
diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp
index b2411395dc0..70721e006da 100644
--- a/llvm/lib/ObjectYAML/WasmYAML.cpp
+++ b/llvm/lib/ObjectYAML/WasmYAML.cpp
@@ -236,7 +236,7 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
void MappingTraits<WasmYAML::Signature>::mapping(
IO &IO, WasmYAML::Signature &Signature) {
- IO.mapOptional("Index", Signature.Index);
+ IO.mapRequired("Index", Signature.Index);
IO.mapRequired("ReturnType", Signature.ReturnType);
IO.mapRequired("ParamTypes", Signature.ParamTypes);
}
@@ -248,6 +248,7 @@ void MappingTraits<WasmYAML::Table>::mapping(IO &IO, WasmYAML::Table &Table) {
void MappingTraits<WasmYAML::Function>::mapping(IO &IO,
WasmYAML::Function &Function) {
+ IO.mapRequired("Index", Function.Index);
IO.mapRequired("Locals", Function.Locals);
IO.mapRequired("Body", Function.Body);
}
@@ -323,6 +324,7 @@ void MappingTraits<WasmYAML::Export>::mapping(IO &IO,
void MappingTraits<WasmYAML::Global>::mapping(IO &IO,
WasmYAML::Global &Global) {
+ IO.mapRequired("Index", Global.Index);
IO.mapRequired("Type", Global.Type);
IO.mapRequired("Mutable", Global.Mutable);
IO.mapRequired("InitExpr", Global.InitExpr);
OpenPOWER on IntegriCloud