[ELF] Generalize symbol type handling.
SymbolBody constructor and friends take isFunc and isTLS boolean arguments.
ELF symbols have already a type so than be easily passed as argument.
If we want to support another type, this scheme is not good enough, that is,
the current code logic would require passing another `bool isObject` around.
Up to two argument, this stretching exercise was a little bit goofy but
still acceptable, but with more types to support, is just too much, IMHO.
Change the code so that the type is passed instead.
Differential Revision: http://reviews.llvm.org/D17871
llvm-svn: 262684
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index a1e936e..49304e4 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -61,7 +61,7 @@
auto *SS = cast<SharedSymbol<ELFT>>(this);
if (!SS->NeedsCopyOrPltAddr)
return 0;
- if (SS->IsFunc)
+ if (SS->isFunc())
return getPltVA<ELFT>();
else
return Out<ELFT>::Bss->getVA() + SS->OffsetInBss;
@@ -161,25 +161,24 @@
}
Defined::Defined(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility,
- bool IsTls, bool IsFunction)
- : SymbolBody(K, Name, IsWeak, Visibility, IsTls, IsFunction) {}
+ uint8_t Type)
+ : SymbolBody(K, Name, IsWeak, Visibility, Type) {}
DefinedBitcode::DefinedBitcode(StringRef Name, bool IsWeak)
- : Defined(DefinedBitcodeKind, Name, IsWeak, STV_DEFAULT, false, false) {}
+ : Defined(DefinedBitcodeKind, Name, IsWeak, STV_DEFAULT, 0 /* Type */) {}
bool DefinedBitcode::classof(const SymbolBody *S) {
return S->kind() == DefinedBitcodeKind;
}
Undefined::Undefined(SymbolBody::Kind K, StringRef N, bool IsWeak,
- uint8_t Visibility, bool IsTls)
- : SymbolBody(K, N, IsWeak, Visibility, IsTls, /*IsFunction*/ false),
+ uint8_t Visibility, uint8_t Type)
+ : SymbolBody(K, N, IsWeak, Visibility, Type),
CanKeepUndefined(false) {}
Undefined::Undefined(StringRef N, bool IsWeak, uint8_t Visibility,
bool CanKeepUndefined)
- : Undefined(SymbolBody::UndefinedKind, N, IsWeak, Visibility,
- /*IsTls*/ false) {
+ : Undefined(SymbolBody::UndefinedKind, N, IsWeak, Visibility, 0 /* Type */) {
this->CanKeepUndefined = CanKeepUndefined;
}
@@ -187,7 +186,7 @@
UndefinedElf<ELFT>::UndefinedElf(StringRef N, const Elf_Sym &Sym)
: Undefined(SymbolBody::UndefinedElfKind, N,
Sym.getBinding() == llvm::ELF::STB_WEAK, Sym.getVisibility(),
- Sym.getType() == llvm::ELF::STT_TLS),
+ Sym.getType()),
Sym(Sym) {}
template <typename ELFT>
@@ -195,13 +194,13 @@
OutputSectionBase<ELFT> &Section,
uint8_t Visibility)
: Defined(SymbolBody::DefinedSyntheticKind, N, false, Visibility,
- /*IsTls*/ false, /*IsFunction*/ false),
+ 0 /* Type */),
Value(Value), Section(Section) {}
DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment,
bool IsWeak, uint8_t Visibility)
: Defined(SymbolBody::DefinedCommonKind, N, IsWeak, Visibility,
- /*IsTls*/ false, /*IsFunction*/ false) {
+ 0 /* Type */) {
MaxAlignment = Alignment;
this->Size = Size;
}