Simplify. NFC.

llvm-svn: 282725
This commit is contained in:
Rafael Espindola 2016-09-29 16:29:55 +00:00
parent 4e96895385
commit c94678bf72
1 changed files with 4 additions and 5 deletions

View File

@ -1190,15 +1190,14 @@ static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase<ELFT> *Sec) {
Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize); Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);
Off = alignTo(Off, Alignment); Off = alignTo(Off, Alignment);
// Relocatable output does not have program headers OutputSectionBase<ELFT> *First = Sec->FirstInPtLoad;
// and does not need any other offset adjusting. // If the section is not in a PT_LOAD, we have no other constraint.
if (Config->Relocatable || !(Sec->getFlags() & SHF_ALLOC)) if (!First)
return Off; return Off;
OutputSectionBase<ELFT> *First = Sec->FirstInPtLoad;
// If two sections share the same PT_LOAD the file offset is calculated using // If two sections share the same PT_LOAD the file offset is calculated using
// this formula: Off2 = Off1 + (VA2 - VA1). // this formula: Off2 = Off1 + (VA2 - VA1).
if (!First || Sec == First) if (Sec == First)
return alignTo(Off, Target->MaxPageSize, Sec->getVA()); return alignTo(Off, Target->MaxPageSize, Sec->getVA());
return First->getFileOffset() + Sec->getVA() - First->getVA(); return First->getFileOffset() + Sec->getVA() - First->getVA();
} }