From 53d5cea648d8db7ceeedced4309e8ddd2c715578 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 21 Sep 2015 17:47:00 +0000 Subject: [PATCH] Rename SectionChunk to InputSection. This is more consistent with OutputSection. This is also part of removing the "Chunk" term from the ELF linker, since we just have input/output sections and program headers. llvm-svn: 248183 --- lld/ELF/Chunks.cpp | 14 +++++++------- lld/ELF/Chunks.h | 4 ++-- lld/ELF/InputFiles.cpp | 4 ++-- lld/ELF/InputFiles.h | 4 ++-- lld/ELF/Symbols.h | 4 ++-- lld/ELF/Writer.cpp | 28 ++++++++++++++-------------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lld/ELF/Chunks.cpp b/lld/ELF/Chunks.cpp index 29160dad7575..22bca359748a 100644 --- a/lld/ELF/Chunks.cpp +++ b/lld/ELF/Chunks.cpp @@ -18,10 +18,10 @@ using namespace lld; using namespace lld::elf2; template -SectionChunk::SectionChunk(ObjectFile *F, const Elf_Shdr *Header) +InputSection::InputSection(ObjectFile *F, const Elf_Shdr *Header) : File(F), Header(Header) {} -template void SectionChunk::writeTo(uint8_t *Buf) { +template void InputSection::writeTo(uint8_t *Buf) { if (Header->sh_type == SHT_NOBITS) return; // Copy section contents from source object file to output file. @@ -29,7 +29,7 @@ template void SectionChunk::writeTo(uint8_t *Buf) { memcpy(Buf + OutputSectionOff, Data.data(), Data.size()); } -template StringRef SectionChunk::getSectionName() const { +template StringRef InputSection::getSectionName() const { ErrorOr Name = File->getObj()->getSectionName(Header); error(Name); return *Name; @@ -37,9 +37,9 @@ template StringRef SectionChunk::getSectionName() const { namespace lld { namespace elf2 { -template class SectionChunk; -template class SectionChunk; -template class SectionChunk; -template class SectionChunk; +template class InputSection; +template class InputSection; +template class InputSection; +template class InputSection; } } diff --git a/lld/ELF/Chunks.h b/lld/ELF/Chunks.h index 3b8126e689c1..4888b70b4fb6 100644 --- a/lld/ELF/Chunks.h +++ b/lld/ELF/Chunks.h @@ -20,14 +20,14 @@ template class ObjectFile; template class OutputSection; // A chunk corresponding a section of an input file. -template class SectionChunk { +template class InputSection { typedef typename llvm::object::ELFFile::Elf_Shdr Elf_Shdr; typedef typename llvm::object::ELFFile::Elf_Rela Elf_Rela; typedef typename llvm::object::ELFFile::Elf_Rel Elf_Rel; typedef typename llvm::object::ELFFile::uintX_t uintX_t; public: - SectionChunk(ObjectFile *F, const Elf_Shdr *Header); + InputSection(ObjectFile *F, const Elf_Shdr *Header); // Returns the size of this chunk (even if this is a common or BSS.) size_t getSize() const { return Header->sh_size; } diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 5d9e92d71531..654aa8985904 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -119,14 +119,14 @@ template void elf2::ObjectFile::initializeChunks() { uint32_t RelocatedSectionIndex = Sec.sh_info; if (RelocatedSectionIndex >= Size) error("Invalid relocated section index"); - SectionChunk *RelocatedSection = Chunks[RelocatedSectionIndex]; + InputSection *RelocatedSection = Chunks[RelocatedSectionIndex]; if (!RelocatedSection) error("Unsupported relocation reference"); RelocatedSection->RelocSections.push_back(&Sec); break; } default: - Chunks[I] = new (Alloc) SectionChunk(this, &Sec); + Chunks[I] = new (Alloc) InputSection(this, &Sec); break; } ++I; diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index f689b4238881..32f30c1b3e4e 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -132,7 +132,7 @@ public: : ObjectFileBase(getStaticELFKind(), M) {} void parse() override; - ArrayRef *> getChunks() const { return Chunks; } + ArrayRef *> getChunks() const { return Chunks; } SymbolBody *getSymbolBody(uint32_t SymbolIndex) const { uint32_t FirstNonLocal = this->Symtab->sh_info; @@ -153,7 +153,7 @@ private: SymbolBody *createSymbolBody(StringRef StringTable, const Elf_Sym *Sym); // List of all chunks defined by this file. - std::vector *> Chunks; + std::vector *> Chunks; ArrayRef SymtabSHNDX; }; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 27d4d6ec1ed9..404bcca6d7a9 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -197,14 +197,14 @@ template class DefinedRegular : public Defined { public: explicit DefinedRegular(StringRef N, const Elf_Sym &Sym, - SectionChunk &Section) + InputSection &Section) : Defined(Base::DefinedRegularKind, N, Sym), Section(Section) {} static bool classof(const SymbolBody *S) { return S->kind() == Base::DefinedRegularKind; } - const SectionChunk &Section; + const InputSection &Section; }; // Undefined symbol. diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9ec540678da6..46441e67015e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -96,7 +96,7 @@ template class SymbolTableSection; template struct DynamicReloc { typedef typename ELFFile::Elf_Rel Elf_Rel; - const SectionChunk &C; + const InputSection &C; const Elf_Rel &RI; }; @@ -225,7 +225,7 @@ public: auto *P = reinterpret_cast(Buf); bool IsMips64EL = Relocs[0].C.getFile()->getObj()->isMips64EL(); for (const DynamicReloc &Rel : Relocs) { - const SectionChunk &C = Rel.C; + const InputSection &C = Rel.C; const Elf_Rel &RI = Rel.RI; OutputSection *Out = C.getOutputSection(); uint32_t SymIndex = RI.getSymbol(IsMips64EL); @@ -270,7 +270,7 @@ public: : OutputSectionBase(Name, sh_type, sh_flags), PltSec(PltSec), GotSec(GotSec) {} - void addChunk(SectionChunk *C); + void addChunk(InputSection *C); void writeTo(uint8_t *Buf) override; template @@ -284,7 +284,7 @@ public: uintX_t BaseAddr, uintX_t SymVA); private: - std::vector *> Chunks; + std::vector *> Chunks; const PltSection &PltSec; const GotSection &GotSec; }; @@ -633,9 +633,9 @@ public: private: void createSections(); template - void scanRelocs(const SectionChunk &C, + void scanRelocs(const InputSection &C, iterator_range *> Rels); - void scanRelocs(const SectionChunk &C); + void scanRelocs(const InputSection &C); void assignAddresses(); void openFile(StringRef OutputPath); void writeHeader(); @@ -711,7 +711,7 @@ template void Writer::run() { } template -void OutputSection::addChunk(SectionChunk *C) { +void OutputSection::addChunk(InputSection *C) { Chunks.push_back(C); C->setOutputSection(this); uint32_t Align = C->getAlign(); @@ -728,7 +728,7 @@ void OutputSection::addChunk(SectionChunk *C) { template static typename ELFFile::uintX_t getSymVA(const DefinedRegular *DR) { - const SectionChunk *SC = &DR->Section; + const InputSection *SC = &DR->Section; OutputSection *OS = SC->getOutputSection(); return OS->getVA() + SC->getOutputSectionOff() + DR->Sym.st_value; } @@ -832,7 +832,7 @@ void OutputSection::relocate( } template void OutputSection::writeTo(uint8_t *Buf) { - for (SectionChunk *C : Chunks) { + for (InputSection *C : Chunks) { C->writeTo(Buf); const ObjectFile *File = C->getFile(); ELFFile *EObj = File->getObj(); @@ -876,7 +876,7 @@ static bool includeInSymtab(const SymbolBody &B) { template void SymbolTableSection::writeTo(uint8_t *Buf) { const OutputSection *Out = nullptr; - const SectionChunk *Section = nullptr; + const InputSection *Section = nullptr; Buf += sizeof(Elf_Sym); // All symbols with STB_LOCAL binding precede the weak and global symbols. @@ -898,7 +898,7 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { if (SecIndex == SHN_XINDEX) SecIndex = File.getObj()->getExtendedSymbolTableIndex( &Sym, File.getSymbolTable(), File.getSymbolTableShndx()); - ArrayRef *> Chunks = File.getChunks(); + ArrayRef *> Chunks = File.getChunks(); Section = Chunks[SecIndex]; assert(Section != nullptr); Out = Section->getOutputSection(); @@ -1035,7 +1035,7 @@ static bool compSec(OutputSectionBase *A, template template void Writer::scanRelocs( - const SectionChunk &C, + const InputSection &C, iterator_range *> Rels) { typedef Elf_Rel_Impl RelType; const ObjectFile &File = *C.getFile(); @@ -1064,7 +1064,7 @@ void Writer::scanRelocs( } template -void Writer::scanRelocs(const SectionChunk &C) { +void Writer::scanRelocs(const InputSection &C) { const ObjectFile *File = C.getFile(); ELFFile *EObj = File->getObj(); @@ -1126,7 +1126,7 @@ template void Writer::createSections() { SymTabSec.addSymbol(*SymName, true); } } - for (SectionChunk *C : File.getChunks()) { + for (InputSection *C : File.getChunks()) { if (!C) continue; const Elf_Shdr *H = C->getSectionHdr();