• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared.s -o %t3.o
4# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared2.s -o %t4.o
5# RUN: ld.lld -shared %t2.o -o %t2.so
6# RUN: ld.lld -shared %t3.o -o %t3.so
7# RUN: ld.lld -shared %t4.o -o %t4.so
8# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
9# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so %t3.so %t4.so
10# RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck %s
11
12# This test the property that we have a needed line for every undefined.
13# It would also be OK to keep bar2 and the need for %t2.so
14# At the same time, weak symbols should not cause adding DT_NEEDED;
15# this case is checked with symbol qux and %t4.so.
16
17# CHECK-NOT: NEEDED
18# CHECK:     NEEDED Shared library: [{{.*}}3.so]
19# CHECK-NOT: NEEDED
20
21# CHECK:      DynamicSymbols [
22# CHECK-NEXT:   Symbol {
23# CHECK-NEXT:     Name:
24# CHECK-NEXT:     Value:
25# CHECK-NEXT:     Size:
26# CHECK-NEXT:     Binding: Local
27# CHECK-NEXT:     Type:
28# CHECK-NEXT:     Other:
29# CHECK-NEXT:     Section: Undefined (0x0)
30# CHECK-NEXT:   }
31# CHECK-NEXT:   Symbol {
32# CHECK-NEXT:     Name: qux
33# CHECK-NEXT:     Value:
34# CHECK-NEXT:     Size:
35# CHECK-NEXT:     Binding: Weak
36# CHECK-NEXT:     Type:
37# CHECK-NEXT:     Other:
38# CHECK-NEXT:     Section: Undefined
39# CHECK-NEXT:   }
40# CHECK-NEXT:   Symbol {
41# CHECK-NEXT:     Name: bar
42# CHECK-NEXT:     Value:
43# CHECK-NEXT:     Size:
44# CHECK-NEXT:     Binding: Global
45# CHECK-NEXT:     Type:
46# CHECK-NEXT:     Other:
47# CHECK-NEXT:     Section: .text
48# CHECK-NEXT:   }
49# CHECK-NEXT:   Symbol {
50# CHECK-NEXT:     Name: baz
51# CHECK-NEXT:     Value:
52# CHECK-NEXT:     Size:
53# CHECK-NEXT:     Binding: Global
54# CHECK-NEXT:     Type:
55# CHECK-NEXT:     Other:
56# CHECK-NEXT:     Section: Undefined
57# CHECK-NEXT:   }
58# CHECK-NEXT:   Symbol {
59# CHECK-NEXT:     Name: foo
60# CHECK-NEXT:     Value:
61# CHECK-NEXT:     Size:
62# CHECK-NEXT:     Binding: Global
63# CHECK-NEXT:     Type:
64# CHECK-NEXT:     Other:
65# CHECK-NEXT:     Section: .text
66# CHECK-NEXT:   }
67# CHECK-NEXT: ]
68
69# Test with %t.o at the end too.
70# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t --as-needed %t2.so %t3.so %t4.so %t.o
71# RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck --check-prefix=CHECK %s
72
73.section .text.foo, "ax"
74.globl foo
75foo:
76.long bar - .
77
78.section .text.bar, "ax"
79.globl bar
80bar:
81ret
82
83.section .text._start, "ax"
84.globl _start
85.weak qux
86_start:
87.long baz - .
88.long qux - .
89ret
90
91.section .text.unused, "ax"
92.long bar2 - .
93