Centralize most calls to setUsedInDynamicReloc.

llvm-svn: 259887
This commit is contained in:
Rafael Espindola 2016-02-05 15:03:10 +00:00
parent d389c7a3cc
commit d30eb7d77d
3 changed files with 10 additions and 10 deletions

View File

@ -215,6 +215,14 @@ RelocationSection<ELFT>::RelocationSection(StringRef Name, bool IsRela)
this->Header.sh_addralign = sizeof(uintX_t); this->Header.sh_addralign = sizeof(uintX_t);
} }
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> template <class ELFT>
static typename ELFFile<ELFT>::uintX_t static typename ELFFile<ELFT>::uintX_t
getOffset(const DynamicReloc<ELFT> &Rel) { getOffset(const DynamicReloc<ELFT> &Rel) {

View File

@ -255,7 +255,7 @@ class RelocationSection final : public OutputSectionBase<ELFT> {
public: public:
RelocationSection(StringRef Name, bool IsRela); RelocationSection(StringRef Name, bool IsRela);
void addReloc(const DynamicReloc<ELFT> &Reloc) { Relocs.push_back(Reloc); } void addReloc(const DynamicReloc<ELFT> &Reloc);
unsigned getRelocOffset(); unsigned getRelocOffset();
void finalize() override; void finalize() override;
void writeTo(uint8_t *Buf) override; void writeTo(uint8_t *Buf) override;

View File

@ -235,7 +235,6 @@ static bool handleTlsRelocation(unsigned Type, SymbolBody *Body,
{Target->TlsModuleIndexRel, DynamicReloc<ELFT>::Off_GTlsIndex, Body}); {Target->TlsModuleIndexRel, DynamicReloc<ELFT>::Off_GTlsIndex, Body});
Out<ELFT>::RelaDyn->addReloc( Out<ELFT>::RelaDyn->addReloc(
{Target->TlsOffsetRel, DynamicReloc<ELFT>::Off_GTlsOffset, Body}); {Target->TlsOffsetRel, DynamicReloc<ELFT>::Off_GTlsOffset, Body});
Body->setUsedInDynamicReloc();
return true; return true;
} }
if (!canBePreempted(Body, true)) if (!canBePreempted(Body, true))
@ -306,7 +305,6 @@ void Writer<ELFT>::scanRelocs(
continue; continue;
if (Target->needsCopyRel(Type, *B)) { if (Target->needsCopyRel(Type, *B)) {
B->NeedsCopy = true; B->NeedsCopy = true;
B->setUsedInDynamicReloc();
Out<ELFT>::RelaDyn->addReloc( Out<ELFT>::RelaDyn->addReloc(
{Target->CopyRel, DynamicReloc<ELFT>::Off_Bss, B}); {Target->CopyRel, DynamicReloc<ELFT>::Off_Bss, B});
continue; continue;
@ -317,7 +315,6 @@ void Writer<ELFT>::scanRelocs(
// to the symbol go through the PLT. This is true even for a local // to the symbol go through the PLT. This is true even for a local
// symbol, although local symbols normally do not require PLT entries. // symbol, although local symbols normally do not require PLT entries.
if (Body && isGnuIFunc<ELFT>(*Body)) { if (Body && isGnuIFunc<ELFT>(*Body)) {
Body->setUsedInDynamicReloc();
if (Body->isInGot()) if (Body->isInGot())
continue; continue;
Out<ELFT>::Plt->addEntry(Body); Out<ELFT>::Plt->addEntry(Body);
@ -354,9 +351,6 @@ void Writer<ELFT>::scanRelocs(
Out<ELFT>::RelaDyn->addReloc( Out<ELFT>::RelaDyn->addReloc(
{Target->GotRel, DynamicReloc<ELFT>::Off_Got, Body}); {Target->GotRel, DynamicReloc<ELFT>::Off_Got, Body});
} }
if (canBePreempted(Body, /*NeedsGot=*/true))
Body->setUsedInDynamicReloc();
continue; continue;
} }
@ -372,6 +366,7 @@ void Writer<ELFT>::scanRelocs(
// See "Global Offset Table" in Chapter 5 in the following document // See "Global Offset Table" in Chapter 5 in the following document
// for detailed description: // for detailed description:
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
// FIXME: Why do we need to set this here?
Body->setUsedInDynamicReloc(); Body->setUsedInDynamicReloc();
continue; continue;
} }
@ -379,8 +374,6 @@ void Writer<ELFT>::scanRelocs(
bool CBP = canBePreempted(Body, /*NeedsGot=*/true); bool CBP = canBePreempted(Body, /*NeedsGot=*/true);
bool Dynrel = Config->Shared && !Target->isRelRelative(Type) && bool Dynrel = Config->Shared && !Target->isRelRelative(Type) &&
!Target->isSizeRel(Type); !Target->isSizeRel(Type);
if (CBP)
Body->setUsedInDynamicReloc();
if (CBP || Dynrel) { if (CBP || Dynrel) {
uint32_t DynType; uint32_t DynType;
if (CBP) if (CBP)
@ -413,7 +406,6 @@ void Writer<ELFT>::scanRelocs(
if (canBePreempted(Body, /*NeedsGot=*/false)) { if (canBePreempted(Body, /*NeedsGot=*/false)) {
// We don't know anything about the finaly symbol. Just ask the dynamic // We don't know anything about the finaly symbol. Just ask the dynamic
// linker to handle the relocation for us. // linker to handle the relocation for us.
Body->setUsedInDynamicReloc();
Out<ELFT>::RelaDyn->addReloc({Target->getDynRel(Type), &C, RI.r_offset, Out<ELFT>::RelaDyn->addReloc({Target->getDynRel(Type), &C, RI.r_offset,
false, Body, getAddend<ELFT>(RI)}); false, Body, getAddend<ELFT>(RI)});
continue; continue;