summaryrefslogtreecommitdiffstats
path: root/lld/test
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-04-25 00:29:13 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-04-25 00:29:13 +0000
commit61376d9bed0a750e5c8acecf08134ec2a2af7164 (patch)
tree908f5c4e52dbd7e13b76f278562e605520d9b657 /lld/test
parent69e68f84682cc4b9888d6794fac404902ddf214c (diff)
downloadbcm5719-llvm-61376d9bed0a750e5c8acecf08134ec2a2af7164.tar.gz
bcm5719-llvm-61376d9bed0a750e5c8acecf08134ec2a2af7164.zip
Bring r329960 back.
The fix is to copy Used when replacing the symbol. Original message: Do not keep shared symbols created from garbage-collected eliminated DSOs. If all references to a DSO happen to be weak, and if the DSO is specified with --as-needed, the DSO is not added to DT_NEEDED. If that happens, we also need to eliminate shared symbols created from the DSO. Otherwise, they become dangling references that point to non-exsitent DSO. Fixes https://bugs.llvm.org/show_bug.cgi?id=36991 Differential Revision: https://reviews.llvm.org/D45536 llvm-svn: 330788
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/ELF/as-needed-weak.s22
-rw-r--r--lld/test/ELF/gc-sections-shared.s72
2 files changed, 32 insertions, 62 deletions
diff --git a/lld/test/ELF/as-needed-weak.s b/lld/test/ELF/as-needed-weak.s
new file mode 100644
index 00000000000..f009c72d6f4
--- /dev/null
+++ b/lld/test/ELF/as-needed-weak.s
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+
+# RUN: echo '.globl foo; .type foo, @function; foo:' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t1.o
+# RUN: ld.lld -shared -o %t1.so -soname libfoo %t1.o
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
+# RUN: ld.lld -o %t.exe %t2.o --as-needed %t1.so
+# RUN: llvm-readelf -dynamic-table -dyn-symbols %t.exe | FileCheck %s
+
+# CHECK-NOT: libfoo
+
+# CHECK: Symbol table of .hash for image:
+# CHECK-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
+# CHECK-NEXT: 1 1: 0000000000000000 0 FUNC WEAK DEFAULT UND foo@
+
+.globl _start
+.weak foo
+
+_start:
+ mov $foo, %eax
+ callq foo
diff --git a/lld/test/ELF/gc-sections-shared.s b/lld/test/ELF/gc-sections-shared.s
index 55b3ef556ce..c0ebf403a33 100644
--- a/lld/test/ELF/gc-sections-shared.s
+++ b/lld/test/ELF/gc-sections-shared.s
@@ -25,6 +25,15 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: qux
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Weak
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: Undefined
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: bar
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
@@ -51,15 +60,6 @@
# CHECK-NEXT: Other:
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: qux
-# CHECK-NEXT: Value:
-# CHECK-NEXT: Size:
-# CHECK-NEXT: Binding: Weak
-# CHECK-NEXT: Type:
-# CHECK-NEXT: Other:
-# CHECK-NEXT: Section: Undefined
-# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NOT: NEEDED
@@ -68,59 +68,7 @@
# Test with %t.o at the end too.
# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t --as-needed %t2.so %t3.so %t4.so %t.o
-# RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck --check-prefix=CHECK2 %s
-
-# CHECK2: DynamicSymbols [
-# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name:
-# CHECK2-NEXT: Value:
-# CHECK2-NEXT: Size:
-# CHECK2-NEXT: Binding: Local
-# CHECK2-NEXT: Type:
-# CHECK2-NEXT: Other:
-# CHECK2-NEXT: Section: Undefined (0x0)
-# CHECK2-NEXT: }
-# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: bar
-# CHECK2-NEXT: Value:
-# CHECK2-NEXT: Size:
-# CHECK2-NEXT: Binding: Global
-# CHECK2-NEXT: Type:
-# CHECK2-NEXT: Other:
-# CHECK2-NEXT: Section: .text
-# CHECK2-NEXT: }
-# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: baz
-# CHECK2-NEXT: Value:
-# CHECK2-NEXT: Size:
-# CHECK2-NEXT: Binding: Global
-# CHECK2-NEXT: Type:
-# CHECK2-NEXT: Other:
-# CHECK2-NEXT: Section: Undefined
-# CHECK2-NEXT: }
-# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: qux
-# CHECK2-NEXT: Value:
-# CHECK2-NEXT: Size:
-# CHECK2-NEXT: Binding: Weak
-# CHECK2-NEXT: Type:
-# CHECK2-NEXT: Other:
-# CHECK2-NEXT: Section: Undefined
-# CHECK2-NEXT: }
-# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: foo
-# CHECK2-NEXT: Value:
-# CHECK2-NEXT: Size:
-# CHECK2-NEXT: Binding: Global
-# CHECK2-NEXT: Type:
-# CHECK2-NEXT: Other:
-# CHECK2-NEXT: Section: .text
-# CHECK2-NEXT: }
-# CHECK2-NEXT: ]
-
-# CHECK2-NOT: NEEDED
-# CHECK2: NEEDED Shared library: [{{.*}}3.so]
-# CHECK2-NOT: NEEDED
+# RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck --check-prefix=CHECK %s
.section .text.foo, "ax"
.globl foo
OpenPOWER on IntegriCloud