Remove OutputSection::updateAlignment.
I feel it is easier to understand without this function.
llvm-svn: 315140
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 577b32f..a8e72f5 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -688,7 +688,8 @@
Sec->MemRegion = findMemoryRegion(Sec);
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (Sec->AlignExpr)
- Sec->updateAlignment(Sec->AlignExpr().getValue());
+ Sec->Alignment =
+ std::max<uint32_t>(Sec->Alignment, Sec->AlignExpr().getValue());
}
}
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 7fe772a..9013adf 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -119,7 +119,7 @@
IS->Parent = this;
Flags |= IS->Flags;
- this->updateAlignment(IS->Alignment);
+ Alignment = std::max(Alignment, IS->Alignment);
// The actual offsets will be computed by assignAddresses. For now, use
// crude approximation so that it is at least easy for other code to know the
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 1a4baa9..665fffe 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -56,11 +56,6 @@
uint32_t getPhdrFlags() const;
- void updateAlignment(uint32_t Val) {
- if (Val > Alignment)
- Alignment = Val;
- }
-
// Pointer to the PT_LOAD segment, which this section resides in. This field
// is used to correctly compute file offset of a section. When two sections
// share the same load segment, difference between their file offsets should
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f017557..11f8345 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -363,7 +363,7 @@
BssSection::BssSection(StringRef Name, uint64_t Size, uint32_t Alignment)
: SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, Alignment, Name) {
if (OutputSection *Sec = getParent())
- Sec->updateAlignment(Alignment);
+ Sec->Alignment = std::max(Sec->Alignment, Alignment);
this->Size = Size;
}
@@ -494,8 +494,10 @@
void EhFrameSection<ELFT>::addSection(InputSectionBase *C) {
auto *Sec = cast<EhInputSection>(C);
Sec->Parent = this;
- updateAlignment(Sec->Alignment);
+
+ Alignment = std::max(Alignment, Sec->Alignment);
Sections.push_back(Sec);
+
for (auto *DS : Sec->DependentSections)
DependentSections.push_back(DS);
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 5c2acc4..e9b27a1 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -265,7 +265,7 @@
Out::ElfHeader = make<OutputSection>("", 0, SHF_ALLOC);
Out::ElfHeader->Size = sizeof(Elf_Ehdr);
Out::ProgramHeaders = make<OutputSection>("", 0, SHF_ALLOC);
- Out::ProgramHeaders->updateAlignment(Config->Wordsize);
+ Out::ProgramHeaders->Alignment = Config->Wordsize;
if (needsInterpSection()) {
InX::Interp = createInterpSection();