// 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);
}
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);
// 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)
}
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;
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>
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);
}
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;
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;
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);
// 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();