[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / verdef-defaultver.s
blob661f6c4e7da42e44954c4533bad4d689c9ff1662
1 # REQUIRES: x86
3 # RUN: rm -rf %t && split-file %s %t && cd %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/verdef-defaultver.s -o %t1
5 # RUN: echo "V1 { global: a; b; local: *; };" > %t.script
6 # RUN: echo "V2 { global: b; c; } V1;" >> %t.script
7 # RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script --undefined-version -o %t.so
8 # RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s
10 # DSO: DynamicSymbols [
11 # DSO-NEXT: Symbol {
12 # DSO-NEXT: Name:
13 # DSO-NEXT: Value: 0x0
14 # DSO-NEXT: Size: 0
15 # DSO-NEXT: Binding: Local
16 # DSO-NEXT: Type: None
17 # DSO-NEXT: Other: 0
18 # DSO-NEXT: Section: Undefined
19 # DSO-NEXT: }
20 # DSO-NEXT: Symbol {
21 # DSO-NEXT: Name: b@V1
22 # DSO-NEXT: Value: 0x12E9
23 # DSO-NEXT: Size: 0
24 # DSO-NEXT: Binding: Global
25 # DSO-NEXT: Type: Function
26 # DSO-NEXT: Other: 0
27 # DSO-NEXT: Section: .text
28 # DSO-NEXT: }
29 # DSO-NEXT: Symbol {
30 # DSO-NEXT: Name: b@@V2
31 # DSO-NEXT: Value: 0x12EA
32 # DSO-NEXT: Size: 0
33 # DSO-NEXT: Binding: Global
34 # DSO-NEXT: Type: Function
35 # DSO-NEXT: Other: 0
36 # DSO-NEXT: Section: .text
37 # DSO-NEXT: }
38 # DSO-NEXT: Symbol {
39 # DSO-NEXT: Name: a@@V1
40 # DSO-NEXT: Value: 0x12E8
41 # DSO-NEXT: Size: 0
42 # DSO-NEXT: Binding: Global
43 # DSO-NEXT: Type: Function
44 # DSO-NEXT: Other: 0
45 # DSO-NEXT: Section: .text
46 # DSO-NEXT: }
47 # DSO-NEXT: Symbol {
48 # DSO-NEXT: Name: c@@V2
49 # DSO-NEXT: Value: 0x12EB
50 # DSO-NEXT: Size: 0
51 # DSO-NEXT: Binding: Global
52 # DSO-NEXT: Type: Function
53 # DSO-NEXT: Other: 0
54 # DSO-NEXT: Section: .text
55 # DSO-NEXT: }
56 # DSO-NEXT: ]
57 # DSO-NEXT: VersionSymbols [
58 # DSO-NEXT: Symbol {
59 # DSO-NEXT: Version: 0
60 # DSO-NEXT: Name:
61 # DSO-NEXT: }
62 # DSO-NEXT: Symbol {
63 # DSO-NEXT: Version: 2
64 # DSO-NEXT: Name: b@V1
65 # DSO-NEXT: }
66 # DSO-NEXT: Symbol {
67 # DSO-NEXT: Version: 3
68 # DSO-NEXT: Name: b@@V2
69 # DSO-NEXT: }
70 # DSO-NEXT: Symbol {
71 # DSO-NEXT: Version: 2
72 # DSO-NEXT: Name: a@@V1
73 # DSO-NEXT: }
74 # DSO-NEXT: Symbol {
75 # DSO-NEXT: Version: 3
76 # DSO-NEXT: Name: c@@V2
77 # DSO-NEXT: }
78 # DSO-NEXT: ]
79 # DSO-NEXT: VersionDefinitions [
80 # DSO-NEXT: Definition {
81 # DSO-NEXT: Version: 1
82 # DSO-NEXT: Flags [ (0x1)
83 # DSO-NEXT: Base (0x1)
84 # DSO-NEXT: ]
85 # DSO-NEXT: Index: 1
86 # DSO-NEXT: Hash: 127830196
87 # DSO-NEXT: Name: shared
88 # DSO-NEXT: Predecessors: []
89 # DSO-NEXT: }
90 # DSO-NEXT: Definition {
91 # DSO-NEXT: Version: 1
92 # DSO-NEXT: Flags [ (0x0)
93 # DSO-NEXT: ]
94 # DSO-NEXT: Index: 2
95 # DSO-NEXT: Hash: 1425
96 # DSO-NEXT: Name: V1
97 # DSO-NEXT: Predecessors: []
98 # DSO-NEXT: }
99 # DSO-NEXT: Definition {
100 # DSO-NEXT: Version: 1
101 # DSO-NEXT: Flags [ (0x0)
102 # DSO-NEXT: ]
103 # DSO-NEXT: Index: 3
104 # DSO-NEXT: Hash: 1426
105 # DSO-NEXT: Name: V2
106 # DSO-NEXT: Predecessors: []
107 # DSO-NEXT: }
108 # DSO-NEXT: ]
110 ## Check that we can link against DSO produced.
111 # RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
112 # RUN: ld.lld --hash-style=sysv a.o %t.so -o a
113 # RUN: llvm-readobj -V --dyn-syms a | FileCheck --check-prefix=EXE %s
115 # EXE: DynamicSymbols [
116 # EXE-NEXT: Symbol {
117 # EXE-NEXT: Name:
118 # EXE-NEXT: Value: 0x0
119 # EXE-NEXT: Size: 0
120 # EXE-NEXT: Binding: Local
121 # EXE-NEXT: Type: None
122 # EXE-NEXT: Other: 0
123 # EXE-NEXT: Section: Undefined
124 # EXE-NEXT: }
125 # EXE-NEXT: Symbol {
126 # EXE-NEXT: Name: a@V1
127 # EXE-NEXT: Value: 0x201340
128 # EXE-NEXT: Size: 0
129 # EXE-NEXT: Binding: Global
130 # EXE-NEXT: Type: Function
131 # EXE-NEXT: Other: 0
132 # EXE-NEXT: Section: Undefined
133 # EXE-NEXT: }
134 # EXE-NEXT: Symbol {
135 # EXE-NEXT: Name: b@V2
136 # EXE-NEXT: Value: 0x201350
137 # EXE-NEXT: Size: 0
138 # EXE-NEXT: Binding: Global
139 # EXE-NEXT: Type: Function
140 # EXE-NEXT: Other: 0
141 # EXE-NEXT: Section: Undefined
142 # EXE-NEXT: }
143 # EXE-NEXT: Symbol {
144 # EXE-NEXT: Name: c@V2
145 # EXE-NEXT: Value: 0x201360
146 # EXE-NEXT: Size: 0
147 # EXE-NEXT: Binding: Global
148 # EXE-NEXT: Type: Function
149 # EXE-NEXT: Other: 0
150 # EXE-NEXT: Section: Undefined
151 # EXE-NEXT: }
152 # EXE-NEXT: ]
153 # EXE-NEXT: VersionSymbols [
154 # EXE-NEXT: Symbol {
155 # EXE-NEXT: Version: 0
156 # EXE-NEXT: Name:
157 # EXE-NEXT: }
158 # EXE-NEXT: Symbol {
159 # EXE-NEXT: Version: 2
160 # EXE-NEXT: Name: a@V1
161 # EXE-NEXT: }
162 # EXE-NEXT: Symbol {
163 # EXE-NEXT: Version: 3
164 # EXE-NEXT: Name: b@V2
165 # EXE-NEXT: }
166 # EXE-NEXT: Symbol {
167 # EXE-NEXT: Version: 3
168 # EXE-NEXT: Name: c@V2
169 # EXE-NEXT: }
170 # EXE-NEXT: ]
171 # EXE-NEXT: VersionDefinitions [
172 # EXE-NEXT: ]
173 # EXE-NEXT: VersionRequirements [
174 # EXE-NEXT: Dependency {
175 # EXE-NEXT: Version: 1
176 # EXE-NEXT: Count: 2
177 # EXE-NEXT: FileName: shared
178 # EXE-NEXT: Entries [
179 # EXE-NEXT: Entry {
180 # EXE-NEXT: Hash: 1425
181 # EXE-NEXT: Flags [ (0x0)
182 # EXE-NEXT: ]
183 # EXE-NEXT: Index: 2
184 # EXE-NEXT: Name: V1
185 # EXE-NEXT: }
186 # EXE-NEXT: Entry {
187 # EXE-NEXT: Hash: 1426
188 # EXE-NEXT: Flags [ (0x0)
189 # EXE-NEXT: ]
190 # EXE-NEXT: Index: 3
191 # EXE-NEXT: Name: V2
192 # EXE-NEXT: }
193 # EXE-NEXT: ]
194 # EXE-NEXT: }
195 # EXE-NEXT: ]
197 # RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
198 # RUN: ld.lld -shared --version-script=%t.script --fatal-warnings --undefined-version %t.so b.o -o b.so
199 # RUN: llvm-readelf --dyn-syms b.so | FileCheck %s --check-prefix=PREEMPT
200 # RUN: ld.lld -shared --version-script=%t.script --fatal-warnings --undefined-version b.o %t.so -o b.so
201 # RUN: llvm-readelf --dyn-syms b.so | FileCheck %s --check-prefix=PREEMPT
203 # PREEMPT-DAG: a@@V1
204 # PREEMPT-DAG: c@@V2
206 #--- a.s
207 .globl _start
208 _start:
209 .long a - .
210 .long b - .
211 .long c - .
213 #--- b.s
214 .globl a, c