diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 88b8ff4c9d7b..9557b93a11c2 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -573,7 +573,7 @@ bool lld::elf2::canBePreempted(const SymbolBody *Body, bool NeedsGot) { } if (!Config->Shared) return false; - return Body->getMostConstrainingVisibility() == STV_DEFAULT; + return Body->getVisibility() == STV_DEFAULT; } template void OutputSection::writeTo(uint8_t *Buf) { @@ -645,7 +645,7 @@ template bool lld::elf2::includeInSymtab(const SymbolBody &B) { } bool lld::elf2::includeInDynamicSymtab(const SymbolBody &B) { - uint8_t V = B.getMostConstrainingVisibility(); + uint8_t V = B.getVisibility(); if (V != STV_DEFAULT && V != STV_PROTECTED) return false; @@ -803,7 +803,7 @@ void SymbolTableSection::writeGlobalSymbols(uint8_t *Buf) { ESym->setBindingAndType(getSymbolBinding(Body), Type); ESym->st_size = Size; - ESym->setVisibility(Body->getMostConstrainingVisibility()); + ESym->setVisibility(Body->getVisibility()); ESym->st_value = getSymVA(*Body); if (Section) @@ -820,7 +820,7 @@ void SymbolTableSection::writeGlobalSymbols(uint8_t *Buf) { template uint8_t SymbolTableSection::getSymbolBinding(SymbolBody *Body) { - uint8_t Visibility = Body->getMostConstrainingVisibility(); + uint8_t Visibility = Body->getVisibility(); if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) return STB_LOCAL; if (const auto *EBody = dyn_cast>(Body)) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index e92c046c1e59..5a1596a4bee6 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -40,10 +40,8 @@ template int SymbolBody::compare(SymbolBody *Other) { if (L > R) return -Other->compare(this); - uint8_t LV = getMostConstrainingVisibility(); - uint8_t RV = Other->getMostConstrainingVisibility(); - MostConstrainingVisibility = getMinVisibility(LV, RV); - Other->MostConstrainingVisibility = MostConstrainingVisibility; + Visibility = Other->Visibility = + getMinVisibility(Visibility, Other->Visibility); IsUsedInRegularObj |= Other->IsUsedInRegularObj; Other->IsUsedInRegularObj |= IsUsedInRegularObj; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 632e8c63179f..1571335701c5 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -83,9 +83,7 @@ public: // Returns the symbol name. StringRef getName() const { return Name; } - uint8_t getMostConstrainingVisibility() const { - return MostConstrainingVisibility; - } + uint8_t getVisibility() const { return Visibility; } unsigned getDynamicSymbolTableIndex() const { return DynamicSymbolTableIndex; @@ -116,15 +114,15 @@ public: protected: SymbolBody(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility, bool IsTLS) - : SymbolKind(K), IsWeak(IsWeak), MostConstrainingVisibility(Visibility), - IsTLS(IsTLS), Name(Name) { + : SymbolKind(K), IsWeak(IsWeak), Visibility(Visibility), IsTLS(IsTLS), + Name(Name) { IsUsedInRegularObj = K != SharedKind && K != LazyKind; IsUsedInDynamicReloc = 0; } const unsigned SymbolKind : 8; unsigned IsWeak : 1; - unsigned MostConstrainingVisibility : 2; + unsigned Visibility : 2; unsigned IsUsedInRegularObj : 1; unsigned IsUsedInDynamicReloc : 1; unsigned IsTLS : 1;