[lld] r259887 - Centralize most calls to setUsedInDynamicReloc.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 07:03:10 PST 2016
Author: rafael
Date: Fri Feb 5 09:03:10 2016
New Revision: 259887
URL: http://llvm.org/viewvc/llvm-project?rev=259887&view=rev
Log:
Centralize most calls to setUsedInDynamicReloc.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259887&r1=259886&r2=259887&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Feb 5 09:03:10 2016
@@ -216,6 +216,14 @@ RelocationSection<ELFT>::RelocationSecti
}
template <class ELFT>
+void RelocationSection<ELFT>::addReloc(const DynamicReloc<ELFT> &Reloc) {
+ SymbolBody *Sym = Reloc.Sym;
+ if (!Reloc.UseSymVA && Sym)
+ Sym->setUsedInDynamicReloc();
+ Relocs.push_back(Reloc);
+}
+
+template <class ELFT>
static typename ELFFile<ELFT>::uintX_t
getOffset(const DynamicReloc<ELFT> &Rel) {
typedef typename ELFFile<ELFT>::uintX_t uintX_t;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=259887&r1=259886&r2=259887&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Feb 5 09:03:10 2016
@@ -255,7 +255,7 @@ class RelocationSection final : public O
public:
RelocationSection(StringRef Name, bool IsRela);
- void addReloc(const DynamicReloc<ELFT> &Reloc) { Relocs.push_back(Reloc); }
+ void addReloc(const DynamicReloc<ELFT> &Reloc);
unsigned getRelocOffset();
void finalize() override;
void writeTo(uint8_t *Buf) override;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259887&r1=259886&r2=259887&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Feb 5 09:03:10 2016
@@ -235,7 +235,6 @@ static bool handleTlsRelocation(unsigned
{Target->TlsModuleIndexRel, DynamicReloc<ELFT>::Off_GTlsIndex, Body});
Out<ELFT>::RelaDyn->addReloc(
{Target->TlsOffsetRel, DynamicReloc<ELFT>::Off_GTlsOffset, Body});
- Body->setUsedInDynamicReloc();
return true;
}
if (!canBePreempted(Body, true))
@@ -306,7 +305,6 @@ void Writer<ELFT>::scanRelocs(
continue;
if (Target->needsCopyRel(Type, *B)) {
B->NeedsCopy = true;
- B->setUsedInDynamicReloc();
Out<ELFT>::RelaDyn->addReloc(
{Target->CopyRel, DynamicReloc<ELFT>::Off_Bss, B});
continue;
@@ -317,7 +315,6 @@ void Writer<ELFT>::scanRelocs(
// to the symbol go through the PLT. This is true even for a local
// symbol, although local symbols normally do not require PLT entries.
if (Body && isGnuIFunc<ELFT>(*Body)) {
- Body->setUsedInDynamicReloc();
if (Body->isInGot())
continue;
Out<ELFT>::Plt->addEntry(Body);
@@ -354,9 +351,6 @@ void Writer<ELFT>::scanRelocs(
Out<ELFT>::RelaDyn->addReloc(
{Target->GotRel, DynamicReloc<ELFT>::Off_Got, Body});
}
-
- if (canBePreempted(Body, /*NeedsGot=*/true))
- Body->setUsedInDynamicReloc();
continue;
}
@@ -372,6 +366,7 @@ void Writer<ELFT>::scanRelocs(
// See "Global Offset Table" in Chapter 5 in the following document
// for detailed description:
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
+ // FIXME: Why do we need to set this here?
Body->setUsedInDynamicReloc();
continue;
}
@@ -379,8 +374,6 @@ void Writer<ELFT>::scanRelocs(
bool CBP = canBePreempted(Body, /*NeedsGot=*/true);
bool Dynrel = Config->Shared && !Target->isRelRelative(Type) &&
!Target->isSizeRel(Type);
- if (CBP)
- Body->setUsedInDynamicReloc();
if (CBP || Dynrel) {
uint32_t DynType;
if (CBP)
@@ -413,7 +406,6 @@ void Writer<ELFT>::scanRelocs(
if (canBePreempted(Body, /*NeedsGot=*/false)) {
// We don't know anything about the finaly symbol. Just ask the dynamic
// linker to handle the relocation for us.
- Body->setUsedInDynamicReloc();
Out<ELFT>::RelaDyn->addReloc({Target->getDynRel(Type), &C, RI.r_offset,
false, Body, getAddend<ELFT>(RI)});
continue;
More information about the llvm-commits
mailing list