1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: echo "LIBSAMPLE_1.0 { global: a; local: *; };" > %t.script
4# RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; };" >> %t.script
5# RUN: echo "LIBSAMPLE_3.0 { global: c; local: *; };" >> %t.script
6# RUN: ld.lld --hash-style=sysv --version-script %t.script -shared -soname shared %t.o -o %t.so
7# RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s
8
9# DSO:       VersionSymbols [
10# DSO-NEXT:   Symbol {
11# DSO-NEXT:     Version: 0
12# DSO-NEXT:     Name:
13# DSO-NEXT:   }
14# DSO-NEXT:   Symbol {
15# DSO-NEXT:     Version: 2
16# DSO-NEXT:     Name: a@@LIBSAMPLE_1.0
17# DSO-NEXT:   }
18# DSO-NEXT:   Symbol {
19# DSO-NEXT:     Version: 3
20# DSO-NEXT:     Name: b@@LIBSAMPLE_2.0
21# DSO-NEXT:   }
22# DSO-NEXT:   Symbol {
23# DSO-NEXT:     Version: 4
24# DSO-NEXT:     Name: c@@LIBSAMPLE_3.0
25# DSO-NEXT:   }
26# DSO-NEXT: ]
27# DSO-NEXT: VersionDefinitions [
28# DSO-NEXT:   Definition {
29# DSO-NEXT:     Version: 1
30# DSO-NEXT:     Flags [ (0x1)
31# DSO-NEXT:       Base (0x1)
32# DSO-NEXT:     ]
33# DSO-NEXT:     Index: 1
34# DSO-NEXT:     Hash: 127830196
35# DSO-NEXT:     Name: shared
36# DSO-NEXT:     Predecessors: []
37# DSO-NEXT:   }
38# DSO-NEXT:   Definition {
39# DSO-NEXT:     Version: 1
40# DSO-NEXT:     Flags [ (0x0)
41# DSO-NEXT:     ]
42# DSO-NEXT:     Index: 2
43# DSO-NEXT:     Hash: 98457184
44# DSO-NEXT:     Name: LIBSAMPLE_1.0
45# DSO-NEXT:     Predecessors: []
46# DSO-NEXT:   }
47# DSO-NEXT:   Definition {
48# DSO-NEXT:     Version: 1
49# DSO-NEXT:     Flags [ (0x0)
50# DSO-NEXT:     ]
51# DSO-NEXT:     Index: 3
52# DSO-NEXT:     Hash: 98456416
53# DSO-NEXT:     Name: LIBSAMPLE_2.0
54# DSO-NEXT:     Predecessors: []
55# DSO-NEXT:   }
56# DSO-NEXT:   Definition {
57# DSO-NEXT:     Version: 1
58# DSO-NEXT:     Flags [ (0x0)
59# DSO-NEXT:     ]
60# DSO-NEXT:     Index: 4
61# DSO-NEXT:     Hash: 98456672
62# DSO-NEXT:     Name: LIBSAMPLE_3.0
63# DSO-NEXT:     Predecessors: []
64# DSO-NEXT:   }
65# DSO-NEXT: ]
66# DSO-NEXT: VersionRequirements [
67# DSO-NEXT: ]
68
69## Check that we can link agains DSO we produced.
70# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/verdef.s -o %tmain.o
71# RUN: ld.lld --hash-style=sysv %tmain.o %t.so -o %tout
72# RUN: llvm-readobj -V %tout | FileCheck --check-prefix=MAIN %s
73
74# MAIN:      VersionSymbols [
75# MAIN-NEXT:   Symbol {
76# MAIN-NEXT:     Version: 0
77# MAIN-NEXT:     Name:
78# MAIN-NEXT:   }
79# MAIN-NEXT:   Symbol {
80# MAIN-NEXT:     Version: 2
81# MAIN-NEXT:     Name: a@LIBSAMPLE_1.0
82# MAIN-NEXT:   }
83# MAIN-NEXT:   Symbol {
84# MAIN-NEXT:     Version: 3
85# MAIN-NEXT:     Name: b@LIBSAMPLE_2.0
86# MAIN-NEXT:   }
87# MAIN-NEXT:   Symbol {
88# MAIN-NEXT:     Version: 4
89# MAIN-NEXT:     Name: c@LIBSAMPLE_3.0
90# MAIN-NEXT:   }
91# MAIN-NEXT: ]
92# MAIN-NEXT: VersionDefinitions [
93# MAIN-NEXT: ]
94
95# RUN: echo "VERSION {" > %t.script
96# RUN: echo "LIBSAMPLE_1.0 { global: a; local: *; };" >> %t.script
97# RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; };" >> %t.script
98# RUN: echo "LIBSAMPLE_3.0 { global: c; local: *; };" >> %t.script
99# RUN: echo "}" >> %t.script
100# RUN: ld.lld --hash-style=sysv --script %t.script -shared -soname shared %t.o -o %t2.so
101# RUN: llvm-readobj -V --dyn-syms %t2.so | FileCheck --check-prefix=DSO %s
102
103.globl a
104.type  a,@function
105a:
106retq
107
108.globl b
109.type  b,@function
110b:
111retq
112
113.globl c
114.type  c,@function
115c:
116retq
117