diff --git a/lld/test/ELF/Inputs/gc-sections-shared.s b/lld/test/ELF/Inputs/gc-sections-shared.s new file mode 100644 index 000000000000..e7017f566411 --- /dev/null +++ b/lld/test/ELF/Inputs/gc-sections-shared.s @@ -0,0 +1,3 @@ +.global baz +.type baz, @function +baz: diff --git a/lld/test/ELF/gc-sections-shared.s b/lld/test/ELF/gc-sections-shared.s index 3bb8ff12fc26..80b3d61165cc 100644 --- a/lld/test/ELF/gc-sections-shared.s +++ b/lld/test/ELF/gc-sections-shared.s @@ -1,8 +1,10 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared.s -o %t3.o # RUN: ld.lld -shared %t2.o -o %t2.so +# RUN: ld.lld -shared %t3.o -o %t3.so # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so +# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so %t3.so # RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck %s # This test the property that we have a needed line for every undefined. @@ -45,9 +47,21 @@ # CHECK-NEXT: Other: # CHECK-NEXT: Section: .text # CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: baz +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } # CHECK-NEXT: ] -# CHECK: NEEDED Shared library: [{{.*}}.so] +# CHECK-NOT: NEEDED +# CHECK: NEEDED Shared library: [{{.*}}2.so] +# CHECK: NEEDED Shared library: [{{.*}}3.so] +# CHECK-NOT: NEEDED .section .text.foo, "ax" .globl foo @@ -62,6 +76,7 @@ ret .section .text._start, "ax" .globl _start _start: +call baz ret .section .text.unused, "ax"