[lld] r315140 - Remove OutputSection::updateAlignment.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 17:58:34 PDT 2017
Author: ruiu
Date: Fri Oct 6 17:58:34 2017
New Revision: 315140
URL: http://llvm.org/viewvc/llvm-project?rev=315140&view=rev
Log:
Remove OutputSection::updateAlignment.
I feel it is easier to understand without this function.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315140&r1=315139&r2=315140&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Oct 6 17:58:34 2017
@@ -688,7 +688,8 @@ void LinkerScript::adjustSectionsAfterSo
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());
}
}
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=315140&r1=315139&r2=315140&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Oct 6 17:58:34 2017
@@ -119,7 +119,7 @@ void OutputSection::addSection(InputSect
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
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=315140&r1=315139&r2=315140&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Oct 6 17:58:34 2017
@@ -56,11 +56,6 @@ public:
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
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=315140&r1=315139&r2=315140&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Fri Oct 6 17:58:34 2017
@@ -363,7 +363,7 @@ void BuildIdSection::computeHash(
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 @@ template <class ELFT>
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);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=315140&r1=315139&r2=315140&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Oct 6 17:58:34 2017
@@ -265,7 +265,7 @@ template <class ELFT> void Writer<ELFT>:
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();
More information about the llvm-commits
mailing list