diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-02-26 14:33:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-02-26 14:33:23 +0000 |
commit | a350e266aa70925727cf543cc161a285bf860122 (patch) | |
tree | fcd461de2eabc373811236c4dbd9e55824c73c9f | |
parent | 993f0273e3998f8b15a52a2feade074917d20113 (diff) | |
download | bcm5719-llvm-a350e266aa70925727cf543cc161a285bf860122.tar.gz bcm5719-llvm-a350e266aa70925727cf543cc161a285bf860122.zip |
Refactor multiple calls to canBePreempted.
llvm-svn: 262018
-rw-r--r-- | lld/ELF/InputSection.cpp | 5 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index bcf5d5e6f16..9ac5514bb5e 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -272,10 +272,11 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd, } uintX_t SymVA = Body->getVA<ELFT>(); + bool CBP = canBePreempted(Body); if (Target->needsPlt<ELFT>(Type, *Body)) { SymVA = Body->getPltVA<ELFT>(); } 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<ELFT>::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 524e7cb3404..b87291fad00 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -327,6 +327,7 @@ void Writer<ELFT>::scanRelocs( if (Body) Body = Body->repl(); + bool CBP = canBePreempted(Body); if (handleTlsRelocation<ELFT>(Type, Body, C, RI)) continue; @@ -335,7 +336,7 @@ void Writer<ELFT>::scanRelocs( Body, getAddend<ELFT>(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<ELFT>::Got->addMipsLocalEntry(); @@ -362,7 +363,6 @@ void Writer<ELFT>::scanRelocs( if (Body->isInPlt()) continue; Out<ELFT>::Plt->addEntry(Body); - bool CBP = canBePreempted(Body); if (Target->UseLazyBinding) { Out<ELFT>::GotPlt->addEntry(Body); Out<ELFT>::RelaPlt->addReloc( @@ -419,7 +419,6 @@ void Writer<ELFT>::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<ELFT>::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<ELFT>::RelaDyn->addReloc({Target->getDynRel(Type), &C, RI.r_offset, |