[lld] r262018 - Refactor multiple calls to canBePreempted.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 06:33:23 PST 2016
Author: rafael
Date: Fri Feb 26 08:33:23 2016
New Revision: 262018
URL: http://llvm.org/viewvc/llvm-project?rev=262018&view=rev
Log:
Refactor multiple calls to canBePreempted.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=262018&r1=262017&r2=262018&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Feb 26 08:33:23 2016
@@ -272,10 +272,11 @@ void InputSectionBase<ELFT>::relocate(ui
}
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(ui
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
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262018&r1=262017&r2=262018&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Feb 26 08:33:23 2016
@@ -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,
More information about the llvm-commits
mailing list