[lld] r250328 - ELF2: Remove {set,get}OutputSection accessors.

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


Author: ruiu
Date: Wed Oct 14 16:09:55 2015
New Revision: 250328

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

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

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=250328&r1=250327&r2=250328&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Oct 14 16:09:55 2015
@@ -76,7 +76,7 @@ template <class ELFT> void InputSection<
   ObjectFile<ELFT> *File = getFile();
   ELFFile<ELFT> &EObj = File->getObj();
   uint8_t *Base = Buf + OutputSectionOff;
-  uintX_t BaseAddr = OutSec->getVA() + OutputSectionOff;
+  uintX_t BaseAddr = OutputSection->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=250328&r1=250327&r2=250328&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Oct 14 16:09:55 2015
@@ -48,15 +48,13 @@ public:
     return std::max<uintX_t>(Header->sh_addralign, 1);
   }
 
-  void setOutputSection(OutputSection<ELFT> *O) { OutSec = O; }
-  OutputSection<ELFT> *getOutputSection() const { return OutSec; }
-
   // 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;
+  OutputSection<ELFT> *OutputSection = nullptr;
 
   static InputSection<ELFT> Discarded;
 
@@ -70,8 +68,6 @@ private:
   // The file this section is from.
   ObjectFile<ELFT> *File;
 
-  OutputSection<ELFT> *OutSec = nullptr;
-
   const Elf_Shdr *Header;
 };
 

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250328&r1=250327&r2=250328&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Oct 14 16:09:55 2015
@@ -113,7 +113,6 @@ template <class ELFT> void RelocationSec
 
     const InputSection<ELFT> &C = Rel.C;
     const Elf_Rel &RI = Rel.RI;
-    OutputSection<ELFT> *OutSec = C.getOutputSection();
     uint32_t SymIndex = RI.getSymbol(IsMips64EL);
     const ObjectFile<ELFT> &File = *C.getFile();
     SymbolBody *Body = File.getSymbolBody(SymIndex);
@@ -143,7 +142,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.OutputSectionOff + OutSec->getVA();
+      P->r_offset = RI.r_offset + C.OutputSection->getVA() + C.OutputSectionOff;
       if (CanBePreempted)
         P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
                             IsMips64EL);
@@ -385,7 +384,7 @@ OutputSection<ELFT>::OutputSection(Strin
 template <class ELFT>
 void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) {
   Sections.push_back(C);
-  C->setOutputSection(this);
+  C->OutputSection = this;
   uint32_t Align = C->getAlign();
   if (Align > this->Header.sh_addralign)
     this->Header.sh_addralign = Align;
@@ -409,8 +408,7 @@ typename ELFFile<ELFT>::uintX_t lld::elf
   case SymbolBody::DefinedRegularKind: {
     const auto &DR = cast<DefinedRegular<ELFT>>(S);
     const InputSection<ELFT> *SC = &DR.Section;
-    OutputSection<ELFT> *OS = SC->getOutputSection();
-    return OS->getVA() + SC->OutputSectionOff + DR.Sym.st_value;
+    return SC->OutputSection->getVA() + SC->OutputSectionOff + DR.Sym.st_value;
   }
   case SymbolBody::DefinedCommonKind:
     return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS;
@@ -453,8 +451,8 @@ lld::elf2::getLocalRelTarget(const Objec
   if (Section == &InputSection<ELFT>::Discarded)
     return 0;
 
-  OutputSection<ELFT> *OutSec = Section->getOutputSection();
-  return OutSec->getVA() + Section->OutputSectionOff + Sym->st_value;
+  return Section->OutputSection->getVA() + Section->OutputSectionOff +
+         Sym->st_value;
 }
 
 // Returns true if a symbol can be replaced at load-time by a symbol
@@ -628,7 +626,7 @@ void SymbolTableSection<ELFT>::writeLoca
               &Sym, File->getSymbolTable(), File->getSymbolTableShndx());
         ArrayRef<InputSection<ELFT> *> Sections = File->getSections();
         const InputSection<ELFT> *Section = Sections[SecIndex];
-        const OutputSection<ELFT> *OutSec = Section->getOutputSection();
+        const OutputSection<ELFT> *OutSec = Section->OutputSection;
         ESym->st_shndx = OutSec->getSectionIndex();
         VA += OutSec->getVA() + Section->OutputSectionOff;
       }
@@ -696,7 +694,7 @@ void SymbolTableSection<ELFT>::writeGlob
     ESym->st_value = getSymVA<ELFT>(*Body);
 
     if (Section)
-      OutSec = Section->getOutputSection();
+      OutSec = Section->OutputSection;
 
     if (isa<DefinedAbsolute<ELFT>>(Body))
       ESym->st_shndx = SHN_ABS;




More information about the llvm-commits mailing list