[lld] r248229 - Remove the Chunk terminology from ELF.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 17:16:19 PDT 2015


Author: rafael
Date: Mon Sep 21 19:16:19 2015
New Revision: 248229

URL: http://llvm.org/viewvc/llvm-project?rev=248229&view=rev
Log:
Remove the Chunk terminology from ELF.

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputFiles.h
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Sep 21 19:16:19 2015
@@ -91,13 +91,13 @@ template <class ELFT> void elf2::ObjectF
   this->openELF(MB);
 
   // Read section and symbol tables.
-  initializeChunks();
+  initializeSections();
   initializeSymbols();
 }
 
-template <class ELFT> void elf2::ObjectFile<ELFT>::initializeChunks() {
+template <class ELFT> void elf2::ObjectFile<ELFT>::initializeSections() {
   uint64_t Size = this->ELFObj->getNumSections();
-  Chunks.resize(Size);
+  Sections.resize(Size);
   unsigned I = 0;
   for (const Elf_Shdr &Sec : this->ELFObj->sections()) {
     switch (Sec.sh_type) {
@@ -119,14 +119,14 @@ template <class ELFT> void elf2::ObjectF
       uint32_t RelocatedSectionIndex = Sec.sh_info;
       if (RelocatedSectionIndex >= Size)
         error("Invalid relocated section index");
-      InputSection<ELFT> *RelocatedSection = Chunks[RelocatedSectionIndex];
+      InputSection<ELFT> *RelocatedSection = Sections[RelocatedSectionIndex];
       if (!RelocatedSection)
         error("Unsupported relocation reference");
       RelocatedSection->RelocSections.push_back(&Sec);
       break;
     }
     default:
-      Chunks[I] = new (Alloc) InputSection<ELFT>(this, &Sec);
+      Sections[I] = new (Alloc) InputSection<ELFT>(this, &Sec);
       break;
     }
     ++I;
@@ -162,8 +162,7 @@ SymbolBody *elf2::ObjectFile<ELFT>::crea
     break;
   }
 
-  if (SecIndex >= Chunks.size() ||
-      (SecIndex != 0 && !Chunks[SecIndex]))
+  if (SecIndex >= Sections.size() || (SecIndex != 0 && !Sections[SecIndex]))
     error("Invalid section index");
 
   switch (Sym->getBinding()) {
@@ -171,7 +170,7 @@ SymbolBody *elf2::ObjectFile<ELFT>::crea
     error("unexpected binding");
   case STB_GLOBAL:
   case STB_WEAK:
-    return new (Alloc) DefinedRegular<ELFT>(Name, *Sym, *Chunks[SecIndex]);
+    return new (Alloc) DefinedRegular<ELFT>(Name, *Sym, *Sections[SecIndex]);
   }
 }
 

Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Mon Sep 21 19:16:19 2015
@@ -132,7 +132,7 @@ public:
       : ObjectFileBase(getStaticELFKind<ELFT>(), M) {}
   void parse() override;
 
-  ArrayRef<InputSection<ELFT> *> getChunks() const { return Chunks; }
+  ArrayRef<InputSection<ELFT> *> getSections() const { return Sections; }
 
   SymbolBody *getSymbolBody(uint32_t SymbolIndex) const {
     uint32_t FirstNonLocal = this->Symtab->sh_info;
@@ -147,13 +147,13 @@ public:
   ArrayRef<Elf_Word> getSymbolTableShndx() const { return SymtabSHNDX; };
 
 private:
-  void initializeChunks();
+  void initializeSections();
   void initializeSymbols();
 
   SymbolBody *createSymbolBody(StringRef StringTable, const Elf_Sym *Sym);
 
-  // List of all chunks defined by this file.
-  std::vector<InputSection<ELFT> *> Chunks;
+  // List of all sections defined by this file.
+  std::vector<InputSection<ELFT> *> Sections;
 
   ArrayRef<Elf_Word> SymtabSHNDX;
 };

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Mon Sep 21 19:16:19 2015
@@ -21,7 +21,7 @@ template <class ELFT> class OutputSectio
 template <class ELFT> class PltSection;
 template <class ELFT> class GotSection;
 
-// A chunk corresponding a section of an input file.
+// This corresponds to a section of an input file.
 template <class ELFT> class InputSection {
   typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr;
   typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela;
@@ -32,10 +32,10 @@ template <class ELFT> class InputSection
 public:
   InputSection(ObjectFile<ELFT> *F, const Elf_Shdr *Header);
 
-  // Returns the size of this chunk (even if this is a common or BSS.)
+  // Returns the size of this section (even if this is a common or BSS.)
   size_t getSize() const { return Header->sh_size; }
 
-  // Write this chunk to a mmap'ed file, assuming Buf is pointing to
+  // Write this section to a mmap'ed file, assuming Buf is pointing to
   // beginning of the output section.
   void writeTo(uint8_t *Buf, const PltSection<ELFT> &PltSec,
                const GotSection<ELFT> &GotSec);
@@ -72,11 +72,11 @@ private:
                 const ObjectFile<ELFT> &File, uintX_t BaseAddr,
                 const PltSection<ELFT> &PltSec, const GotSection<ELFT> &GotSec);
 
-  // The offset from beginning of the output sections this chunk was assigned
+  // 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 chunk was created from.
+  // The file this section is from.
   ObjectFile<ELFT> *File;
 
   OutputSection<ELFT> *Out = nullptr;

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Sep 21 19:16:19 2015
@@ -240,8 +240,8 @@ template <class ELFT> void DynamicSectio
 }
 
 template <class ELFT>
-void OutputSection<ELFT>::addChunk(InputSection<ELFT> *C) {
-  Chunks.push_back(C);
+void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) {
+  Sections.push_back(C);
   C->setOutputSection(this);
   uint32_t Align = C->getAlign();
   if (Align > this->Header.sh_addralign)
@@ -271,14 +271,14 @@ lld::elf2::getLocalSymVA(const typename
   if (SecIndex == SHN_XINDEX)
     SecIndex = File.getObj()->getExtendedSymbolTableIndex(
         Sym, File.getSymbolTable(), File.getSymbolTableShndx());
-  ArrayRef<InputSection<ELFT> *> Chunks = File.getChunks();
-  InputSection<ELFT> *Section = Chunks[SecIndex];
+  ArrayRef<InputSection<ELFT> *> Sections = File.getSections();
+  InputSection<ELFT> *Section = Sections[SecIndex];
   OutputSection<ELFT> *Out = Section->getOutputSection();
   return Out->getVA() + Section->getOutputSectionOff() + Sym->st_value;
 }
 
 template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) {
-  for (InputSection<ELFT> *C : Chunks)
+  for (InputSection<ELFT> *C : Sections)
     C->writeTo(Buf, PltSec, GotSec);
 }
 
@@ -323,8 +323,8 @@ template <class ELFT> void SymbolTableSe
         if (SecIndex == SHN_XINDEX)
           SecIndex = File.getObj()->getExtendedSymbolTableIndex(
               &Sym, File.getSymbolTable(), File.getSymbolTableShndx());
-        ArrayRef<InputSection<ELFT> *> Chunks = File.getChunks();
-        Section = Chunks[SecIndex];
+        ArrayRef<InputSection<ELFT> *> Sections = File.getSections();
+        Section = Sections[SecIndex];
         assert(Section != nullptr);
         Out = Section->getOutputSection();
         assert(Out != nullptr);

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Mon Sep 21 19:16:19 2015
@@ -43,10 +43,10 @@ getLocalSymVA(const typename llvm::objec
 
 bool includeInSymtab(const SymbolBody &B);
 
-// OutputSection represents a section in an output file. It's a
-// container of chunks. OutputSection and Chunk are 1:N relationship.
-// Chunks cannot belong to more than one OutputSections. The writer
-// creates multiple OutputSections and assign them unique,
+// This represents a section in an output file.
+// Different sub classes represent different types of sections. Some contain
+// input sections, others are created by the linker.
+// The writer creates multiple OutputSections and assign them unique,
 // non-overlapping file offsets and VAs.
 template <bool Is64Bits> class OutputSectionBase {
 public:
@@ -242,11 +242,11 @@ public:
       : OutputSectionBase<ELFT::Is64Bits>(Name, sh_type, sh_flags),
         PltSec(PltSec), GotSec(GotSec) {}
 
-  void addChunk(InputSection<ELFT> *C);
+  void addSection(InputSection<ELFT> *C);
   void writeTo(uint8_t *Buf) override;
 
 private:
-  std::vector<InputSection<ELFT> *> Chunks;
+  std::vector<InputSection<ELFT> *> Sections;
   const PltSection<ELFT> &PltSec;
   const GotSection<ELFT> &GotSec;
 };

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Mon Sep 21 19:16:19 2015
@@ -20,7 +20,6 @@ namespace lld {
 namespace elf2 {
 
 class ArchiveFile;
-class Chunk;
 class InputFile;
 class SymbolBody;
 template <class ELFT> class ObjectFile;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248229&r1=248228&r2=248229&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Sep 21 19:16:19 2015
@@ -333,13 +333,13 @@ template <class ELFT> void Writer<ELFT>:
           SymTabSec.addSymbol(*SymName, true);
       }
     }
-    for (InputSection<ELFT> *C : File.getChunks()) {
+    for (InputSection<ELFT> *C : File.getSections()) {
       if (!C)
         continue;
       const Elf_Shdr *H = C->getSectionHdr();
       OutputSection<ELFT> *Sec =
           getSection(C->getSectionName(), H->sh_type, H->sh_flags);
-      Sec->addChunk(C);
+      Sec->addSection(C);
       scanRelocs(*C);
     }
   }




More information about the llvm-commits mailing list