mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-10 19:34:29 +00:00
ELF2: Remove {set,get}OutputSection accessors.
These accessors didn't provide any additional value over a public member variable, too. llvm-svn: 250328
This commit is contained in:
parent
18426935ac
commit
80edbbbdf8
@ -76,7 +76,7 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
ObjectFile<ELFT> *File = getFile();
|
||||
ELFFile<ELFT> &EObj = File->getObj();
|
||||
uint8_t *Base = Buf + OutputSectionOff;
|
||||
uintX_t BaseAddr = OutSec->getVA() + OutputSectionOff;
|
||||
uintX_t BaseAddr = OutputSection->getVA() + OutputSectionOff;
|
||||
// Iterate over all relocation sections that apply to this section.
|
||||
for (const Elf_Shdr *RelSec : RelocSections) {
|
||||
if (RelSec->sh_type == SHT_RELA)
|
||||
|
@ -48,15 +48,13 @@ public:
|
||||
return std::max<uintX_t>(Header->sh_addralign, 1);
|
||||
}
|
||||
|
||||
void setOutputSection(OutputSection<ELFT> *O) { OutSec = O; }
|
||||
OutputSection<ELFT> *getOutputSection() const { return OutSec; }
|
||||
|
||||
// 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;
|
||||
OutputSection<ELFT> *OutputSection = nullptr;
|
||||
|
||||
static InputSection<ELFT> Discarded;
|
||||
|
||||
@ -70,8 +68,6 @@ private:
|
||||
// The file this section is from.
|
||||
ObjectFile<ELFT> *File;
|
||||
|
||||
OutputSection<ELFT> *OutSec = nullptr;
|
||||
|
||||
const Elf_Shdr *Header;
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,6 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
|
||||
const InputSection<ELFT> &C = Rel.C;
|
||||
const Elf_Rel &RI = Rel.RI;
|
||||
OutputSection<ELFT> *OutSec = C.getOutputSection();
|
||||
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
|
||||
const ObjectFile<ELFT> &File = *C.getFile();
|
||||
SymbolBody *Body = File.getSymbolBody(SymIndex);
|
||||
@ -143,7 +142,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.OutputSectionOff + OutSec->getVA();
|
||||
P->r_offset = RI.r_offset + C.OutputSection->getVA() + C.OutputSectionOff;
|
||||
if (CanBePreempted)
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
|
||||
IsMips64EL);
|
||||
@ -385,7 +384,7 @@ OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t sh_type,
|
||||
template <class ELFT>
|
||||
void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) {
|
||||
Sections.push_back(C);
|
||||
C->setOutputSection(this);
|
||||
C->OutputSection = this;
|
||||
uint32_t Align = C->getAlign();
|
||||
if (Align > this->Header.sh_addralign)
|
||||
this->Header.sh_addralign = Align;
|
||||
@ -409,8 +408,7 @@ typename ELFFile<ELFT>::uintX_t lld::elf2::getSymVA(const SymbolBody &S) {
|
||||
case SymbolBody::DefinedRegularKind: {
|
||||
const auto &DR = cast<DefinedRegular<ELFT>>(S);
|
||||
const InputSection<ELFT> *SC = &DR.Section;
|
||||
OutputSection<ELFT> *OS = SC->getOutputSection();
|
||||
return OS->getVA() + SC->OutputSectionOff + DR.Sym.st_value;
|
||||
return SC->OutputSection->getVA() + SC->OutputSectionOff + DR.Sym.st_value;
|
||||
}
|
||||
case SymbolBody::DefinedCommonKind:
|
||||
return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS;
|
||||
@ -453,8 +451,8 @@ lld::elf2::getLocalRelTarget(const ObjectFile<ELFT> &File,
|
||||
if (Section == &InputSection<ELFT>::Discarded)
|
||||
return 0;
|
||||
|
||||
OutputSection<ELFT> *OutSec = Section->getOutputSection();
|
||||
return OutSec->getVA() + Section->OutputSectionOff + Sym->st_value;
|
||||
return Section->OutputSection->getVA() + Section->OutputSectionOff +
|
||||
Sym->st_value;
|
||||
}
|
||||
|
||||
// Returns true if a symbol can be replaced at load-time by a symbol
|
||||
@ -628,7 +626,7 @@ void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) {
|
||||
&Sym, File->getSymbolTable(), File->getSymbolTableShndx());
|
||||
ArrayRef<InputSection<ELFT> *> Sections = File->getSections();
|
||||
const InputSection<ELFT> *Section = Sections[SecIndex];
|
||||
const OutputSection<ELFT> *OutSec = Section->getOutputSection();
|
||||
const OutputSection<ELFT> *OutSec = Section->OutputSection;
|
||||
ESym->st_shndx = OutSec->getSectionIndex();
|
||||
VA += OutSec->getVA() + Section->OutputSectionOff;
|
||||
}
|
||||
@ -696,7 +694,7 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *&Buf) {
|
||||
ESym->st_value = getSymVA<ELFT>(*Body);
|
||||
|
||||
if (Section)
|
||||
OutSec = Section->getOutputSection();
|
||||
OutSec = Section->OutputSection;
|
||||
|
||||
if (isa<DefinedAbsolute<ELFT>>(Body))
|
||||
ESym->st_shndx = SHN_ABS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user