diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-03-08 19:35:29 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-03-08 19:35:29 +0000 |
| commit | fcd208fdb3309a8d8637e7017415581f3eb62e18 (patch) | |
| tree | f85ac8559dd2c97bcc0289ae5bb910a0804d9779 | |
| parent | 7596bd7a27e62540aefc5607124d7b71d728f35e (diff) | |
| download | bcm5719-llvm-fcd208fdb3309a8d8637e7017415581f3eb62e18.tar.gz bcm5719-llvm-fcd208fdb3309a8d8637e7017415581f3eb62e18.zip | |
Use uint32_t for alignment in more places, NFC.
llvm-svn: 297305
| -rw-r--r-- | lld/ELF/InputSection.cpp | 17 | ||||
| -rw-r--r-- | lld/ELF/InputSection.h | 4 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 2 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.h | 2 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 2 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.h | 2 | ||||
| -rw-r--r-- | lld/ELF/Symbols.cpp | 16 | ||||
| -rw-r--r-- | lld/ELF/Symbols.h | 6 | ||||
| -rw-r--r-- | lld/ELF/SyntheticSections.cpp | 2 | ||||
| -rw-r--r-- | lld/ELF/SyntheticSections.h | 4 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 4 |
11 files changed, 30 insertions, 31 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 99d4db351f4..a620d023e4c 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -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, diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index b22e21469cd..b243d912082 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -79,7 +79,7 @@ public: 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, StringRef Name, + uint32_t Alignment, ArrayRef<uint8_t> Data, StringRef Name, Kind SectionKind); OutputSection *OutSec = nullptr; @@ -253,7 +253,7 @@ public: // .eh_frame. It also includes the synthetic sections themselves. class InputSection : public InputSectionBase { public: - InputSection(uint64_t Flags, uint32_t Type, uint64_t Alignment, + InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment, ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular); template <class ELFT> InputSection(ObjectFile<ELFT> *F, const typename ELFT::Shdr *Header, diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 2efb47b9fc8..544a6d08798 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -299,7 +299,7 @@ static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) { typedef typename ELFT::uint uintX_t; - uintX_t Alignment = 0; + uint32_t Alignment = 0; uintX_t Flags = 0; if (Config->Relocatable && (C->Flags & SHF_MERGE)) { Alignment = std::max<uintX_t>(C->Alignment, C->Entsize); diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 660096fde01..63c8dce72ab 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -114,7 +114,7 @@ struct Out { struct SectionKey { StringRef Name; uint64_t Flags; - uint64_t Alignment; + uint32_t Alignment; }; } } diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 42ba18a39ac..9105253b897 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -319,7 +319,7 @@ static int compareDefinedNonCommon(Symbol *S, bool WasInserted, uint8_t Binding, template <class ELFT> Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size, - uint64_t Alignment, uint8_t Binding, + uint32_t Alignment, uint8_t Binding, uint8_t StOther, uint8_t Type, InputFile *File) { Symbol *S; diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index aefa30d76d3..f6a2b1151f6 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -71,7 +71,7 @@ public: Symbol *addBitcode(StringRef Name, uint8_t Binding, uint8_t StOther, uint8_t Type, bool CanOmitFromDynSym, BitcodeFile *File); - Symbol *addCommon(StringRef N, uint64_t Size, uint64_t Alignment, + Symbol *addCommon(StringRef N, uint64_t Size, uint32_t Alignment, uint8_t Binding, uint8_t StOther, uint8_t Type, InputFile *File); diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 9eb222362bb..178c5e85b62 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -289,7 +289,7 @@ Undefined::Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther, this->File = File; } -DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint64_t Alignment, +DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint32_t Alignment, uint8_t StOther, uint8_t Type, InputFile *File) : Defined(SymbolBody::DefinedCommonKind, Name, /*IsLocal=*/false, StOther, Type), @@ -300,11 +300,11 @@ DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint64_t Alignment, // If a shared symbol is referred via a copy relocation, its alignment // becomes part of the ABI. This function returns a symbol alignment. // Because symbols don't have alignment attributes, we need to infer that. -template <class ELFT> uint64_t SharedSymbol::getAlignment() const { +template <class ELFT> uint32_t SharedSymbol::getAlignment() const { auto *File = cast<SharedFile<ELFT>>(this->File); - uint64_t SecAlign = File->getSection(getSym<ELFT>())->sh_addralign; + uint32_t SecAlign = File->getSection(getSym<ELFT>())->sh_addralign; uint64_t SymValue = getSym<ELFT>().st_value; - uint64_t SymAlign = uint64_t(1) << countTrailingZeros(SymValue); + uint32_t SymAlign = uint32_t(1) << countTrailingZeros(SymValue); return std::min(SecAlign, SymAlign); } @@ -433,7 +433,7 @@ template bool DefinedRegular::template isMipsPIC<ELF32BE>() const; template bool DefinedRegular::template isMipsPIC<ELF64LE>() const; template bool DefinedRegular::template isMipsPIC<ELF64BE>() const; -template uint64_t SharedSymbol::template getAlignment<ELF32LE>() const; -template uint64_t SharedSymbol::template getAlignment<ELF32BE>() const; -template uint64_t SharedSymbol::template getAlignment<ELF64LE>() const; -template uint64_t SharedSymbol::template getAlignment<ELF64BE>() const; +template uint32_t SharedSymbol::template getAlignment<ELF32LE>() const; +template uint32_t SharedSymbol::template getAlignment<ELF32BE>() const; +template uint32_t SharedSymbol::template getAlignment<ELF64LE>() const; +template uint32_t SharedSymbol::template getAlignment<ELF64BE>() const; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 696a30cb390..79bce2dd456 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -156,7 +156,7 @@ public: class DefinedCommon : public Defined { public: - DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, uint8_t StOther, + DefinedCommon(StringRef N, uint64_t Size, uint32_t Alignment, uint8_t StOther, uint8_t Type, InputFile *File); static bool classof(const SymbolBody *S) { @@ -168,7 +168,7 @@ public: uint64_t Offset; // The maximum alignment we have seen for this symbol. - uint64_t Alignment; + uint32_t Alignment; uint64_t Size; }; @@ -265,7 +265,7 @@ public: return getSym<ELFT>().st_size; } - template <class ELFT> uint64_t getAlignment() const; + template <class ELFT> uint32_t getAlignment() const; // This field is a pointer to the symbol's version definition. const void *Verdef; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index d00bba1c266..75649954980 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2136,7 +2136,7 @@ template <class ELFT> bool VersionNeedSection<ELFT>::empty() const { } MergeSyntheticSection::MergeSyntheticSection(StringRef Name, uint32_t Type, - uint64_t Flags, uint64_t Alignment) + uint64_t Flags, uint32_t Alignment) : SyntheticSection(Flags, Type, Alignment, Name), Builder(StringTableBuilder::RAW, Alignment) {} diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index b54e70478e4..50451628889 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -32,7 +32,7 @@ namespace elf { class SyntheticSection : public InputSection { public: - SyntheticSection(uint64_t Flags, uint32_t Type, uint64_t Alignment, + SyntheticSection(uint64_t Flags, uint32_t Type, uint32_t Alignment, StringRef Name) : InputSection(Flags, Type, Alignment, {}, Name, InputSectionBase::Synthetic) { @@ -646,7 +646,7 @@ public: class MergeSyntheticSection final : public SyntheticSection { public: MergeSyntheticSection(StringRef Name, uint32_t Type, uint64_t Flags, - uint64_t Alignment); + uint32_t Alignment); void addSection(MergeInputSection *MS); void writeTo(uint8_t *Buf) override; void finalizeContents() override; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index ee225416a49..bcd6a0d434f 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -176,7 +176,7 @@ template <class ELFT> static void combineMergableSections() { StringRef OutsecName = getOutputSectionName(MS->Name); uintX_t Flags = getOutFlags<ELFT>(MS); - uintX_t Alignment = std::max<uintX_t>(MS->Alignment, MS->Entsize); + uint32_t Alignment = std::max<uintX_t>(MS->Alignment, MS->Entsize); auto I = llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) { @@ -1477,7 +1477,7 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() { VA += getHeaderSize<ELFT>(); uintX_t ThreadBssOffset = 0; for (OutputSection *Sec : OutputSections) { - uintX_t Alignment = Sec->Alignment; + uint32_t Alignment = Sec->Alignment; if (Sec->PageAlign) Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize); |

