Be a bit more consistent about using getters. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 25 Oct 2016 16:42:46 +0000 (16:42 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 25 Oct 2016 16:42:46 +0000 (16:42 +0000)
llvm-svn: 285082

lld/ELF/InputSection.cpp
lld/ELF/InputSection.h

index 67bbbd8..81f3cea 100644 (file)
@@ -54,7 +54,7 @@ InputSectionBase<ELFT>::InputSectionBase(elf::ObjectFile<ELFT> *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<uint64_t>(Header->sh_addralign, 1);
+  uint64_t V = std::max<uint64_t>(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 <class ELFT> void InputSectionBase<ELFT>::uncompress() {
   // shouldn't be significant in ELF.) We need to be able to read both.
   ArrayRef<uint8_t> 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<ELFT>::classof(const InputSectionBase<ELFT> *S) {
 
 template <class ELFT>
 InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() {
-  assert(this->Header->sh_type == SHT_RELA || this->Header->sh_type == SHT_REL);
+  assert(this->getType() == SHT_RELA || this->getType() == SHT_REL);
   ArrayRef<InputSectionBase<ELFT> *> Sections = this->File->getSections();
-  return Sections[this->Header->sh_info];
+  return Sections[this->getInfo()];
 }
 
 template <class ELFT> void InputSection<ELFT>::addThunk(const Thunk<ELFT> *T) {
@@ -400,7 +400,7 @@ void InputSectionBase<ELFT>::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<InputSection<ELFT>>(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<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd) {
 }
 
 template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
-  if (this->Header->sh_type == SHT_NOBITS)
+  if (this->getType() == SHT_NOBITS)
     return;
   ELFFile<ELFT> &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<ELFT>::MergeInputSection(elf::ObjectFile<ELFT> *F,
 
 template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
   ArrayRef<uint8_t> 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);
index ec2a3f3..3ff3531 100644 (file)
@@ -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<ELFT> *getFile() const { return File; }
   uintX_t getOffset(const DefinedRegular<ELFT> &Sym) const;
   InputSectionBase *getLinkOrderDep() const;