[ELF] - Rename PhdrEntry::First/Last to FirstSec/LastSec. NFC.

As was suggested in D34956 thread.

llvm-svn: 312712
This commit is contained in:
George Rimar 2017-09-07 11:01:10 +00:00
parent 582ede8922
commit 6823c5f0c0
4 changed files with 24 additions and 24 deletions

View File

@ -485,9 +485,9 @@ static uint64_t getAArch64UndefinedRelativeWeakVA(uint64_t Type, uint64_t A,
// of the RW segment.
static uint64_t getARMStaticBase(const SymbolBody &Body) {
OutputSection *OS = Body.getOutputSection();
if (!OS || !OS->PtLoad || !OS->PtLoad->First)
if (!OS || !OS->PtLoad || !OS->PtLoad->FirstSec)
fatal("SBREL relocation to " + Body.getName() + " without static base");
return OS->PtLoad->First->Addr;
return OS->PtLoad->FirstSec->Addr;
}
static uint64_t getRelocTargetVA(uint32_t Type, int64_t A, uint64_t P,

View File

@ -770,7 +770,7 @@ void LinkerScript::allocateHeaders(std::vector<PhdrEntry *> &Phdrs) {
Out::ElfHeader->PtLoad = nullptr;
Out::ProgramHeaders->PtLoad = nullptr;
FirstPTLoad->First = findFirstSection(FirstPTLoad);
FirstPTLoad->FirstSec = findFirstSection(FirstPTLoad);
llvm::erase_if(Phdrs,
[](const PhdrEntry *E) { return E->p_type == PT_PHDR; });

View File

@ -127,9 +127,9 @@ template <class ELFT> void Writer<ELFT>::removeEmptyPTLoad() {
llvm::erase_if(Phdrs, [&](const PhdrEntry *P) {
if (P->p_type != PT_LOAD)
return false;
if (!P->First)
if (!P->FirstSec)
return true;
uint64_t Size = P->Last->Addr + P->Last->Size - P->First->Addr;
uint64_t Size = P->LastSec->Addr + P->LastSec->Size - P->FirstSec->Addr;
return Size == 0;
});
}
@ -741,9 +741,9 @@ static bool compareSections(const BaseCommand *ACmd, const BaseCommand *BCmd) {
}
void PhdrEntry::add(OutputSection *Sec) {
Last = Sec;
if (!First)
First = Sec;
LastSec = Sec;
if (!FirstSec)
FirstSec = Sec;
p_align = std::max(p_align, Sec->Alignment);
if (p_type == PT_LOAD)
Sec->PtLoad = this;
@ -956,7 +956,7 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSymbols() {
// _end is the first location after the uninitialized data region.
if (Last) {
for (size_t I = 0; I < V.size(); ++I) {
if (V[I] != Last->Last)
if (V[I] != Last->LastSec)
continue;
if (ElfSym::End2)
V.insert(V.begin() + I + 1, Make(ElfSym::End2));
@ -969,7 +969,7 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSymbols() {
// _etext is the first location after the last read-only loadable segment.
if (LastRO) {
for (size_t I = 0; I < V.size(); ++I) {
if (V[I] != LastRO->Last)
if (V[I] != LastRO->LastSec)
continue;
if (ElfSym::Etext2)
V.insert(V.begin() + I + 1, Make(ElfSym::Etext2));
@ -983,7 +983,7 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSymbols() {
if (LastRW) {
size_t I = 0;
for (; I < V.size(); ++I)
if (V[I] == LastRW->First)
if (V[I] == LastRW->FirstSec)
break;
for (; I < V.size(); ++I) {
@ -1547,7 +1547,7 @@ template <class ELFT> std::vector<PhdrEntry *> Writer<ELFT>::createPhdrs() {
for (OutputSection *Sec : OutputSections)
if (Sec->Flags & SHF_TLS)
TlsHdr->add(Sec);
if (TlsHdr->First)
if (TlsHdr->FirstSec)
Ret.push_back(TlsHdr);
// Add an entry for .dynamic.
@ -1561,7 +1561,7 @@ template <class ELFT> std::vector<PhdrEntry *> Writer<ELFT>::createPhdrs() {
for (OutputSection *Sec : OutputSections)
if (needsPtLoad(Sec) && isRelroSection(Sec))
RelRo->add(Sec);
if (RelRo->First)
if (RelRo->FirstSec)
Ret.push_back(RelRo);
// PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr.
@ -1635,18 +1635,18 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
};
for (const PhdrEntry *P : Phdrs)
if (P->p_type == PT_LOAD && P->First)
PageAlign(P->First);
if (P->p_type == PT_LOAD && P->FirstSec)
PageAlign(P->FirstSec);
for (const PhdrEntry *P : Phdrs) {
if (P->p_type != PT_GNU_RELRO)
continue;
if (P->First)
PageAlign(P->First);
if (P->FirstSec)
PageAlign(P->FirstSec);
// Find the first section after PT_GNU_RELRO. If it is in a PT_LOAD we
// have to align it to a page.
auto End = OutputSections.end();
auto I = std::find(OutputSections.begin(), End, P->Last);
auto I = std::find(OutputSections.begin(), End, P->LastSec);
if (I == End || (I + 1) == End)
continue;
OutputSection *Cmd = (*(I + 1));
@ -1664,7 +1664,7 @@ static uint64_t getFileAlignment(uint64_t Off, OutputSection *Cmd) {
if (!Cmd->PtLoad)
return alignTo(Off, Cmd->Alignment);
OutputSection *First = Cmd->PtLoad->First;
OutputSection *First = Cmd->PtLoad->FirstSec;
// The first section in a PT_LOAD has to have congruent offset and address
// module the page size.
if (Cmd == First)
@ -1713,7 +1713,7 @@ template <class ELFT> void Writer<ELFT>::assignFileOffsets() {
// If this is a last section of the last executable segment and that
// segment is the last loadable segment, align the offset of the
// following section to avoid loading non-segments parts of the file.
if (LastRX && LastRX->Last == Sec)
if (LastRX && LastRX->LastSec == Sec)
Off = alignTo(Off, Target->PageSize);
}
@ -1725,8 +1725,8 @@ template <class ELFT> void Writer<ELFT>::assignFileOffsets() {
// file offsets and VAs to all sections.
template <class ELFT> void Writer<ELFT>::setPhdrs() {
for (PhdrEntry *P : Phdrs) {
OutputSection *First = P->First;
OutputSection *Last = P->Last;
OutputSection *First = P->FirstSec;
OutputSection *Last = P->LastSec;
if (First) {
P->p_filesz = Last->Offset - First->Offset;
if (Last->Type != SHT_NOBITS)

View File

@ -41,8 +41,8 @@ struct PhdrEntry {
uint32_t p_type = 0;
uint32_t p_flags = 0;
OutputSection *First = nullptr;
OutputSection *Last = nullptr;
OutputSection *FirstSec = nullptr;
OutputSection *LastSec = nullptr;
bool HasLMA = false;
};