From 77dbe9a40513affe771fdc88358a6af69645f0be Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 9 Nov 2016 14:39:20 +0000 Subject: [PATCH] Add a convenience getObj method. NFC. llvm-svn: 286370 --- lld/ELF/ICF.cpp | 8 ++++---- lld/ELF/InputSection.cpp | 6 +++--- lld/ELF/InputSection.h | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 8b0beb5..a3e0980 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -218,8 +218,8 @@ bool ICF::equalsConstant(const InputSection *A, for (size_t I = 0, E = A->RelocSections.size(); I != E; ++I) { const Elf_Shdr *RA = A->RelocSections[I]; const Elf_Shdr *RB = B->RelocSections[I]; - ELFFile FileA = A->File->getObj(); - ELFFile FileB = B->File->getObj(); + ELFFile FileA = A->getObj(); + ELFFile FileB = B->getObj(); if (RA->sh_type == SHT_RELA) { if (!relocationEq(check(FileA.relas(RA)), check(FileB.relas(RB)))) return false; @@ -271,8 +271,8 @@ bool ICF::equalsVariable(const InputSection *A, for (size_t I = 0, E = A->RelocSections.size(); I != E; ++I) { const Elf_Shdr *RA = A->RelocSections[I]; const Elf_Shdr *RB = B->RelocSections[I]; - ELFFile FileA = A->File->getObj(); - ELFFile FileB = B->File->getObj(); + ELFFile FileA = A->getObj(); + ELFFile FileB = B->getObj(); if (RA->sh_type == SHT_RELA) { if (!variableEq(A, B, check(FileA.relas(RA)), check(FileB.relas(RB)))) return false; diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 225ff07..b20825a 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -470,9 +470,9 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd) { if (IS && !(IS->Flags & SHF_ALLOC)) { for (const Elf_Shdr *RelSec : IS->RelocSections) { if (RelSec->sh_type == SHT_RELA) - IS->relocateNonAlloc(Buf, check(IS->File->getObj().relas(RelSec))); + IS->relocateNonAlloc(Buf, check(IS->getObj().relas(RelSec))); else - IS->relocateNonAlloc(Buf, check(IS->File->getObj().rels(RelSec))); + IS->relocateNonAlloc(Buf, check(IS->getObj().rels(RelSec))); } return; } @@ -607,7 +607,7 @@ template void EhInputSection::split() { return; if (RelocSection) { - ELFFile Obj = this->File->getObj(); + ELFFile Obj = this->getObj(); if (RelocSection->sh_type == SHT_RELA) split(check(Obj.relas(RelocSection))); else diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 62fc5e6..6e86392 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -119,6 +119,7 @@ public: static InputSectionBase Discarded; ObjectFile *getFile() const { return File; } + llvm::object::ELFFile getObj() const { return File->getObj(); } uintX_t getOffset(const DefinedRegular &Sym) const; InputSectionBase *getLinkOrderDep() const; // Translate an offset in the input section to an offset in the output -- 2.7.4