[lld] r263365 - Redefine isGnuIfunc as a member function of SymbolBody.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 12 20:40:15 PST 2016


Author: ruiu
Date: Sat Mar 12 22:40:14 2016
New Revision: 263365

URL: http://llvm.org/viewvc/llvm-project?rev=263365&view=rev
Log:
Redefine isGnuIfunc as a member function of SymbolBody.

Modified:
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=263365&r1=263364&r2=263365&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Sat Mar 12 22:40:14 2016
@@ -81,6 +81,12 @@ getSymVA(const SymbolBody &Body, typenam
   llvm_unreachable("invalid symbol kind");
 }
 
+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 ELFFile<ELFT>::uintX_t
 SymbolBody::getVA(typename ELFFile<ELFT>::uintX_t Addend) const {
@@ -245,6 +251,11 @@ 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=263365&r1=263364&r2=263365&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Sat Mar 12 22:40:14 2016
@@ -74,6 +74,8 @@ public:
   bool isLocal() const { return IsLocal; }
   bool isUsedInRegularObj() const { return IsUsedInRegularObj; }
 
+  template <class ELFT> bool isGnuIfunc() const;
+
   // Returns the symbol name.
   StringRef getName() const { return Name; }
 

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=263365&r1=263364&r2=263365&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sat Mar 12 22:40:14 2016
@@ -70,12 +70,6 @@ template <unsigned N> static void checkA
   error("improper alignment for relocation " + S);
 }
 
-template <class ELFT> bool isGnuIFunc(const SymbolBody &S) {
-  if (auto *SS = dyn_cast<DefinedElf<ELFT>>(&S))
-    return SS->Sym.getType() == STT_GNU_IFUNC;
-  return false;
-}
-
 namespace {
 class X86TargetInfo final : public TargetInfo {
 public:
@@ -315,7 +309,7 @@ bool TargetInfo::refersToGotEntry(uint32
 template <class ELFT>
 TargetInfo::PltNeed TargetInfo::needsPlt(uint32_t Type,
                                          const SymbolBody &S) const {
-  if (isGnuIFunc<ELFT>(S))
+  if (S.isGnuIfunc<ELFT>())
     return Plt_Explicit;
   if (canBePreempted(S) && needsPltImpl(Type))
     return Plt_Explicit;
@@ -1806,11 +1800,6 @@ template <class ELFT> typename ELFFile<E
   return 0;
 }
 
-template bool isGnuIFunc<ELF32LE>(const SymbolBody &S);
-template bool isGnuIFunc<ELF32BE>(const SymbolBody &S);
-template bool isGnuIFunc<ELF64LE>(const SymbolBody &S);
-template bool isGnuIFunc<ELF64BE>(const SymbolBody &S);
-
 template uint32_t getMipsGpAddr<ELF32LE>();
 template uint32_t getMipsGpAddr<ELF32BE>();
 template uint64_t getMipsGpAddr<ELF64LE>();

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=263365&r1=263364&r2=263365&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Mar 12 22:40:14 2016
@@ -366,7 +366,7 @@ void Writer<ELFT>::scanRelocs(
     // 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 (isGnuIFunc<ELFT>(Body)) {
+    if (Body.isGnuIfunc<ELFT>()) {
       if (Body.isInPlt())
         continue;
       Out<ELFT>::Plt->addEntry(Body);




More information about the llvm-commits mailing list