From 397f0aa0d3d3d4b5fe169cfb88653c6c78bb2b53 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 25 Oct 2016 16:42:46 +0000 Subject: [PATCH] Be a bit more consistent about using getters. NFC. llvm-svn: 285082 --- lld/ELF/InputSection.cpp | 20 ++++++++++---------- lld/ELF/InputSection.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 67bbbd8..81f3cea 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -54,7 +54,7 @@ InputSectionBase::InputSectionBase(elf::ObjectFile *File, Header(Hdr), File(File), Repl(this) { // The ELF spec states that a value of 0 means the section has // no alignment constraits. - uint64_t V = std::max(Header->sh_addralign, 1); + uint64_t V = std::max(Hdr->sh_addralign, 1); if (!isPowerOf2_64(V)) fatal(getFilename(File) + ": section sh_addralign is not a power of 2"); @@ -150,7 +150,7 @@ template void InputSectionBase::uncompress() { // shouldn't be significant in ELF.) We need to be able to read both. ArrayRef Buf; // Compressed data size_t Size; // Uncompressed size - if (Header->sh_flags & SHF_COMPRESSED) + if (getFlags() & SHF_COMPRESSED) std::tie(Buf, Size) = getElfCompressedData(Data); else std::tie(Buf, Size) = getRawCompressedData(Data); @@ -188,9 +188,9 @@ bool InputSection::classof(const InputSectionBase *S) { template InputSectionBase *InputSection::getRelocatedSection() { - assert(this->Header->sh_type == SHT_RELA || this->Header->sh_type == SHT_REL); + assert(this->getType() == SHT_RELA || this->getType() == SHT_REL); ArrayRef *> Sections = this->File->getSections(); - return Sections[this->Header->sh_info]; + return Sections[this->getInfo()]; } template void InputSection::addThunk(const Thunk *T) { @@ -400,7 +400,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd) { // vector only for SHF_ALLOC'ed sections. For other sections, // we handle relocations directly here. auto *IS = dyn_cast>(this); - if (IS && !(IS->Header->sh_flags & SHF_ALLOC)) { + if (IS && !(IS->getFlags() & SHF_ALLOC)) { for (const Elf_Shdr *RelSec : IS->RelocSections) { if (RelSec->sh_type == SHT_RELA) IS->relocateNonAlloc(Buf, IS->File->getObj().relas(RelSec)); @@ -456,16 +456,16 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd) { } template void InputSection::writeTo(uint8_t *Buf) { - if (this->Header->sh_type == SHT_NOBITS) + if (this->getType() == SHT_NOBITS) return; ELFFile &EObj = this->File->getObj(); // If -r is given, then an InputSection may be a relocation section. - if (this->Header->sh_type == SHT_RELA) { + if (this->getType() == SHT_RELA) { copyRelocations(Buf + OutSecOff, EObj.relas(this->Header)); return; } - if (this->Header->sh_type == SHT_REL) { + if (this->getType() == SHT_REL) { copyRelocations(Buf + OutSecOff, EObj.rels(this->Header)); return; } @@ -635,8 +635,8 @@ MergeInputSection::MergeInputSection(elf::ObjectFile *F, template void MergeInputSection::splitIntoPieces() { ArrayRef Data = this->Data; - uintX_t EntSize = this->Header->sh_entsize; - if (this->Header->sh_flags & SHF_STRINGS) + uintX_t EntSize = this->getEntsize(); + if (this->getFlags() & SHF_STRINGS) this->Pieces = splitStrings(Data, EntSize); else this->Pieces = splitNonStrings(Data, EntSize); diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index ec2a3f3..3ff3531 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -105,6 +105,7 @@ public: uint32_t getType() const { return Header->sh_type; } uintX_t getEntsize() const { return Header->sh_entsize; } uint32_t getLink() const { return Header->sh_link; } + uint32_t getInfo() const { return Header->sh_info; } ObjectFile *getFile() const { return File; } uintX_t getOffset(const DefinedRegular &Sym) const; InputSectionBase *getLinkOrderDep() const; -- 2.7.4