Index: lib/Object/WasmObjectFile.cpp =================================================================== --- lib/Object/WasmObjectFile.cpp +++ lib/Object/WasmObjectFile.cpp @@ -554,7 +554,6 @@ return make_error("Invalid section code", object_error::parse_failed); uint32_t RelocCount = readVaruint32(Ptr); - uint32_t LastOffset = 0; uint32_t EndOffset = Section->Content.size(); while (RelocCount--) { wasm::WasmRelocation Reloc = {}; @@ -593,6 +592,7 @@ object_error::parse_failed); } + DEBUG(dbgs() << "Adding relocation: " << Reloc.Offset << "\n"); // Relocations must fit inside the section, and must appear in order. They // also shouldn't overlap a function/element boundary, but we don't bother // to check that. @@ -600,10 +600,9 @@ if (Reloc.Type == wasm::R_WEBASSEMBLY_TABLE_INDEX_I32 || Reloc.Type == wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32) Size = 4; - if (Reloc.Offset < LastOffset || Reloc.Offset + Size > EndOffset) + if (Reloc.Offset + Size > EndOffset) return make_error("Bad relocation offset", object_error::parse_failed); - LastOffset = Reloc.Offset; Section->Relocations.push_back(Reloc); }