diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -278,11 +278,6 @@ 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; } diff --git a/lld/test/ELF/ppc32-weak-undef-call.s b/lld/test/ELF/ppc32-weak-undef-call.s --- a/lld/test/ELF/ppc32-weak-undef-call.s +++ b/lld/test/ELF/ppc32-weak-undef-call.s @@ -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 diff --git a/lld/test/ELF/weak-undef-no-shared-libs.s b/lld/test/ELF/weak-undef-no-shared-libs.s deleted file mode 100644 --- a/lld/test/ELF/weak-undef-no-shared-libs.s +++ /dev/null @@ -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: ]