From: Rafael Espindola Date: Fri, 26 Feb 2016 14:33:23 +0000 (+0000) Subject: Refactor multiple calls to canBePreempted. X-Git-Tag: llvmorg-3.9.0-rc1~13121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a350e266aa70925727cf543cc161a285bf860122;p=platform%2Fupstream%2Fllvm.git Refactor multiple calls to canBePreempted. llvm-svn: 262018 --- diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index bcf5d5e..9ac5514 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -272,10 +272,11 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, } uintX_t SymVA = Body->getVA(); + bool CBP = canBePreempted(Body); if (Target->needsPlt(Type, *Body)) { SymVA = Body->getPltVA(); } else if (Target->needsGot(Type, *Body)) { - if (Config->EMachine == EM_MIPS && !canBePreempted(Body)) + if (Config->EMachine == EM_MIPS && !CBP) // Under some conditions relocations against non-local symbols require // entries in the local part of MIPS GOT. In that case we need an entry // initialized by full address of the symbol. @@ -289,7 +290,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, continue; } else if (Target->isTlsDynRel(Type, *Body)) { continue; - } else if (Target->isSizeRel(Type) && canBePreempted(Body)) { + } else if (Target->isSizeRel(Type) && CBP) { // A SIZE relocation is supposed to set a symbol size, but if a symbol // can be preempted, the size at runtime may be different than link time. // If that's the case, we leave the field alone rather than filling it diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 524e7cb..b87291f 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -327,6 +327,7 @@ void Writer::scanRelocs( if (Body) Body = Body->repl(); + bool CBP = canBePreempted(Body); if (handleTlsRelocation(Type, Body, C, RI)) continue; @@ -335,7 +336,7 @@ void Writer::scanRelocs( Body, getAddend(RI)}); // MIPS has a special rule to create GOTs for local symbols. - if (Config->EMachine == EM_MIPS && !canBePreempted(Body) && + if (Config->EMachine == EM_MIPS && !CBP && (Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16)) { // FIXME (simon): Do not add so many redundant entries. Out::Got->addMipsLocalEntry(); @@ -362,7 +363,6 @@ void Writer::scanRelocs( if (Body->isInPlt()) continue; Out::Plt->addEntry(Body); - bool CBP = canBePreempted(Body); if (Target->UseLazyBinding) { Out::GotPlt->addEntry(Body); Out::RelaPlt->addReloc( @@ -419,7 +419,6 @@ void Writer::scanRelocs( continue; } - bool CBP = canBePreempted(Body); bool Dynrel = Config->Shared && !Target->isRelRelative(Type) && !Target->isSizeRel(Type); if (CBP || Dynrel) { @@ -452,7 +451,7 @@ void Writer::scanRelocs( continue; } - if (canBePreempted(Body)) { + if (CBP) { // We don't know anything about the finaly symbol. Just ask the dynamic // linker to handle the relocation for us. Out::RelaDyn->addReloc({Target->getDynRel(Type), &C, RI.r_offset,