From c7b073a23a92eb6e88111972075bdaeeb29d4d07 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 5 Jan 2016 16:35:48 +0000 Subject: [PATCH] Simplify. NFC. llvm-svn: 256846 --- lld/ELF/OutputSections.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 0d435f3e7ccc..dbe523be158a 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -239,14 +239,13 @@ bool RelocationSection::applyTlsDynamicReloc(SymbolBody *Body, } template void RelocationSection::writeTo(uint8_t *Buf) { - const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); for (const DynamicReloc &Rel : Relocs) { auto *P = reinterpret_cast(Buf); - Buf += EntrySize; + Buf += IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); // Skip placeholder for global dynamic TLS relocation pair. It was already // handled by the previous relocation. - if (!Rel.C || !Rel.RI) + if (!Rel.C) continue; InputSectionBase &C = *Rel.C; @@ -262,16 +261,16 @@ template void RelocationSection::writeTo(uint8_t *Buf) { continue; bool NeedsCopy = Body && Target->needsCopyRel(Type, *Body); bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body); - bool CanBePreempted = canBePreempted(Body, NeedsGot); + bool CBP = canBePreempted(Body, NeedsGot); bool LazyReloc = Body && Target->supportsLazyRelocations() && Target->relocNeedsPlt(Type, *Body); bool IsDynRelative = Type == Target->getRelativeReloc(); - unsigned Sym = CanBePreempted ? Body->DynamicSymbolTableIndex : 0; + unsigned Sym = CBP ? Body->DynamicSymbolTableIndex : 0; unsigned Reloc; - if (!CanBePreempted && Body && isGnuIFunc(*Body)) + if (!CBP && Body && isGnuIFunc(*Body)) Reloc = Target->getIRelativeReloc(); - else if (!CanBePreempted || IsDynRelative) + else if (!CBP || IsDynRelative) Reloc = Target->getRelativeReloc(); else if (LazyReloc) Reloc = Target->getPltReloc(); @@ -289,7 +288,7 @@ template void RelocationSection::writeTo(uint8_t *Buf) { P->r_offset = Out::Got->getEntryAddr(*Body); else if (NeedsCopy) P->r_offset = Out::Bss->getVA() + - dyn_cast>(Body)->OffsetInBss; + cast>(Body)->OffsetInBss; else P->r_offset = C.getOffset(RI.r_offset) + C.OutSec->getVA(); @@ -300,7 +299,7 @@ template void RelocationSection::writeTo(uint8_t *Buf) { uintX_t Addend; if (NeedsCopy) Addend = 0; - else if (CanBePreempted || IsDynRelative) + else if (CBP || IsDynRelative) Addend = OrigAddend; else if (Body) Addend = getSymVA(*Body) + OrigAddend;