mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:13:38 +08:00
Prefer symbols from .o over .so.
This matches the behavior of gold and bfd ld. llvm-svn: 258102
This commit is contained in:
@@ -39,8 +39,9 @@ static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
|
||||
template <class ELFT> int SymbolBody::compare(SymbolBody *Other) {
|
||||
typedef typename ELFFile<ELFT>::uintX_t uintX_t;
|
||||
assert(!isLazy() && !Other->isLazy());
|
||||
std::pair<bool, bool> L(isDefined(), !isWeak());
|
||||
std::pair<bool, bool> R(Other->isDefined(), !Other->isWeak());
|
||||
std::tuple<bool, bool, bool> L(isDefined(), !isShared(), !isWeak());
|
||||
std::tuple<bool, bool, bool> R(Other->isDefined(), !Other->isShared(),
|
||||
!Other->isWeak());
|
||||
|
||||
// Normalize
|
||||
if (L > R)
|
||||
@@ -54,11 +55,7 @@ template <class ELFT> int SymbolBody::compare(SymbolBody *Other) {
|
||||
|
||||
if (L != R)
|
||||
return -1;
|
||||
if (!L.first || !L.second)
|
||||
return 1;
|
||||
if (isShared())
|
||||
return -1;
|
||||
if (Other->isShared())
|
||||
if (!std::get<0>(L) || !std::get<1>(L) || !std::get<2>(L))
|
||||
return 1;
|
||||
if (isCommon()) {
|
||||
if (!Other->isCommon())
|
||||
|
||||
2
lld/test/ELF/Inputs/resolution-shared.s
Normal file
2
lld/test/ELF/Inputs/resolution-shared.s
Normal file
@@ -0,0 +1,2 @@
|
||||
.global foo
|
||||
foo:
|
||||
15
lld/test/ELF/resolution-shared.s
Normal file
15
lld/test/ELF/resolution-shared.s
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/resolution-shared.s -o %t2.o
|
||||
// RUN: ld.lld %t2.o -o %t2.so -shared
|
||||
// RUN: ld.lld %t.o %t2.so -o %t3 -shared
|
||||
// RUN: llvm-readobj -t %t3 | FileCheck %s
|
||||
// REQUIRES: x86
|
||||
|
||||
.weak foo
|
||||
foo:
|
||||
|
||||
// CHECK: Symbol {
|
||||
// CHECK: Name: foo
|
||||
// CHECK-NEXT: Value:
|
||||
// CHECK-NEXT: Size:
|
||||
// CHECK-NEXT: Binding: Weak
|
||||
Reference in New Issue
Block a user