diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 6922d350a85a..b4e5fade73d1 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -826,8 +826,7 @@ void OutputSection::addSection(InputSectionBase *C) { Sections.push_back(S); S->OutSec = this; uint32_t Align = S->getAlign(); - if (Align > this->Header.sh_addralign) - this->Header.sh_addralign = Align; + this->updateAlign(Align); uintX_t Off = this->Header.sh_size; Off = alignTo(Off, Align); @@ -1098,10 +1097,7 @@ void EHOutputSection::addSectionAux( const endianness E = ELFT::TargetEndianness; S->OutSec = this; - uint32_t Align = S->getAlign(); - if (Align > this->Header.sh_addralign) - this->Header.sh_addralign = Align; - + this->updateAlign(S->getAlign()); Sections.push_back(S); ArrayRef SecData = S->getSectionData(); @@ -1285,9 +1281,7 @@ template void MergeOutputSection::addSection(InputSectionBase *C) { auto *S = cast>(C); S->OutSec = this; - uint32_t Align = S->getAlign(); - if (Align > this->Header.sh_addralign) - this->Header.sh_addralign = Align; + this->updateAlign(S->getAlign()); ArrayRef D = S->getSectionData(); StringRef Data((const char *)D.data(), D.size());