forked from OSchip/llvm-project
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
This commit is contained in:
parent
dc83e7795f
commit
b7e2ee2aba
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue