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