Skip to content

Commit 98b70f6

Browse files
committed
[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 llvm-svn: 359268
1 parent 9e441ae commit 98b70f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lld/ELF/InputSection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ InputSectionBase::InputSectionBase(InputFile *File, uint64_t Flags,
7575

7676
// The ELF spec states that a value of 0 means the section has
7777
// no alignment constraits.
78-
uint32_t V = std::max<uint64_t>(Alignment, 1);
78+
uint32_t V = std::max<uint32_t>(Alignment, 1);
7979
if (!isPowerOf2_64(V))
8080
fatal(toString(this) + ": sh_addralign is not a power of 2");
8181
this->Alignment = V;
@@ -253,7 +253,7 @@ void InputSectionBase::parseCompressedHeader() {
253253
}
254254

255255
UncompressedSize = Hdr->ch_size;
256-
Alignment = std::max<uint64_t>(Hdr->ch_addralign, 1);
256+
Alignment = std::max<uint32_t>(Hdr->ch_addralign, 1);
257257
RawData = RawData.slice(sizeof(*Hdr));
258258
return;
259259
}
@@ -271,7 +271,7 @@ void InputSectionBase::parseCompressedHeader() {
271271
}
272272

273273
UncompressedSize = Hdr->ch_size;
274-
Alignment = std::max<uint64_t>(Hdr->ch_addralign, 1);
274+
Alignment = std::max<uint32_t>(Hdr->ch_addralign, 1);
275275
RawData = RawData.slice(sizeof(*Hdr));
276276
}
277277

0 commit comments

Comments
 (0)