[lld] r296609 - [ELF] - Reset output section size when assigning offsets.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 03:10:53 PST 2017
Author: grimar
Date: Wed Mar 1 05:10:53 2017
New Revision: 296609
URL: http://llvm.org/viewvc/llvm-project?rev=296609&view=rev
Log:
[ELF] - Reset output section size when assigning offsets.
In many places we reset Size to 0 before calling assignOffsets()
manually. Sometimes we don't do that.
It looks we can just always do that inside.
Previous code had:
template <class ELFT> void OutputSection::assignOffsets() {
uint64_t Off = Size;
And tests feels fine with Off = 0.
I think Off = Size make no sence.
Differential revision: https://reviews.llvm.org/D30463
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=296609&r1=296608&r2=296609&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Mar 1 05:10:53 2017
@@ -87,7 +87,6 @@ static bool compareByFilePosition(InputS
template <class ELFT> void OutputSection::finalize() {
if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
std::sort(Sections.begin(), Sections.end(), compareByFilePosition<ELFT>);
- Size = 0;
assignOffsets<ELFT>();
// We must preserve the link order dependency of sections with the
@@ -133,7 +132,7 @@ void OutputSection::addSection(InputSect
// This function is called after we sort input sections
// and scan relocations to setup sections' offsets.
template <class ELFT> void OutputSection::assignOffsets() {
- uint64_t Off = this->Size;
+ uint64_t Off = 0;
for (InputSection *S : Sections) {
Off = alignTo(Off, S->Alignment);
S->OutSecOff = Off;
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=296609&r1=296608&r2=296609&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Mar 1 05:10:53 2017
@@ -886,7 +886,6 @@ static void mergeThunks(OutputSection *O
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<ELFT>();
}
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296609&r1=296608&r2=296609&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Mar 1 05:10:53 2017
@@ -1025,7 +1025,6 @@ static void finalizeSynthetic(const std:
for (SyntheticSection *SS : Sections)
if (SS && SS->OutSec && !SS->empty()) {
SS->finalizeContents();
- SS->OutSec->Size = 0;
SS->OutSec->template assignOffsets<ELFT>();
}
}
More information about the llvm-commits
mailing list