forked from OSchip/llvm-project
[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 llvm-svn: 296609
This commit is contained in:
parent
62703eb8a7
commit
efc31dd9bb
|
@ -87,7 +87,6 @@ static bool compareByFilePosition(InputSection *A, InputSection *B) {
|
||||||
template <class ELFT> void OutputSection::finalize() {
|
template <class ELFT> void OutputSection::finalize() {
|
||||||
if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
|
if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
|
||||||
std::sort(Sections.begin(), Sections.end(), compareByFilePosition<ELFT>);
|
std::sort(Sections.begin(), Sections.end(), compareByFilePosition<ELFT>);
|
||||||
Size = 0;
|
|
||||||
assignOffsets<ELFT>();
|
assignOffsets<ELFT>();
|
||||||
|
|
||||||
// We must preserve the link order dependency of sections with the
|
// We must preserve the link order dependency of sections with the
|
||||||
|
@ -133,7 +132,7 @@ void OutputSection::addSection(InputSectionBase *C) {
|
||||||
// This function is called after we sort input sections
|
// This function is called after we sort input sections
|
||||||
// and scan relocations to setup sections' offsets.
|
// and scan relocations to setup sections' offsets.
|
||||||
template <class ELFT> void OutputSection::assignOffsets() {
|
template <class ELFT> void OutputSection::assignOffsets() {
|
||||||
uint64_t Off = this->Size;
|
uint64_t Off = 0;
|
||||||
for (InputSection *S : Sections) {
|
for (InputSection *S : Sections) {
|
||||||
Off = alignTo(Off, S->Alignment);
|
Off = alignTo(Off, S->Alignment);
|
||||||
S->OutSecOff = Off;
|
S->OutSecOff = Off;
|
||||||
|
|
|
@ -886,7 +886,6 @@ static void mergeThunks(OutputSection *OS,
|
||||||
std::merge(OS->Sections.begin(), OS->Sections.end(), Thunks.begin(),
|
std::merge(OS->Sections.begin(), OS->Sections.end(), Thunks.begin(),
|
||||||
Thunks.end(), std::back_inserter(Tmp), MergeCmp);
|
Thunks.end(), std::back_inserter(Tmp), MergeCmp);
|
||||||
OS->Sections = std::move(Tmp);
|
OS->Sections = std::move(Tmp);
|
||||||
OS->Size = 0;
|
|
||||||
OS->assignOffsets<ELFT>();
|
OS->assignOffsets<ELFT>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1025,7 +1025,6 @@ static void finalizeSynthetic(const std::vector<SyntheticSection *> &Sections) {
|
||||||
for (SyntheticSection *SS : Sections)
|
for (SyntheticSection *SS : Sections)
|
||||||
if (SS && SS->OutSec && !SS->empty()) {
|
if (SS && SS->OutSec && !SS->empty()) {
|
||||||
SS->finalizeContents();
|
SS->finalizeContents();
|
||||||
SS->OutSec->Size = 0;
|
|
||||||
SS->OutSec->template assignOffsets<ELFT>();
|
SS->OutSec->template assignOffsets<ELFT>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue