[PATCH] D71794: [ELF] Don't special case weak symbols for pie with no shared objects
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 22:08:07 PST 2019
MaskRay updated this revision to Diff 235003.
MaskRay edited the summary of this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
MaskRay added a comment.
Herald added a subscriber: wuzish.
Add reviewers
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71794/new/
https://reviews.llvm.org/D71794
Files:
lld/ELF/Symbols.cpp
lld/test/ELF/ppc32-weak-undef-call.s
lld/test/ELF/weak-undef-no-shared-libs.s
Index: lld/test/ELF/weak-undef-no-shared-libs.s
===================================================================
--- 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, at function
- .weak foo
- .long foo at 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: ]
Index: lld/test/ELF/ppc32-weak-undef-call.s
===================================================================
--- lld/test/ELF/ppc32-weak-undef-call.s
+++ 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
Index: lld/ELF/Symbols.cpp
===================================================================
--- lld/ELF/Symbols.cpp
+++ 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71794.235003.patch
Type: text/x-patch
Size: 2888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191221/3f4c348c/attachment.bin>
More information about the llvm-commits
mailing list