From: Rui Ueyama Date: Sun, 13 Mar 2016 05:06:50 +0000 (+0000) Subject: Use RelTy instead of Elf_Rel_Impl for readability. X-Git-Tag: llvmorg-3.9.0-rc1~11848 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc467e77b8c07b0cdef8b0193d4e99640c4eb84d;p=platform%2Fupstream%2Fllvm.git Use RelTy instead of Elf_Rel_Impl for readability. llvm-svn: 263368 --- diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index d634e7c..b529957 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -113,19 +113,18 @@ InputSectionBase *InputSection::getRelocatedSection() { // to update symbol table offset and section index for each relocation. So we // copy relocations one by one. template -template +template void InputSection::copyRelocations(uint8_t *Buf, - RelIteratorRange Rels) { - typedef Elf_Rel_Impl RelType; + iterator_range Rels) { InputSectionBase *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(Buf); - Buf += sizeof(RelType); + RelTy *P = reinterpret_cast(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 -template -uint8_t *InputSectionBase::findMipsPairedReloc( - uint8_t *Buf, - const Elf_Rel_Impl *Rel, - const Elf_Rel_Impl *End) { +template +uint8_t *InputSectionBase::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::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 *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::findMipsPairedReloc( } template -template +template void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, - RelIteratorRange Rels) { - typedef Elf_Rel_Impl RelType; + iterator_range 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 71c7060..3549bd5 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -75,19 +75,14 @@ public: InputSectionBase *getRelocTarget(const Elf_Rel &Rel) const; InputSectionBase *getRelocTarget(const Elf_Rela &Rel) const; - template - using RelIteratorRange = - llvm::iterator_range *>; - - template - void relocate(uint8_t *Buf, uint8_t *BufEnd, RelIteratorRange Rels); + template + void relocate(uint8_t *Buf, uint8_t *BufEnd, + llvm::iterator_range Rels); private: - template - uint8_t * - findMipsPairedReloc(uint8_t *Buf, - const llvm::object::Elf_Rel_Impl *Rel, - const llvm::object::Elf_Rel_Impl *End); + template + uint8_t *findMipsPairedReloc(uint8_t *Buf, const RelTy *Rel, + const RelTy *End); }; template @@ -173,12 +168,8 @@ public: InputSectionBase *getRelocatedSection(); private: - template - using RelIteratorRange = - llvm::iterator_range *>; - - template - void copyRelocations(uint8_t *Buf, RelIteratorRange Rels); + template + void copyRelocations(uint8_t *Buf, llvm::iterator_range Rels); // Called by ICF to merge two input sections. void replace(InputSection *Other); diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 5163fe2..1f72e12 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1089,10 +1089,9 @@ static typename ELFFile::uintX_t readEntryLength(ArrayRef D) { } template -template -void EHOutputSection::addSectionAux( - EHInputSection *S, - iterator_range *> Rels) { +template +void EHOutputSection::addSectionAux(EHInputSection *S, + iterator_range Rels) { const endianness E = ELFT::TargetEndianness; S->OutSec = this; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 415762a..2cc339c 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 - void addSectionAux( - EHInputSection *S, - llvm::iterator_range *> - Rels); + template + void addSectionAux(EHInputSection *S, + llvm::iterator_range Rels); void addSection(InputSectionBase *S) override; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9e063da..ca6cc66 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -62,9 +62,9 @@ private: void addPredefinedSections(); bool needsGot(); - template + template void scanRelocs(InputSectionBase &C, - iterator_range *> Rels); + iterator_range Rels); void scanRelocs(InputSection &C); void scanRelocs(InputSectionBase &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 -template -void Writer::scanRelocs( - InputSectionBase &C, - iterator_range *> Rels) { - typedef Elf_Rel_Impl RelType; +template +void Writer::scanRelocs(InputSectionBase &C, + iterator_range Rels) { const elf::ObjectFile &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();