diff options
| -rw-r--r-- | lld/ELF/InputSection.cpp | 31 | ||||
| -rw-r--r-- | lld/ELF/InputSection.h | 25 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 7 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.h | 8 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 14 | 
5 files changed, 34 insertions, 51 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index d634e7ce44f..b529957c862 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -113,19 +113,18 @@ InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() {  // to update symbol table offset and section index for each relocation. So we  // copy relocations one by one.  template <class ELFT> -template <bool isRela> +template <class RelTy>  void InputSection<ELFT>::copyRelocations(uint8_t *Buf, -                                         RelIteratorRange<isRela> Rels) { -  typedef Elf_Rel_Impl<ELFT, isRela> RelType; +                                         iterator_range<const RelTy *> Rels) {    InputSectionBase<ELFT> *RelocatedSection = getRelocatedSection(); -  for (const RelType &Rel : Rels) { +  for (const RelTy &Rel : Rels) {      uint32_t SymIndex = Rel.getSymbol(Config->Mips64EL);      uint32_t Type = Rel.getType(Config->Mips64EL);      SymbolBody &Body = this->File->getSymbolBody(SymIndex).repl(); -    RelType *P = reinterpret_cast<RelType *>(Buf); -    Buf += sizeof(RelType); +    RelTy *P = reinterpret_cast<RelTy *>(Buf); +    Buf += sizeof(RelTy);      P->r_offset = RelocatedSection->getOffset(Rel.r_offset);      P->setSymbolAndType(Body.DynsymIndex, Type, Config->Mips64EL); @@ -149,11 +148,10 @@ static uint32_t getMipsPairType(const RelTy *Rel, const SymbolBody &Sym) {  }  template <class ELFT> -template <bool isRela> -uint8_t *InputSectionBase<ELFT>::findMipsPairedReloc( -    uint8_t *Buf, -    const Elf_Rel_Impl<ELFT, isRela> *Rel, -    const Elf_Rel_Impl<ELFT, isRela> *End) { +template <class RelTy> +uint8_t *InputSectionBase<ELFT>::findMipsPairedReloc(uint8_t *Buf, +                                                     const RelTy *Rel, +                                                     const RelTy *End) {    uint32_t SymIndex = Rel->getSymbol(Config->Mips64EL);    SymbolBody &Sym = File->getSymbolBody(SymIndex).repl();    uint32_t Type = getMipsPairType(Rel, Sym); @@ -162,10 +160,10 @@ uint8_t *InputSectionBase<ELFT>::findMipsPairedReloc(    // itself and addend of paired relocation. ABI requires to compute such    // combined addend in case of REL relocation record format only.    // See p. 4-17 at ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf -  if (isRela || Type == R_MIPS_NONE) +  if (RelTy::IsRela || Type == R_MIPS_NONE)      return nullptr; -  for (const Elf_Rel_Impl<ELFT, isRela> *RI = Rel; RI != End; ++RI) { +  for (const RelTy *RI = Rel; RI != End; ++RI) {      if (RI->getType(Config->Mips64EL) != Type)        continue;      if (RI->getSymbol(Config->Mips64EL) != SymIndex) @@ -179,13 +177,12 @@ uint8_t *InputSectionBase<ELFT>::findMipsPairedReloc(  }  template <class ELFT> -template <bool isRela> +template <class RelTy>  void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd, -                                      RelIteratorRange<isRela> Rels) { -  typedef Elf_Rel_Impl<ELFT, isRela> RelType; +                                      iterator_range<const RelTy *> Rels) {    size_t Num = Rels.end() - Rels.begin();    for (size_t I = 0; I < Num; ++I) { -    const RelType &RI = *(Rels.begin() + I); +    const RelTy &RI = *(Rels.begin() + I);      uintX_t Offset = getOffset(RI.r_offset);      if (Offset == (uintX_t)-1)        continue; diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 71c7060a219..3549bd5de82 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -75,19 +75,14 @@ public:    InputSectionBase<ELFT> *getRelocTarget(const Elf_Rel &Rel) const;    InputSectionBase<ELFT> *getRelocTarget(const Elf_Rela &Rel) const; -  template <bool isRela> -  using RelIteratorRange = -      llvm::iterator_range<const llvm::object::Elf_Rel_Impl<ELFT, isRela> *>; - -  template <bool isRela> -  void relocate(uint8_t *Buf, uint8_t *BufEnd, RelIteratorRange<isRela> Rels); +  template <class RelTy> +  void relocate(uint8_t *Buf, uint8_t *BufEnd, +                llvm::iterator_range<const RelTy *> Rels);  private: -  template <bool isRela> -  uint8_t * -  findMipsPairedReloc(uint8_t *Buf, -                      const llvm::object::Elf_Rel_Impl<ELFT, isRela> *Rel, -                      const llvm::object::Elf_Rel_Impl<ELFT, isRela> *End); +  template <class RelTy> +  uint8_t *findMipsPairedReloc(uint8_t *Buf, const RelTy *Rel, +                               const RelTy *End);  };  template <class ELFT> @@ -173,12 +168,8 @@ public:    InputSectionBase<ELFT> *getRelocatedSection();  private: -  template <bool isRela> -  using RelIteratorRange = -      llvm::iterator_range<const llvm::object::Elf_Rel_Impl<ELFT, isRela> *>; - -  template <bool isRela> -  void copyRelocations(uint8_t *Buf, RelIteratorRange<isRela> Rels); +  template <class RelTy> +  void copyRelocations(uint8_t *Buf, llvm::iterator_range<const RelTy *> Rels);    // Called by ICF to merge two input sections.    void replace(InputSection<ELFT> *Other); diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 5163fe23a73..1f72e123cd3 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1089,10 +1089,9 @@ static typename ELFFile<ELFT>::uintX_t readEntryLength(ArrayRef<uint8_t> D) {  }  template <class ELFT> -template <bool IsRela> -void EHOutputSection<ELFT>::addSectionAux( -    EHInputSection<ELFT> *S, -    iterator_range<const Elf_Rel_Impl<ELFT, IsRela> *> Rels) { +template <class RelTy> +void EHOutputSection<ELFT>::addSectionAux(EHInputSection<ELFT> *S, +                                          iterator_range<const RelTy *> Rels) {    const endianness E = ELFT::TargetEndianness;    S->OutSec = this; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 415762a6a7f..2cc339c718f 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -324,11 +324,9 @@ public:    EHOutputSection(StringRef Name, uint32_t Type, uintX_t Flags);    void writeTo(uint8_t *Buf) override; -  template <bool IsRela> -  void addSectionAux( -      EHInputSection<ELFT> *S, -      llvm::iterator_range<const llvm::object::Elf_Rel_Impl<ELFT, IsRela> *> -          Rels); +  template <class RelTy> +  void addSectionAux(EHInputSection<ELFT> *S, +                     llvm::iterator_range<const RelTy *> Rels);    void addSection(InputSectionBase<ELFT> *S) override; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9e063da6e87..ca6cc66d602 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -62,9 +62,9 @@ private:    void addPredefinedSections();    bool needsGot(); -  template <bool isRela> +  template <class RelTy>    void scanRelocs(InputSectionBase<ELFT> &C, -                  iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels); +                  iterator_range<const RelTy *> Rels);    void scanRelocs(InputSection<ELFT> &C);    void scanRelocs(InputSectionBase<ELFT> &S, const Elf_Shdr &RelSec); @@ -310,13 +310,11 @@ static bool handleTlsRelocation(uint32_t Type, SymbolBody &Body,  // complicates things for the dynamic linker and means we would have to reserve  // space for the extra PT_LOAD even if we end up not using it.  template <class ELFT> -template <bool isRela> -void Writer<ELFT>::scanRelocs( -    InputSectionBase<ELFT> &C, -    iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels) { -  typedef Elf_Rel_Impl<ELFT, isRela> RelType; +template <class RelTy> +void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, +                              iterator_range<const RelTy *> Rels) {    const elf::ObjectFile<ELFT> &File = *C.getFile(); -  for (const RelType &RI : Rels) { +  for (const RelTy &RI : Rels) {      uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);      SymbolBody &OrigBody = File.getSymbolBody(SymIndex);      SymbolBody &Body = OrigBody.repl();  | 

