summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-01-16 19:28:28 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-01-16 19:28:28 +0000
commit62003fbb024862a67837f963c2ac157850848af7 (patch)
tree9518cf61b618f6e3b97a5cbe8e4585d6ec4c8428
parent96753028661c0916577f4f596fb98b024692d418 (diff)
downloadbcm5719-llvm-62003fbb024862a67837f963c2ac157850848af7.tar.gz
bcm5719-llvm-62003fbb024862a67837f963c2ac157850848af7.zip
Inline foot gun into only valid use.
Symbol had both Visibility and getVisibility() and they had different meanings. That is just too easy to get wrong. getVisibility() would compute the visibility of a particular symbol (foo in bar.o), and Visibility stores the computed value we will put in the output. There is only one case when we want what getVisibility() provides, so inline it. llvm-svn: 322590
-rw-r--r--lld/ELF/Relocations.cpp5
-rw-r--r--lld/ELF/Symbols.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 1b956c4a1f5..ce70ef02231 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -744,7 +744,10 @@ template <class ELFT> static void addGotEntry(Symbol &Sym) {
static bool canDefineSymbolInExecutable(Symbol &Sym) {
// If the symbol has default visibility the symbol defined in the
// executable will preempt it.
- if (Sym.getVisibility() == STV_DEFAULT)
+ // Note that we want the visibility of the shared symbol itself, not
+ // the visibility of the symbol in the output file we are producing. That is
+ // why we use Sym.StOther.
+ if ((Sym.StOther & 0x3) == STV_DEFAULT)
return true;
// If we are allowed to break address equality of functions, defining
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 9b720738334..f6e71cc79e4 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -108,7 +108,6 @@ public:
}
StringRef getName() const { return Name; }
- uint8_t getVisibility() const { return StOther & 0x3; }
void parseSymbolVersion();
bool isInGot() const { return GotIndex != -1U; }
OpenPOWER on IntegriCloud