summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputSection.cpp4
-rw-r--r--lld/ELF/InputSection.h10
-rw-r--r--lld/ELF/OutputSections.cpp10
3 files changed, 11 insertions, 13 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index d1236fd1a58..980466b61f9 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -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)
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index eea4c2df5e6..e65232fd277 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -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;
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 0b531c011a6..5f489997f39 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -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;
}
OpenPOWER on IntegriCloud