forked from OSchip/llvm-project
[ELF] Don't special case weak symbols for pie with no shared objects
D59275 added the following clause to Symbol::includeInDynsym() if (isUndefWeak() && Config->Pie && SharedFiles.empty()) return false; D59549 explored the possibility to generalize it for -no-pie. GNU ld's rules are architecture dependent and partly controlled by -z {,no-}dynamic-undefined-weak. Our attempts to mimic its rules are actually half-baked and don't provide perceivable benefits (it can save a few more weak undefined symbols in .dynsym in a -static-pie executable). Let's just delete the rule for simplicity. We will expect cosmetic inconsistencies with ld.bfd in certain -static-pie scenarios. This permits a simplification in D71795. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D71794
This commit is contained in:
parent
46e2f89364
commit
96e2376d02
|
@ -278,11 +278,6 @@ bool Symbol::includeInDynsym() const {
|
|||
if (computeBinding() == STB_LOCAL)
|
||||
return false;
|
||||
|
||||
// If a PIE binary was not linked against any shared libraries, then we can
|
||||
// safely drop weak undef symbols from .dynsym.
|
||||
if (isUndefWeak() && config->pie && sharedFiles.empty())
|
||||
return false;
|
||||
|
||||
return isUndefined() || isShared() || exportDynamic || inDynamicList;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# REQUIRES: ppc
|
||||
# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=EXE %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PDE %s
|
||||
# RUN: ld.lld -pie %t.o -o %t
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=EXE %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PIC %s
|
||||
# RUN: ld.lld -shared %t.o -o %t
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=SHARED %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PIC %s
|
||||
|
||||
## It does not really matter how we fixup it, but we cannot overflow and
|
||||
## should not generate a call stub (this would waste space).
|
||||
# EXE: bl .+0
|
||||
# PDE: bl .+0
|
||||
|
||||
## With -shared, create a call stub. ld.bfd produces bl .+0
|
||||
# SHARED: bl .+4
|
||||
# SHARED: 00000000.plt_pic32.foo:
|
||||
## With -pie or -shared, create a call stub. ld.bfd produces bl .+0
|
||||
# PIC: bl .+4
|
||||
# PIC: 00000000.plt_pic32.foo:
|
||||
|
||||
.weak foo
|
||||
bl foo
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// REQUIRES: x86
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
||||
// RUN: ld.lld -pie %t.o -o %t
|
||||
// RUN: llvm-readobj -V --dyn-syms %t | FileCheck %s
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
.type foo,@function
|
||||
.weak foo
|
||||
.long foo@gotpcrel
|
||||
|
||||
// Test that an entry for weak undefined symbols is NOT emitted in .dynsym as
|
||||
// the PIE was not linked with any shared libraries. There are other tests which
|
||||
// ensure that the weak undefined symbols do get emitted in .dynsym for PIEs
|
||||
// linked against dynamic libraries.
|
||||
|
||||
|
||||
// CHECK: DynamicSymbols [
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name:
|
||||
// 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: ]
|
Loading…
Reference in New Issue