Index: wasm/InputChunks.cpp =================================================================== --- wasm/InputChunks.cpp +++ wasm/InputChunks.cpp @@ -78,19 +78,19 @@ } } -static void applyRelocations(uint8_t *Buf, ArrayRef Relocs) { - if (!Relocs.size()) +// Copy this input chunk to an mmap'ed output file. +void InputChunk::writeTo(uint8_t *Buf) const { + // Copy contents + memcpy(Buf + getOutputOffset(), data().data(), data().size()); + + // Apply relocations + if (OutRelocations.empty()) return; - DEBUG(dbgs() << "applyRelocations: count=" << Relocs.size() << "\n"); - for (const OutputRelocation &Reloc : Relocs) + DEBUG(dbgs() << "applyRelocations: count=" << OutRelocations.size() << "\n"); + for (const OutputRelocation &Reloc : OutRelocations) applyRelocation(Buf, Reloc); } -void InputChunk::writeTo(uint8_t *SectionStart) const { - memcpy(SectionStart + getOutputOffset(), data().data(), data().size()); - applyRelocations(SectionStart, OutRelocations); -} - // Populate OutRelocations based on the input relocations and offset within the // output section. Calculates the updated index and offset for each relocation // as well as the value to write out in the final binary.