Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -121,7 +121,6 @@ template void OutputSection::finalize() { if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) { std::sort(Sections.begin(), Sections.end(), compareByFilePosition); - Size = 0; assignOffsets(); // We must preserve the link order dependency of sections with the @@ -162,7 +161,7 @@ // This function is called after we sort input sections // and scan relocations to setup sections' offsets. template void OutputSection::assignOffsets() { - uint64_t Off = this->Size; + uint64_t Off = 0; for (InputSection *S : Sections) { Off = alignTo(Off, S->Alignment); S->OutSecOff = Off; Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -886,7 +886,6 @@ std::merge(OS->Sections.begin(), OS->Sections.end(), Thunks.begin(), Thunks.end(), std::back_inserter(Tmp), MergeCmp); OS->Sections = std::move(Tmp); - OS->Size = 0; OS->assignOffsets(); } Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -1025,7 +1025,6 @@ for (SyntheticSection *SS : Sections) if (SS && SS->OutSec && !SS->empty()) { SS->finalizeContents(); - SS->OutSec->Size = 0; SS->OutSec->template assignOffsets(); } }