Remove DefinedElf class.
DefinedElf was a superclass of DefinedRegular and SharedSymbol classes
and represented the notion of defined symbols created for ELF symbols.
It turned out that we didn't use that class often. We had only two
occurrences of dyn_cast'ing to DefinedElf, and both were easily
rewritten without it.
The class was also a bit confusing. The concept of "created for ELF
symbol" is orthogonal to defined/undefined types. However, we had
two distinct classes, DefinedElf and UndefinedElf.
This patch simply removes the class. Now the class hierarchy is one
level shallower.
llvm-svn: 265234
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index b536def..d4f6120 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -143,11 +143,21 @@
}
template <class ELFT> typename ELFT::uint SymbolBody::getSize() const {
- if (auto *B = dyn_cast<DefinedElf<ELFT>>(this))
- return B->Sym.st_size;
+ if (const typename ELFT::Sym *Sym = getElfSym<ELFT>())
+ return Sym->st_size;
return 0;
}
+template <class ELFT> const typename ELFT::Sym *SymbolBody::getElfSym() const {
+ if (auto *S = dyn_cast<DefinedRegular<ELFT>>(this))
+ return &S->Sym;
+ if (auto *S = dyn_cast<SharedSymbol<ELFT>>(this))
+ return &S->Sym;
+ if (auto *S = dyn_cast<UndefinedElf<ELFT>>(this))
+ return &S->Sym;
+ return nullptr;
+}
+
static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
if (VA == STV_DEFAULT)
return VB;
@@ -307,6 +317,11 @@
template uint64_t SymbolBody::template getSize<ELF64LE>() const;
template uint64_t SymbolBody::template getSize<ELF64BE>() const;
+template const ELF32LE::Sym *SymbolBody::template getElfSym<ELF32LE>() const;
+template const ELF32BE::Sym *SymbolBody::template getElfSym<ELF32BE>() const;
+template const ELF64LE::Sym *SymbolBody::template getElfSym<ELF64LE>() const;
+template const ELF64BE::Sym *SymbolBody::template getElfSym<ELF64BE>() const;
+
template uint32_t SymbolBody::template getThunkVA<ELF32LE>() const;
template uint32_t SymbolBody::template getThunkVA<ELF32BE>() const;
template uint64_t SymbolBody::template getThunkVA<ELF64LE>() const;