diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-01-10 17:08:13 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-01-10 17:08:13 +0000 |
commit | b7e2ee2abab757db5d31c4b54ad41705ec504ed5 (patch) | |
tree | 44883baea403d60ff79dedcbb680b8825c7d6c51 | |
parent | dc83e7795f21ef720404d3a29adda8c2df8447ff (diff) | |
download | bcm5719-llvm-b7e2ee2abab757db5d31c4b54ad41705ec504ed5.tar.gz bcm5719-llvm-b7e2ee2abab757db5d31c4b54ad41705ec504ed5.zip |
Give local binding to VER_NDX_LOCAL symbols.
We were already dropping them from the dynamic symbol table, but the
regular symbol table was still listing them as globals.
llvm-svn: 291573
-rw-r--r-- | lld/ELF/Symbols.cpp | 16 | ||||
-rw-r--r-- | lld/ELF/Symbols.h | 1 | ||||
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 10 | ||||
-rw-r--r-- | lld/test/ELF/version-script-anonymous-local.s | 19 |
4 files changed, 34 insertions, 12 deletions
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 48e45dae550..289bc18487a 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -294,10 +294,22 @@ InputFile *LazyObject::fetch() { return createObjectFile(MBRef); } -bool Symbol::includeInDynsym() const { +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 && !body()->isUndefined()) + return STB_LOCAL; + if (Config->NoGnuUnique && Binding == STB_GNU_UNIQUE) + return STB_GLOBAL; + return Binding; +} + +bool Symbol::includeInDynsym() const { + if (computeBinding() == STB_LOCAL) return false; - return (ExportDynamic && VersionId != VER_NDX_LOCAL) || body()->isShared() || + return ExportDynamic || body()->isShared() || (body()->isUndefined() && Config->Shared); } diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index d5667927d9f..af85dc2b121 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -420,6 +420,7 @@ struct Symbol { unsigned InVersionScript : 1; bool includeInDynsym() const; + uint8_t computeBinding() const; bool isWeak() const { return Binding == llvm::ELF::STB_WEAK; } // This field is used to store the Symbol's SymbolBody. This instantiation of diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index f9be1f21565..8490385c153 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1061,15 +1061,7 @@ static bool sortMipsSymbols(const SymbolBody *L, const SymbolBody *R) { } static uint8_t getSymbolBinding(SymbolBody *Body) { - Symbol *S = Body->symbol(); - if (Config->Relocatable) - return S->Binding; - uint8_t Visibility = S->Visibility; - if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) - return STB_LOCAL; - if (Config->NoGnuUnique && S->Binding == STB_GNU_UNIQUE) - return STB_GLOBAL; - return S->Binding; + return Body->symbol()->computeBinding(); } template <class ELFT> void SymbolTableSection<ELFT>::finalize() { diff --git a/lld/test/ELF/version-script-anonymous-local.s b/lld/test/ELF/version-script-anonymous-local.s index dfe52b8c461..3716b7ac99c 100644 --- a/lld/test/ELF/version-script-anonymous-local.s +++ b/lld/test/ELF/version-script-anonymous-local.s @@ -3,7 +3,24 @@ # RUN: echo "{ global: foo; local: bar; };" > %t.script # RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so -# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s +# RUN: llvm-readobj -dyn-symbols -t %t.so | FileCheck %s + +# CHECK: Symbols [ +# CHECK: Name: bar +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Local + +# CHECK: Name: foo +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global + +# CHECK: Name: zed +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global + # CHECK: DynamicSymbols [ # CHECK-NEXT: Symbol { |