Simplify. NFC.

llvm-svn: 256846
This commit is contained in:
Rui Ueyama 2016-01-05 16:35:48 +00:00
parent f53b1b7fde
commit c7b073a23a
1 changed files with 8 additions and 9 deletions

View File

@ -239,14 +239,13 @@ bool RelocationSection<ELFT>::applyTlsDynamicReloc(SymbolBody *Body,
} }
template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
for (const DynamicReloc<ELFT> &Rel : Relocs) { for (const DynamicReloc<ELFT> &Rel : Relocs) {
auto *P = reinterpret_cast<Elf_Rel *>(Buf); auto *P = reinterpret_cast<Elf_Rel *>(Buf);
Buf += EntrySize; Buf += IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
// Skip placeholder for global dynamic TLS relocation pair. It was already // Skip placeholder for global dynamic TLS relocation pair. It was already
// handled by the previous relocation. // handled by the previous relocation.
if (!Rel.C || !Rel.RI) if (!Rel.C)
continue; continue;
InputSectionBase<ELFT> &C = *Rel.C; InputSectionBase<ELFT> &C = *Rel.C;
@ -262,16 +261,16 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
continue; continue;
bool NeedsCopy = Body && Target->needsCopyRel(Type, *Body); bool NeedsCopy = Body && Target->needsCopyRel(Type, *Body);
bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body); bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body);
bool CanBePreempted = canBePreempted(Body, NeedsGot); bool CBP = canBePreempted(Body, NeedsGot);
bool LazyReloc = Body && Target->supportsLazyRelocations() && bool LazyReloc = Body && Target->supportsLazyRelocations() &&
Target->relocNeedsPlt(Type, *Body); Target->relocNeedsPlt(Type, *Body);
bool IsDynRelative = Type == Target->getRelativeReloc(); bool IsDynRelative = Type == Target->getRelativeReloc();
unsigned Sym = CanBePreempted ? Body->DynamicSymbolTableIndex : 0; unsigned Sym = CBP ? Body->DynamicSymbolTableIndex : 0;
unsigned Reloc; unsigned Reloc;
if (!CanBePreempted && Body && isGnuIFunc<ELFT>(*Body)) if (!CBP && Body && isGnuIFunc<ELFT>(*Body))
Reloc = Target->getIRelativeReloc(); Reloc = Target->getIRelativeReloc();
else if (!CanBePreempted || IsDynRelative) else if (!CBP || IsDynRelative)
Reloc = Target->getRelativeReloc(); Reloc = Target->getRelativeReloc();
else if (LazyReloc) else if (LazyReloc)
Reloc = Target->getPltReloc(); Reloc = Target->getPltReloc();
@ -289,7 +288,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body); P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
else if (NeedsCopy) else if (NeedsCopy)
P->r_offset = Out<ELFT>::Bss->getVA() + P->r_offset = Out<ELFT>::Bss->getVA() +
dyn_cast<SharedSymbol<ELFT>>(Body)->OffsetInBss; cast<SharedSymbol<ELFT>>(Body)->OffsetInBss;
else else
P->r_offset = C.getOffset(RI.r_offset) + C.OutSec->getVA(); P->r_offset = C.getOffset(RI.r_offset) + C.OutSec->getVA();
@ -300,7 +299,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
uintX_t Addend; uintX_t Addend;
if (NeedsCopy) if (NeedsCopy)
Addend = 0; Addend = 0;
else if (CanBePreempted || IsDynRelative) else if (CBP || IsDynRelative)
Addend = OrigAddend; Addend = OrigAddend;
else if (Body) else if (Body)
Addend = getSymVA<ELFT>(*Body) + OrigAddend; Addend = getSymVA<ELFT>(*Body) + OrigAddend;