[lld] r263368 - Use RelTy instead of Elf_Rel_Impl<ELFT, isRela> for readability.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 12 21:06:51 PST 2016
Author: ruiu
Date: Sat Mar 12 23:06:50 2016
New Revision: 263368
URL: http://llvm.org/viewvc/llvm-project?rev=263368&view=rev
Log:
Use RelTy instead of Elf_Rel_Impl<ELFT, isRela> for readability.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=263368&r1=263367&r2=263368&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Sat Mar 12 23:06:50 2016
@@ -113,19 +113,18 @@ InputSectionBase<ELFT> *InputSection<ELF
// 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 Re
}
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>::findMip
// 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>::findMip
}
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;
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=263368&r1=263367&r2=263368&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Sat Mar 12 23:06:50 2016
@@ -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);
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=263368&r1=263367&r2=263368&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Sat Mar 12 23:06:50 2016
@@ -1089,10 +1089,9 @@ static typename ELFFile<ELFT>::uintX_t r
}
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;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=263368&r1=263367&r2=263368&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Sat Mar 12 23:06:50 2016
@@ -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;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=263368&r1=263367&r2=263368&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Mar 12 23:06:50 2016
@@ -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
// 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();
More information about the llvm-commits
mailing list