[lld] r288971 - Simplify. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 12:20:39 PST 2016
Author: rafael
Date: Wed Dec 7 14:20:39 2016
New Revision: 288971
URL: http://llvm.org/viewvc/llvm-project?rev=288971&view=rev
Log:
Simplify. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=288971&r1=288970&r2=288971&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Dec 7 14:20:39 2016
@@ -1312,20 +1312,18 @@ template <class ELFT> void Writer<ELFT>:
// executables without any address adjustment.
template <class ELFT, class uintX_t>
static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase *Sec) {
- uintX_t Alignment = Sec->Addralign;
- if (Sec->PageAlign)
- Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);
- Off = alignTo(Off, Alignment);
-
OutputSectionBase *First = Sec->FirstInPtLoad;
- // If the section is not in a PT_LOAD, we have no other constraint.
+ // If the section is not in a PT_LOAD, we just have to align it.
if (!First)
- return Off;
+ return alignTo(Off, Sec->Addralign);
- // If two sections share the same PT_LOAD the file offset is calculated using
- // this formula: Off2 = Off1 + (VA2 - VA1).
+ // The first section in a PT_LOAD has to have congruent offset and address
+ // module the page size.
if (Sec == First)
return alignTo(Off, Config->MaxPageSize, Sec->Addr);
+
+ // If two sections share the same PT_LOAD the file offset is calculated
+ // using this formula: Off2 = Off1 + (VA2 - VA1).
return First->Offset + Sec->Addr - First->Addr;
}
More information about the llvm-commits
mailing list