[lld] r359268 - [ELF] Change std::max<uint64_t> to uint32_t for section alignment

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 21:07:59 PDT 2019


Author: maskray
Date: Thu Apr 25 21:07:58 2019
New Revision: 359268

URL: http://llvm.org/viewvc/llvm-project?rev=359268&view=rev
Log:
[ELF] Change std::max<uint64_t> to uint32_t for section alignment

Summary:
We use `uint32_t SectionBase::Alignment` and `uint32_t
PhdrEntry::p_align` despite alignments being 64 bits in ELF64.
Fix the std::max template arguments accordingly.

The currently 160-byte InputSection will become 168 bytes if we make SectionBase::Alignment uint64_t.

Differential Revision: https://reviews.llvm.org/D61171

Modified:
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=359268&r1=359267&r2=359268&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Apr 25 21:07:58 2019
@@ -75,7 +75,7 @@ InputSectionBase::InputSectionBase(Input
 
   // The ELF spec states that a value of 0 means the section has
   // no alignment constraits.
-  uint32_t V = std::max<uint64_t>(Alignment, 1);
+  uint32_t V = std::max<uint32_t>(Alignment, 1);
   if (!isPowerOf2_64(V))
     fatal(toString(this) + ": sh_addralign is not a power of 2");
   this->Alignment = V;
@@ -253,7 +253,7 @@ void InputSectionBase::parseCompressedHe
     }
 
     UncompressedSize = Hdr->ch_size;
-    Alignment = std::max<uint64_t>(Hdr->ch_addralign, 1);
+    Alignment = std::max<uint32_t>(Hdr->ch_addralign, 1);
     RawData = RawData.slice(sizeof(*Hdr));
     return;
   }
@@ -271,7 +271,7 @@ void InputSectionBase::parseCompressedHe
   }
 
   UncompressedSize = Hdr->ch_size;
-  Alignment = std::max<uint64_t>(Hdr->ch_addralign, 1);
+  Alignment = std::max<uint32_t>(Hdr->ch_addralign, 1);
   RawData = RawData.slice(sizeof(*Hdr));
 }
 




More information about the llvm-commits mailing list