[lld] r252717 - Move relocate to the base class.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 02:18:52 PST 2015


Author: rafael
Date: Wed Nov 11 04:18:52 2015
New Revision: 252717

URL: http://llvm.org/viewvc/llvm-project?rev=252717&view=rev
Log:
Move relocate to the base class.

This is in preparation for adding .eh_frame support. They will have
another input section type but will also need to be relocated.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=252717&r1=252716&r2=252717&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Nov 11 04:18:52 2015
@@ -82,7 +82,7 @@ bool InputSection<ELFT>::classof(const I
 
 template <class ELFT>
 template <bool isRela>
-void InputSection<ELFT>::relocate(
+void InputSectionBase<ELFT>::relocate(
     uint8_t *Buf, uint8_t *BufEnd,
     iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels,
     const ObjectFile<ELFT> &File, uintX_t BaseAddr) {
@@ -143,11 +143,11 @@ template <class ELFT> void InputSection<
   // Iterate over all relocation sections that apply to this section.
   for (const Elf_Shdr *RelSec : RelocSections) {
     if (RelSec->sh_type == SHT_RELA)
-      relocate(Base, Base + Data.size(), EObj.relas(RelSec), *this->File,
-               BaseAddr);
+      this->relocate(Base, Base + Data.size(), EObj.relas(RelSec), *this->File,
+                     BaseAddr);
     else
-      relocate(Base, Base + Data.size(), EObj.rels(RelSec), *this->File,
-               BaseAddr);
+      this->relocate(Base, Base + Data.size(), EObj.rels(RelSec), *this->File,
+                     BaseAddr);
   }
 }
 

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=252717&r1=252716&r2=252717&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Nov 11 04:18:52 2015
@@ -69,6 +69,12 @@ public:
   // Returns a section that Rel is pointing to. Used by the garbage collector.
   InputSectionBase<ELFT> *getRelocTarget(const Elf_Rel &Rel);
   InputSectionBase<ELFT> *getRelocTarget(const Elf_Rela &Rel);
+
+  template <bool isRela>
+  void relocate(uint8_t *Buf, uint8_t *BufEnd,
+                llvm::iterator_range<
+                    const llvm::object::Elf_Rel_Impl<ELFT, isRela> *> Rels,
+                const ObjectFile<ELFT> &File, uintX_t BaseAddr);
 };
 
 template <class ELFT>
@@ -116,13 +122,6 @@ public:
   uint64_t OutSecOff = 0;
 
   static bool classof(const InputSectionBase<ELFT> *S);
-
-private:
-  template <bool isRela>
-  void relocate(uint8_t *Buf, uint8_t *BufEnd,
-                llvm::iterator_range<
-                    const llvm::object::Elf_Rel_Impl<ELFT, isRela> *> Rels,
-                const ObjectFile<ELFT> &File, uintX_t BaseAddr);
 };
 
 } // namespace elf2




More information about the llvm-commits mailing list