Index: lld/trunk/wasm/OutputSections.cpp =================================================================== --- lld/trunk/wasm/OutputSections.cpp +++ lld/trunk/wasm/OutputSections.cpp @@ -107,15 +107,12 @@ memcpy(Buf, Header.data(), Header.size()); Buf += Header.size(); - uint8_t *ContentsStart = Buf; - // Write code section headers memcpy(Buf, CodeSectionHeader.data(), CodeSectionHeader.size()); - Buf += CodeSectionHeader.size(); // Write code section bodies - parallelForEach(Functions, [ContentsStart](const InputChunk *Chunk) { - Chunk->writeTo(ContentsStart); + parallelForEach(Functions, [&](const InputChunk *Chunk) { + Chunk->writeTo(Buf); }); } @@ -168,19 +165,17 @@ memcpy(Buf, Header.data(), Header.size()); Buf += Header.size(); - uint8_t *ContentsStart = Buf; - // Write data section headers memcpy(Buf, DataSectionHeader.data(), DataSectionHeader.size()); - parallelForEach(Segments, [ContentsStart](const OutputSegment *Segment) { + parallelForEach(Segments, [&](const OutputSegment *Segment) { // Write data segment header - uint8_t *SegStart = ContentsStart + Segment->getSectionOffset(); + uint8_t *SegStart = Buf + Segment->getSectionOffset(); memcpy(SegStart, Segment->Header.data(), Segment->Header.size()); // Write segment data payload for (const InputChunk *Chunk : Segment->InputSegments) - Chunk->writeTo(ContentsStart); + Chunk->writeTo(Buf); }); }