Index: lld/wasm/OutputSections.cpp =================================================================== --- lld/wasm/OutputSections.cpp +++ lld/wasm/OutputSections.cpp @@ -144,12 +144,13 @@ writeUleb128(OS, WASM_OPCODE_END, "opcode:end"); writeUleb128(OS, Segment->Size, "segment size"); OS.flush(); - Segment->setSectionOffset(BodySize); + + Segment->SectionOffset = BodySize; BodySize += Segment->Header.size() + Segment->Size; log("Data segment: size=" + Twine(Segment->Size)); + for (InputSegment *InputSeg : Segment->InputSegments) - InputSeg->OutputOffset = Segment->getSectionOffset() + - Segment->Header.size() + + InputSeg->OutputOffset = Segment->SectionOffset + Segment->Header.size() + InputSeg->OutputSegmentOffset; } @@ -170,7 +171,7 @@ parallelForEach(Segments, [&](const OutputSegment *Segment) { // Write data segment header - uint8_t *SegStart = Buf + Segment->getSectionOffset(); + uint8_t *SegStart = Buf + Segment->SectionOffset; memcpy(SegStart, Segment->Header.data(), Segment->Header.size()); // Write segment data payload Index: lld/wasm/OutputSegment.h =================================================================== --- lld/wasm/OutputSegment.h +++ lld/wasm/OutputSegment.h @@ -32,12 +32,9 @@ Size += InSeg->getSize(); } - uint32_t getSectionOffset() const { return SectionOffset; } - - void setSectionOffset(uint32_t Offset) { SectionOffset = Offset; } - StringRef Name; const uint32_t Index; + uint32_t SectionOffset = 0; uint32_t Alignment = 0; uint32_t StartVA = 0; std::vector InputSegments; @@ -47,9 +44,6 @@ // Segment header std::string Header; - -private: - uint32_t SectionOffset = 0; }; } // namespace wasm