Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -282,7 +282,7 @@ SymVA = Out::Got->getMipsLocalFullAddr(*Body); else SymVA = Body->getGotVA(); - if (Body->isTls()) + if (Body->IsTls) Type = Target->getTlsGotRel(Type); } else if (!Target->needsCopyRel(Type, *Body) && isa>(*Body)) { Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -955,7 +955,7 @@ return false; if (Body->getVisibility() != STV_DEFAULT) return false; - if (Config->Bsymbolic || (Config->BsymbolicFunctions && Body->isFunc())) + if (Config->Bsymbolic || (Config->BsymbolicFunctions && Body->IsFunc)) return false; return true; } Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -270,7 +270,7 @@ return; } - if (New->isTls() != Existing->isTls()) { + if (New->IsTls != Existing->IsTls) { error("TLS attribute mismatch for symbol: " + conflictMsg(Existing, New)); return; } @@ -331,8 +331,7 @@ L->setWeak(); // FIXME: Do we need to copy more? - if (Undef->isTls()) - L->setTls(); + L->IsTls |= Undef->IsTls; return; } Index: ELF/Symbols.h =================================================================== --- ELF/Symbols.h +++ ELF/Symbols.h @@ -84,8 +84,6 @@ bool isLazy() const { return SymbolKind == LazyKind; } bool isShared() const { return SymbolKind == SharedKind; } bool isUsedInRegularObj() const { return IsUsedInRegularObj; } - bool isFunc() const { return Type == llvm::ELF::STT_FUNC; } - bool isTls() const { return Type == llvm::ELF::STT_TLS; } // Returns the symbol name. StringRef getName() const { return Name; } @@ -131,8 +129,9 @@ SymbolBody(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility, uint8_t Type) : SymbolKind(K), IsWeak(IsWeak), Visibility(Visibility), - MustBeInDynSym(false), NeedsCopyOrPltAddr(false), - Type(Type), Name(Name) { + MustBeInDynSym(false), NeedsCopyOrPltAddr(false), Name(Name) { + IsFunc = Type == llvm::ELF::STT_FUNC; + IsTls = Type == llvm::ELF::STT_TLS; IsUsedInRegularObj = K != SharedKind && K != LazyKind; } @@ -154,9 +153,10 @@ // symbol or if the symbol should point to its plt entry. unsigned NeedsCopyOrPltAddr : 1; -protected: - uint8_t Type; + unsigned IsTls : 1; + unsigned IsFunc : 1; +protected: StringRef Name; Symbol *Backref = nullptr; }; @@ -305,7 +305,7 @@ // OffsetInBss is significant only when needsCopy() is true. uintX_t OffsetInBss = 0; - bool needsCopy() const { return this->NeedsCopyOrPltAddr && !this->isFunc(); } + bool needsCopy() const { return this->NeedsCopyOrPltAddr && !this->IsFunc; } }; // This class represents a symbol defined in an archive file. It is @@ -326,7 +326,6 @@ // was already returned. std::unique_ptr getMember(); - void setTls() { this->Type = llvm::ELF::STT_TLS; } void setWeak() { IsWeak = true; } void setUsedInRegularObj() { IsUsedInRegularObj = true; } Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -61,7 +61,7 @@ auto *SS = cast>(this); if (!SS->NeedsCopyOrPltAddr) return 0; - if (SS->isFunc()) + if (SS->IsFunc) return getPltVA(); else return Out::Bss->getVA() + SS->OffsetInBss; Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -452,7 +452,7 @@ } bool X86TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const { - if (S.isTls() && Type == R_386_TLS_GD) + if (S.IsTls && Type == R_386_TLS_GD) return Target->canRelaxTls(Type, &S) && canBePreempted(&S); if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE) return !canRelaxTls(Type, &S); @@ -523,7 +523,7 @@ } bool X86TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const { - if (Config->Shared || (S && !S->isTls())) + if (Config->Shared || (S && !S->IsTls)) return false; return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM || Type == R_386_TLS_GD || (Type == R_386_TLS_IE && !canBePreempted(S)) || @@ -772,7 +772,7 @@ } bool X86_64TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const { - if (Config->Shared || (S && !S->isTls())) + if (Config->Shared || (S && !S->IsTls)) return false; return Type == R_X86_64_TLSGD || Type == R_X86_64_TLSLD || Type == R_X86_64_DTPOFF32 || @@ -1457,7 +1457,7 @@ } bool AArch64TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const { - if (Config->Shared || (S && !S->isTls())) + if (Config->Shared || (S && !S->IsTls)) return false; // Global-Dynamic relocs can be relaxed to Initial-Exec if the target is Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -268,7 +268,7 @@ return true; } - if (!Body || !Body->isTls()) + if (!Body || !Body->IsTls) return false; if (Target->isTlsGlobalDynamicRel(Type)) { @@ -424,7 +424,7 @@ if (CBP || Dynrel) { uint32_t DynType; if (CBP) - DynType = Body->isTls() ? Target->TlsGotRel : Target->GotRel; + DynType = Body->IsTls ? Target->TlsGotRel : Target->GotRel; else DynType = Target->RelativeRel; Out::RelaDyn->addReloc(