mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
Use uint32_t for alignment in more places, NFC.
llvm-svn: 297305
This commit is contained in:
@@ -53,7 +53,7 @@ static ArrayRef<uint8_t> getSectionContents(elf::ObjectFile<ELFT> *File,
|
||||
InputSectionBase::InputSectionBase(InputFile *File, uint64_t Flags,
|
||||
uint32_t Type, uint64_t Entsize,
|
||||
uint32_t Link, uint32_t Info,
|
||||
uint64_t Alignment, ArrayRef<uint8_t> Data,
|
||||
uint32_t Alignment, ArrayRef<uint8_t> Data,
|
||||
StringRef Name, Kind SectionKind)
|
||||
: File(File), Data(Data), Name(Name), SectionKind(SectionKind),
|
||||
Live(!Config->GcSections || !(Flags & SHF_ALLOC)), Assigned(false),
|
||||
@@ -64,15 +64,9 @@ InputSectionBase::InputSectionBase(InputFile *File, uint64_t Flags,
|
||||
|
||||
// The ELF spec states that a value of 0 means the section has
|
||||
// no alignment constraits.
|
||||
uint64_t V = std::max<uint64_t>(Alignment, 1);
|
||||
uint32_t V = std::max<uint64_t>(Alignment, 1);
|
||||
if (!isPowerOf2_64(V))
|
||||
fatal(toString(File) + ": section sh_addralign is not a power of 2");
|
||||
|
||||
// We reject object files having insanely large alignments even though
|
||||
// they are allowed by the spec. I think 4GB is a reasonable limitation.
|
||||
// We might want to relax this in the future.
|
||||
if (V > UINT32_MAX)
|
||||
fatal(toString(File) + ": section sh_addralign is too large");
|
||||
this->Alignment = V;
|
||||
}
|
||||
|
||||
@@ -84,6 +78,11 @@ InputSectionBase::InputSectionBase(elf::ObjectFile<ELFT> *File,
|
||||
Hdr->sh_entsize, Hdr->sh_link, Hdr->sh_info,
|
||||
Hdr->sh_addralign, getSectionContents(File, Hdr), Name,
|
||||
SectionKind) {
|
||||
// We reject object files having insanely large alignments even though
|
||||
// they are allowed by the spec. I think 4GB is a reasonable limitation.
|
||||
// We might want to relax this in the future.
|
||||
if (Hdr->sh_addralign > UINT32_MAX)
|
||||
fatal(toString(File) + ": section sh_addralign is too large");
|
||||
}
|
||||
|
||||
size_t InputSectionBase::getSize() const {
|
||||
@@ -189,7 +188,7 @@ std::string InputSectionBase::getLocation(uint64_t Offset) {
|
||||
|
||||
InputSectionBase InputSectionBase::Discarded;
|
||||
|
||||
InputSection::InputSection(uint64_t Flags, uint32_t Type, uint64_t Alignment,
|
||||
InputSection::InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
|
||||
ArrayRef<uint8_t> Data, StringRef Name, Kind K)
|
||||
: InputSectionBase(nullptr, Flags, Type,
|
||||
/*Entsize*/ 0, /*Link*/ 0, /*Info*/ 0, Alignment, Data,
|
||||
|
||||
Reference in New Issue
Block a user