[lld] r250326 - ELF2: Remove {set,get}OutputSectionOff accessors.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 14:00:23 PDT 2015


Author: ruiu
Date: Wed Oct 14 16:00:23 2015
New Revision: 250326

URL: http://llvm.org/viewvc/llvm-project?rev=250326&view=rev
Log:
ELF2: Remove {set,get}OutputSectionOff accessors.

These accessors didn't provide any additional value over a public
member variable.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=250326&r1=250325&r2=250326&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Oct 14 16:00:23 2015
@@ -75,8 +75,8 @@ template <class ELFT> void InputSection<
 
   ObjectFile<ELFT> *File = getFile();
   ELFFile<ELFT> &EObj = File->getObj();
-  uint8_t *Base = Buf + getOutputSectionOff();
-  uintX_t BaseAddr = OutSec->getVA() + getOutputSectionOff();
+  uint8_t *Base = Buf + OutputSectionOff;
+  uintX_t BaseAddr = OutSec->getVA() + OutputSectionOff;
   // Iterate over all relocation sections that apply to this section.
   for (const Elf_Shdr *RelSec : RelocSections) {
     if (RelSec->sh_type == SHT_RELA)

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=250326&r1=250325&r2=250326&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Oct 14 16:00:23 2015
@@ -42,13 +42,11 @@ public:
   ObjectFile<ELFT> *getFile() const { return File; }
 
   // The writer sets and uses the addresses.
-  uintX_t getOutputSectionOff() const { return OutputSectionOff; }
   uintX_t getAlign() {
     // The ELF spec states that a value of 0 means the section has no alignment
     // constraits.
     return std::max<uintX_t>(Header->sh_addralign, 1);
   }
-  void setOutputSectionOff(uint64_t V) { OutputSectionOff = V; }
 
   void setOutputSection(OutputSection<ELFT> *O) { OutSec = O; }
   OutputSection<ELFT> *getOutputSection() const { return OutSec; }
@@ -56,6 +54,10 @@ public:
   // Relocation sections that refer to this one.
   SmallVector<const Elf_Shdr *, 1> RelocSections;
 
+  // The offset from beginning of the output sections this section was assigned
+  // to. The writer sets a value.
+  uint64_t OutputSectionOff = 0;
+
   static InputSection<ELFT> Discarded;
 
 private:
@@ -65,10 +67,6 @@ private:
                     const llvm::object::Elf_Rel_Impl<ELFT, isRela> *> Rels,
                 const ObjectFile<ELFT> &File, uintX_t BaseAddr);
 
-  // The offset from beginning of the output sections this section was assigned
-  // to. The writer sets a value.
-  uint64_t OutputSectionOff = 0;
-
   // The file this section is from.
   ObjectFile<ELFT> *File;
 

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250326&r1=250325&r2=250326&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Oct 14 16:00:23 2015
@@ -143,7 +143,7 @@ template <class ELFT> void RelocationSec
     } else {
       if (IsRela)
         Addend += static_cast<const Elf_Rela &>(RI).r_addend;
-      P->r_offset = RI.r_offset + C.getOutputSectionOff() + OutSec->getVA();
+      P->r_offset = RI.r_offset + C.OutputSectionOff + OutSec->getVA();
       if (CanBePreempted)
         P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
                             IsMips64EL);
@@ -392,7 +392,7 @@ void OutputSection<ELFT>::addSection(Inp
 
   uintX_t Off = this->Header.sh_size;
   Off = RoundUpToAlignment(Off, Align);
-  C->setOutputSectionOff(Off);
+  C->OutputSectionOff = Off;
   Off += C->getSize();
   this->Header.sh_size = Off;
 }
@@ -410,7 +410,7 @@ typename ELFFile<ELFT>::uintX_t lld::elf
     const auto &DR = cast<DefinedRegular<ELFT>>(S);
     const InputSection<ELFT> *SC = &DR.Section;
     OutputSection<ELFT> *OS = SC->getOutputSection();
-    return OS->getVA() + SC->getOutputSectionOff() + DR.Sym.st_value;
+    return OS->getVA() + SC->OutputSectionOff + DR.Sym.st_value;
   }
   case SymbolBody::DefinedCommonKind:
     return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS;
@@ -454,7 +454,7 @@ lld::elf2::getLocalRelTarget(const Objec
     return 0;
 
   OutputSection<ELFT> *OutSec = Section->getOutputSection();
-  return OutSec->getVA() + Section->getOutputSectionOff() + Sym->st_value;
+  return OutSec->getVA() + Section->OutputSectionOff + Sym->st_value;
 }
 
 // Returns true if a symbol can be replaced at load-time by a symbol
@@ -630,7 +630,7 @@ void SymbolTableSection<ELFT>::writeLoca
         const InputSection<ELFT> *Section = Sections[SecIndex];
         const OutputSection<ELFT> *OutSec = Section->getOutputSection();
         ESym->st_shndx = OutSec->getSectionIndex();
-        VA += OutSec->getVA() + Section->getOutputSectionOff();
+        VA += OutSec->getVA() + Section->OutputSectionOff;
       }
       ESym->st_value = VA;
     }




More information about the llvm-commits mailing list