ELF2: Remove {set,get}OutputSectionOff accessors.

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

llvm-svn: 250326
This commit is contained in:
Rui Ueyama 2015-10-14 21:00:23 +00:00
parent 9da4c8ed75
commit edffd91bce
3 changed files with 11 additions and 13 deletions

View File

@ -75,8 +75,8 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
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)

View File

@ -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;

View File

@ -143,7 +143,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
} 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(InputSection<ELFT> *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<ELFT>::uintX_t lld::elf2::getSymVA(const SymbolBody &S) {
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 ObjectFile<ELFT> &File,
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>::writeLocalSymbols(uint8_t *&Buf) {
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;
}