From c94678bf723469767f85db39a4bace8a8e60d71c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 29 Sep 2016 16:29:55 +0000 Subject: [PATCH] Simplify. NFC. llvm-svn: 282725 --- lld/ELF/Writer.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 239d45a4a370..ac1d159219da 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1190,15 +1190,14 @@ static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase *Sec) { Alignment = std::max(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 *First = Sec->FirstInPtLoad; + // If the section is not in a PT_LOAD, we have no other constraint. + if (!First) return Off; - OutputSectionBase *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(); }