Skip to content

Commit

Permalink
[ELF] Remove redundant isDefined() in Symbol::computeBinding() and de…
Browse files Browse the repository at this point in the history
…lete one redundant call site

After r367869, VER_NDX_LOCAL can only be assigned to Defined and
CommonSymbol.  CommonSymbol becomes Defined after replaceCommonSymbols(),
thus `versionId == VER_NDX_LOCAL` will imply `isDefined()`.

In maybeReportUndefined(), computeBinding() is called when the symbol is
unknown to be Undefined. computeBinding() != STB_LOCAL will always be
true.

llvm-svn: 368536
  • Loading branch information
MaskRay committed Aug 11, 2019
1 parent 635eda8 commit cfdd458
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lld/ELF/Relocations.cpp
Expand Up @@ -770,8 +770,7 @@ static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec,
if (!sym.isUndefined() || sym.isWeak())
return false;

bool canBeExternal = !sym.isLocal() && sym.computeBinding() != STB_LOCAL &&
sym.visibility == STV_DEFAULT;
bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT;
if (config->unresolvedSymbols == UnresolvedPolicy::Ignore && canBeExternal)
return false;

Expand Down
5 changes: 2 additions & 3 deletions lld/ELF/Symbols.cpp
Expand Up @@ -276,9 +276,8 @@ MemoryBufferRef LazyArchive::getMemberBuffer() {
uint8_t Symbol::computeBinding() const {
if (config->relocatable)
return binding;
if (visibility != STV_DEFAULT && visibility != STV_PROTECTED)
return STB_LOCAL;
if (versionId == VER_NDX_LOCAL && isDefined())
if ((visibility != STV_DEFAULT && visibility != STV_PROTECTED) ||
versionId == VER_NDX_LOCAL)
return STB_LOCAL;
if (!config->gnuUnique && binding == STB_GNU_UNIQUE)
return STB_GLOBAL;
Expand Down

0 comments on commit cfdd458

Please sign in to comment.