diff options
author | Fangrui Song <maskray@google.com> | 2019-08-11 17:03:00 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-08-11 17:03:00 +0000 |
commit | cfdd4589f144448381212922c0def4374926d70c (patch) | |
tree | 23d82adee4786eec83423d251a498c3bf08a71d2 | |
parent | 635eda8bb0fde5eae101f98586146125dbbf550c (diff) | |
download | bcm5719-llvm-cfdd4589f144448381212922c0def4374926d70c.tar.gz bcm5719-llvm-cfdd4589f144448381212922c0def4374926d70c.zip |
[ELF] Remove redundant isDefined() in Symbol::computeBinding() and delete 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
-rw-r--r-- | lld/ELF/Relocations.cpp | 3 | ||||
-rw-r--r-- | lld/ELF/Symbols.cpp | 5 |
2 files changed, 3 insertions, 5 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 6dd1b4d6825..c3288ffb7fc 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -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; diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 6652f485dfa..84bc1587fac 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -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; |