forked from OSchip/llvm-project
ELF: Always include undefined DSO symbols in the symbol table.
Fixes check-llvm when bootstrapping. Also remove mostly dead and most likely incorrect logic regarding preemption of weak undefined symbols. llvm-svn: 267314
This commit is contained in:
parent
0da2076ba1
commit
d869a040ee
|
@ -123,13 +123,9 @@ bool SymbolBody::isPreemptible() const {
|
|||
if (!Config->Shared)
|
||||
return false;
|
||||
|
||||
// Undefined symbols in DSOs can only be preempted if they are strong.
|
||||
// Weak symbols just resolve to zero.
|
||||
if (isUndefined())
|
||||
return !isWeak();
|
||||
|
||||
// -Bsymbolic means that not even default visibility symbols can be preempted.
|
||||
if (Config->Bsymbolic || (Config->BsymbolicFunctions && isFunc()))
|
||||
if ((Config->Bsymbolic || (Config->BsymbolicFunctions && isFunc())) &&
|
||||
isDefined())
|
||||
return false;
|
||||
|
||||
// Only default visibility symbols that appear in the dynamic symbol table can
|
||||
|
@ -323,7 +319,8 @@ std::string elf::demangle(StringRef Name) {
|
|||
bool Symbol::includeInDynsym() const {
|
||||
if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
|
||||
return false;
|
||||
return (ExportDynamic && VersionScriptGlobal) || Body->isShared();
|
||||
return (ExportDynamic && VersionScriptGlobal) || Body->isShared() ||
|
||||
Body->isUndefined();
|
||||
}
|
||||
|
||||
template uint32_t SymbolBody::template getVA<ELF32LE>(uint32_t) const;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
||||
# RUN: echo "{ local: *; };" > %t.script
|
||||
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
|
||||
# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s
|
||||
|
||||
# CHECK: DynamicSymbols [
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: @ (0)
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: Undefined (0x0)
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: bar@ (1)
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Weak (0x2)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: Undefined (0x0)
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: foo@ (5)
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Global (0x1)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: Undefined (0x0)
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ]
|
||||
|
||||
.global foo
|
||||
.weak bar
|
Loading…
Reference in New Issue