[lld] r261069 - Make getOffset a member function of DynamicReloc<ELFT>.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 16 22:08:43 PST 2016
Author: ruiu
Date: Wed Feb 17 00:08:42 2016
New Revision: 261069
URL: http://llvm.org/viewvc/llvm-project?rev=261069&view=rev
Log:
Make getOffset a member function of DynamicReloc<ELFT>.
Logically it belongs to DynamicReloc, and it is more readable to
be a member of the class.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=261069&r1=261068&r2=261069&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Feb 17 00:08:42 2016
@@ -225,25 +225,21 @@ void RelocationSection<ELFT>::addReloc(c
}
template <class ELFT>
-static typename ELFFile<ELFT>::uintX_t
-getOffset(const DynamicReloc<ELFT> &Rel) {
- typedef typename ELFFile<ELFT>::uintX_t uintX_t;
- SymbolBody *Sym = Rel.Sym;
- switch (Rel.OKind) {
- case DynamicReloc<ELFT>::Off_GTlsIndex:
+typename ELFFile<ELFT>::uintX_t DynamicReloc<ELFT>::getOffset() const {
+ switch (OKind) {
+ case Off_GTlsIndex:
return Out<ELFT>::Got->getGlobalDynAddr(*Sym);
- case DynamicReloc<ELFT>::Off_GTlsOffset:
+ case Off_GTlsOffset:
return Out<ELFT>::Got->getGlobalDynAddr(*Sym) + sizeof(uintX_t);
- case DynamicReloc<ELFT>::Off_LTlsIndex:
+ case Off_LTlsIndex:
return Out<ELFT>::Got->getTlsIndexVA();
- case DynamicReloc<ELFT>::Off_Sec:
- return Rel.OffsetSec->getOffset(Rel.OffsetInSec) +
- Rel.OffsetSec->OutSec->getVA();
- case DynamicReloc<ELFT>::Off_Bss:
+ case Off_Sec:
+ return OffsetSec->getOffset(OffsetInSec) + OffsetSec->OutSec->getVA();
+ case Off_Bss:
return cast<SharedSymbol<ELFT>>(Sym)->OffsetInBss + Out<ELFT>::Bss->getVA();
- case DynamicReloc<ELFT>::Off_Got:
+ case Off_Got:
return Sym->getGotVA<ELFT>();
- case DynamicReloc<ELFT>::Off_GotPlt:
+ case Off_GotPlt:
return Sym->getGotPltVA<ELFT>();
}
llvm_unreachable("Invalid offset kind");
@@ -265,7 +261,7 @@ template <class ELFT> void RelocationSec
reinterpret_cast<Elf_Rela *>(P)->r_addend = Rel.Addend + VA;
}
- P->r_offset = getOffset(Rel);
+ P->r_offset = Rel.getOffset();
uint32_t SymIdx = (!Rel.UseSymVA && Sym) ? Sym->DynsymIndex : 0;
P->setSymbolAndType(SymIdx, Rel.Type, Config->Mips64EL);
}
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=261069&r1=261068&r2=261069&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Wed Feb 17 00:08:42 2016
@@ -212,6 +212,8 @@ template <class ELFT> struct DynamicRelo
: Type(Type), OKind(Off_Sec), OffsetSec(OffsetSec),
OffsetInSec(OffsetInSec), TargetSec(TargetSec),
OffsetInTargetSec(OffsetInTargetSec), Addend(Addend) {}
+
+ uintX_t getOffset() const;
};
template <class ELFT>
More information about the llvm-commits
mailing list