From 7ede54310ad9d88552c92cf189d1a9f236f8411b Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 13 Mar 2016 04:40:14 +0000 Subject: [PATCH] Redefine isGnuIfunc as a member function of SymbolBody. llvm-svn: 263365 --- lld/ELF/Symbols.cpp | 11 +++++++++++ lld/ELF/Symbols.h | 2 ++ lld/ELF/Target.cpp | 13 +------------ lld/ELF/Writer.cpp | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index aea97c4..8a7a18c 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -81,6 +81,12 @@ getSymVA(const SymbolBody &Body, typename ELFFile::uintX_t &Addend) { llvm_unreachable("invalid symbol kind"); } +template bool SymbolBody::isGnuIfunc() const { + if (auto *D = dyn_cast>(this)) + return D->Sym.getType() == STT_GNU_IFUNC; + return false; +} + template typename ELFFile::uintX_t SymbolBody::getVA(typename ELFFile::uintX_t Addend) const { @@ -245,6 +251,11 @@ std::string elf::demangle(StringRef Name) { #endif } +template bool SymbolBody::template isGnuIfunc() const; +template bool SymbolBody::template isGnuIfunc() const; +template bool SymbolBody::template isGnuIfunc() const; +template bool SymbolBody::template isGnuIfunc() const; + template uint32_t SymbolBody::template getVA(uint32_t) const; template uint32_t SymbolBody::template getVA(uint32_t) const; template uint64_t SymbolBody::template getVA(uint64_t) const; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 82dd820..e72c717 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -74,6 +74,8 @@ public: bool isLocal() const { return IsLocal; } bool isUsedInRegularObj() const { return IsUsedInRegularObj; } + template bool isGnuIfunc() const; + // Returns the symbol name. StringRef getName() const { return Name; } diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index ed89aad..eee5f3b 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -70,12 +70,6 @@ template static void checkAlignment(uint64_t V, uint32_t Type) { error("improper alignment for relocation " + S); } -template bool isGnuIFunc(const SymbolBody &S) { - if (auto *SS = dyn_cast>(&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_t Type) const { return false; } template TargetInfo::PltNeed TargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { - if (isGnuIFunc(S)) + if (S.isGnuIfunc()) return Plt_Explicit; if (canBePreempted(S) && needsPltImpl(Type)) return Plt_Explicit; @@ -1806,11 +1800,6 @@ template typename ELFFile::uintX_t getMipsGpAddr() { return 0; } -template bool isGnuIFunc(const SymbolBody &S); -template bool isGnuIFunc(const SymbolBody &S); -template bool isGnuIFunc(const SymbolBody &S); -template bool isGnuIFunc(const SymbolBody &S); - template uint32_t getMipsGpAddr(); template uint32_t getMipsGpAddr(); template uint64_t getMipsGpAddr(); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 81d8c04..9e063da 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -366,7 +366,7 @@ void Writer::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(Body)) { + if (Body.isGnuIfunc()) { if (Body.isInPlt()) continue; Out::Plt->addEntry(Body); -- 2.7.4