Add a convenience getObj method. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Nov 2016 14:39:20 +0000 (14:39 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Nov 2016 14:39:20 +0000 (14:39 +0000)
llvm-svn: 286370

lld/ELF/ICF.cpp
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h

index 8b0beb5..a3e0980 100644 (file)
@@ -218,8 +218,8 @@ bool ICF<ELFT>::equalsConstant(const InputSection<ELFT> *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<ELFT> FileA = A->File->getObj();
-    ELFFile<ELFT> FileB = B->File->getObj();
+    ELFFile<ELFT> FileA = A->getObj();
+    ELFFile<ELFT> 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<ELFT>::equalsVariable(const InputSection<ELFT> *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<ELFT> FileA = A->File->getObj();
-    ELFFile<ELFT> FileB = B->File->getObj();
+    ELFFile<ELFT> FileA = A->getObj();
+    ELFFile<ELFT> FileB = B->getObj();
     if (RA->sh_type == SHT_RELA) {
       if (!variableEq(A, B, check(FileA.relas(RA)), check(FileB.relas(RB))))
         return false;
index 225ff07..b20825a 100644 (file)
@@ -470,9 +470,9 @@ void InputSectionBase<ELFT>::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 <class ELFT> void EhInputSection<ELFT>::split() {
     return;
 
   if (RelocSection) {
-    ELFFile<ELFT> Obj = this->File->getObj();
+    ELFFile<ELFT> Obj = this->getObj();
     if (RelocSection->sh_type == SHT_RELA)
       split(check(Obj.relas(RelocSection)));
     else
index 62fc5e6..6e86392 100644 (file)
@@ -119,6 +119,7 @@ public:
   static InputSectionBase<ELFT> Discarded;
 
   ObjectFile<ELFT> *getFile() const { return File; }
+  llvm::object::ELFFile<ELFT> getObj() const { return File->getObj(); }
   uintX_t getOffset(const DefinedRegular<ELFT> &Sym) const;
   InputSectionBase *getLinkOrderDep() const;
   // Translate an offset in the input section to an offset in the output