[lld] r264267 - Make needsPlt a plain function instead of a template.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 05:55:27 PDT 2016
Author: rafael
Date: Thu Mar 24 07:55:27 2016
New Revision: 264267
URL: http://llvm.org/viewvc/llvm-project?rev=264267&view=rev
Log:
Make needsPlt a plain function instead of a template.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Mar 24 07:55:27 2016
@@ -274,7 +274,7 @@ void InputSectionBase<ELFT>::relocate(ui
if (Config->EMachine == EM_MIPS)
PairedLoc = findMipsPairedReloc(Buf, &RI, Rels.end());
- if (Target->needsPlt<ELFT>(Type, Body)) {
+ if (Target->needsPlt(Type, Body)) {
SymVA = Body.getPltVA<ELFT>() + A;
} else if (Target->needsGot(Type, Body)) {
if (Config->EMachine == EM_MIPS)
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu Mar 24 07:55:27 2016
@@ -112,12 +112,6 @@ bool SymbolBody::isPreemptible() const {
return true;
}
-template <class ELFT> bool SymbolBody::isGnuIfunc() const {
- if (auto *D = dyn_cast<DefinedElf<ELFT>>(this))
- return D->Sym.getType() == STT_GNU_IFUNC;
- return false;
-}
-
template <class ELFT>
typename ELFT::uint SymbolBody::getVA(typename ELFT::uint Addend) const {
typename ELFT::uint OutVA = getSymVA<ELFT>(*this, Addend);
@@ -279,11 +273,6 @@ std::string elf::demangle(StringRef Name
#endif
}
-template bool SymbolBody::template isGnuIfunc<ELF32LE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF32BE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF64LE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF64BE>() const;
-
template uint32_t SymbolBody::template getVA<ELF32LE>(uint32_t) const;
template uint32_t SymbolBody::template getVA<ELF32BE>(uint32_t) const;
template uint64_t SymbolBody::template getVA<ELF64LE>(uint64_t) const;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Thu Mar 24 07:55:27 2016
@@ -74,7 +74,6 @@ public:
bool isLocal() const { return IsLocal; }
bool isUsedInRegularObj() const { return IsUsedInRegularObj; }
bool isPreemptible() const;
- template <class ELFT> bool isGnuIfunc() const;
// Returns the symbol name.
StringRef getName() const { return Name; }
@@ -120,6 +119,7 @@ protected:
MustBeInDynSym(false), NeedsCopyOrPltAddr(false), Name(Name) {
IsFunc = Type == llvm::ELF::STT_FUNC;
IsTls = Type == llvm::ELF::STT_TLS;
+ IsGnuIFunc = Type == llvm::ELF::STT_GNU_IFUNC;
IsUsedInRegularObj = K != SharedKind && K != LazyKind;
}
@@ -144,6 +144,7 @@ public:
unsigned IsTls : 1;
unsigned IsFunc : 1;
+ unsigned IsGnuIFunc : 1;
protected:
StringRef Name;
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Mar 24 07:55:27 2016
@@ -300,10 +300,9 @@ bool TargetInfo::needsPltImpl(uint32_t T
bool TargetInfo::refersToGotEntry(uint32_t Type) const { return false; }
-template <class ELFT>
TargetInfo::PltNeed TargetInfo::needsPlt(uint32_t Type,
const SymbolBody &S) const {
- if (S.isGnuIfunc<ELFT>())
+ if (S.IsGnuIFunc)
return Plt_Explicit;
if (S.isPreemptible() && needsPltImpl(Type))
return Plt_Explicit;
@@ -329,9 +328,8 @@ TargetInfo::PltNeed TargetInfo::needsPlt
// that points to the real function is a dedicated got entry used by the
// plt. That is identified by special relocation types (R_X86_64_JUMP_SLOT,
// R_386_JMP_SLOT, etc).
- if (auto *SS = dyn_cast<SharedSymbol<ELFT>>(&S))
- if (!Config->Pic && SS->Sym.getType() == STT_FUNC &&
- !refersToGotEntry(Type))
+ if (S.isShared())
+ if (!Config->Pic && S.IsFunc && !refersToGotEntry(Type))
return Plt_Implicit;
return Plt_No;
@@ -500,7 +498,7 @@ bool X86TargetInfo::needsGot(uint32_t Ty
return Target->canRelaxTls(Type, &S) && S.isPreemptible();
if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
return !canRelaxTls(Type, &S);
- return Type == R_386_GOT32 || needsPlt<ELF32LE>(Type, S);
+ return Type == R_386_GOT32 || needsPlt(Type, S);
}
bool X86TargetInfo::needsPltImpl(uint32_t Type) const {
@@ -757,7 +755,7 @@ bool X86_64TargetInfo::needsGot(uint32_t
return Target->canRelaxTls(Type, &S) && S.isPreemptible();
if (Type == R_X86_64_GOTTPOFF)
return !canRelaxTls(Type, &S);
- return refersToGotEntry(Type) || needsPlt<ELF64LE>(Type, S);
+ return refersToGotEntry(Type) || needsPlt(Type, S);
}
uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t Type) const {
@@ -1061,7 +1059,7 @@ void PPC64TargetInfo::writePlt(uint8_t *
}
bool PPC64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
- if (needsPlt<ELF64BE>(Type, S))
+ if (needsPlt(Type, S))
return true;
switch (Type) {
@@ -1334,7 +1332,7 @@ bool AArch64TargetInfo::needsGot(uint32_
case R_AARCH64_LD64_GOT_LO12_NC:
return true;
default:
- return needsPlt<ELF64LE>(Type, S);
+ return needsPlt(Type, S);
}
}
@@ -1675,7 +1673,7 @@ bool MipsTargetInfo<ELFT>::needsCopyRelI
template <class ELFT>
bool MipsTargetInfo<ELFT>::needsGot(uint32_t Type, SymbolBody &S) const {
- return needsPlt<ELFT>(Type, S) || refersToGotEntry(Type);
+ return needsPlt(Type, S) || refersToGotEntry(Type);
}
template <class ELFT>
@@ -1830,14 +1828,5 @@ template bool TargetInfo::needsCopyRel<E
const SymbolBody &) const;
template bool TargetInfo::needsCopyRel<ELF64BE>(uint32_t,
const SymbolBody &) const;
-
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF32LE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF32BE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF64LE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF64BE>(uint32_t, const SymbolBody &) const;
}
}
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Mar 24 07:55:27 2016
@@ -59,7 +59,6 @@ public:
virtual bool refersToGotEntry(uint32_t Type) const;
enum PltNeed { Plt_No, Plt_Explicit, Plt_Implicit };
- template <class ELFT>
PltNeed needsPlt(uint32_t Type, const SymbolBody &S) const;
virtual void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=264267&r1=264266&r2=264267&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Mar 24 07:55:27 2016
@@ -359,7 +359,7 @@ void Writer<ELFT>::scanRelocs(InputSecti
// An STT_GNU_IFUNC symbol always uses a PLT entry, and all references
// 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>()) {
+ if (Body.IsGnuIFunc) {
if (Body.isInPlt())
continue;
Out<ELFT>::Plt->addEntry(Body);
@@ -379,7 +379,7 @@ void Writer<ELFT>::scanRelocs(InputSecti
// If a relocation needs PLT, we create a PLT and a GOT slot
// for the symbol.
- TargetInfo::PltNeed NeedPlt = Target->needsPlt<ELFT>(Type, Body);
+ TargetInfo::PltNeed NeedPlt = Target->needsPlt(Type, Body);
if (NeedPlt) {
if (NeedPlt == TargetInfo::Plt_Implicit)
Body.NeedsCopyOrPltAddr = true;
More information about the llvm-commits
mailing list