From edffd91bcec7cb02dd527a9ca210888b28eaf0f2 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 14 Oct 2015 21:00:23 +0000 Subject: [PATCH] ELF2: Remove {set,get}OutputSectionOff accessors. These accessors didn't provide any additional value over a public member variable. llvm-svn: 250326 --- lld/ELF/InputSection.cpp | 4 ++-- lld/ELF/InputSection.h | 10 ++++------ lld/ELF/OutputSections.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index d1236fd1a589..980466b61f99 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -75,8 +75,8 @@ template void InputSection::writeTo(uint8_t *Buf) { ObjectFile *File = getFile(); ELFFile &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) diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index eea4c2df5e6d..e65232fd2777 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -42,13 +42,11 @@ public: ObjectFile *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(Header->sh_addralign, 1); } - void setOutputSectionOff(uint64_t V) { OutputSectionOff = V; } void setOutputSection(OutputSection *O) { OutSec = O; } OutputSection *getOutputSection() const { return OutSec; } @@ -56,6 +54,10 @@ public: // Relocation sections that refer to this one. SmallVector 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 Discarded; private: @@ -65,10 +67,6 @@ private: const llvm::object::Elf_Rel_Impl *> Rels, const ObjectFile &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 *File; diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 0b531c011a6d..5f489997f39b 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -143,7 +143,7 @@ template void RelocationSection::writeTo(uint8_t *Buf) { } else { if (IsRela) Addend += static_cast(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::addSection(InputSection *C) { 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::uintX_t lld::elf2::getSymVA(const SymbolBody &S) { const auto &DR = cast>(S); const InputSection *SC = &DR.Section; OutputSection *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::Bss->getVA() + cast>(S).OffsetInBSS; @@ -454,7 +454,7 @@ lld::elf2::getLocalRelTarget(const ObjectFile &File, return 0; OutputSection *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::writeLocalSymbols(uint8_t *&Buf) { const InputSection *Section = Sections[SecIndex]; const OutputSection *OutSec = Section->getOutputSection(); ESym->st_shndx = OutSec->getSectionIndex(); - VA += OutSec->getVA() + Section->getOutputSectionOff(); + VA += OutSec->getVA() + Section->OutputSectionOff; } ESym->st_value = VA; }