1 ## Test how we create SHT_GNU_verdef sections.
3 ## Check that we link the SHT_GNU_verdef section to
4 ## the `.dynstr` section by default.
5 ## Check that we set the value of `sh_info` field to the
6 ## number of version definitions by default.
8 # RUN: yaml2obj --docnum=1 %s -o %t1
9 # RUN: llvm-readobj -V %t1 | FileCheck %s
10 # RUN: llvm-readelf --sections %t1 | \
11 # RUN: FileCheck %s -DLINK=3 -DINFO=4 --check-prefix=FIELDS
13 # FIELDS: [Nr] Name Type {{.*}} Flg Lk Inf
14 # FIELDS: [ 1] .gnu.version_d VERDEF {{.*}} A [[LINK]] [[INFO]]
15 # FIELDS: [ 3] .dynstr
17 # CHECK: VersionDefinitions [
18 # CHECK-NEXT: Definition {
19 # CHECK-NEXT: Version: 1
20 # CHECK-NEXT: Flags [ (0x0)
22 # CHECK-NEXT: Index: 0
25 # CHECK-NEXT: Predecessors: []
27 # CHECK-NEXT: Definition {
28 # CHECK-NEXT: Version: 1
29 # CHECK-NEXT: Flags [ (0x1)
30 # CHECK-NEXT: Base (0x1)
32 # CHECK-NEXT: Index: 1
33 # CHECK-NEXT: Hash: 170240160
34 # CHECK-NEXT: Name: dso.so.0
35 # CHECK-NEXT: Predecessors: []
37 # CHECK-NEXT: Definition {
38 # CHECK-NEXT: Version: 1
39 # CHECK-NEXT: Flags [ (0x2)
40 # CHECK-NEXT: Weak (0x2)
42 # CHECK-NEXT: Index: 2
43 # CHECK-NEXT: Hash: 108387921
44 # CHECK-NEXT: Name: VERSION_1
45 # CHECK-NEXT: Predecessors: []
47 # CHECK-NEXT: Definition {
48 # CHECK-NEXT: Version: 1
49 # CHECK-NEXT: Flags [ (0xFFFF)
50 # CHECK-NEXT: Base (0x1)
51 # CHECK-NEXT: Info (0x4)
52 # CHECK-NEXT: Weak (0x2)
54 # CHECK-NEXT: Index: 3
55 # CHECK-NEXT: Hash: 108387922
56 # CHECK-NEXT: Name: VERSION_2
57 # CHECK-NEXT: Predecessors: [VERSION_3, VERSION_4]
67 - Name: .gnu.version_d
73 ## Case 1: an entry that has no Version, Flags, VersionNdx or Hash fields set.
74 ## Used to check values that are written by default. Also shows
75 ## that we are able to use the "=<none>" syntax for these fields.
76 - Version: [[VERSION=<none>]]
77 Flags: [[FLAGS=<none>]]
78 VersionNdx: [[VERNDX=<none>]]
81 ## Case 2: an arbitrary entry.
87 ## Case 3: one more arbitrary entry with different values.
93 ## Case 4: an entry that has version predecessors. Also, it sets
94 ## all known flags as well as few unknown.
106 ## Check that we are able to set sh_info and sh_link fields to arbitrary values.
108 # RUN: yaml2obj --docnum=1 -DINFO=123 -DLINK=234 %s -o %t1.fields
109 # RUN: llvm-readelf --sections %t1.fields | \
110 # RUN: FileCheck %s -DINFO=123 -DLINK=234 --check-prefix=FIELDS
112 ## Check we are able to emit a version definition which has a version revision
113 ## (vd_version) field value that is not equal to 1.
115 # RUN: yaml2obj --docnum=1 -DVERSION=2 %s -o %t.version
116 # RUN: llvm-readobj -V %t.version 2>&1 | FileCheck %s --check-prefix=VERSION-ERR
118 # VERSION-ERR: unable to dump SHT_GNU_verdef section with index 1: version 2 is not yet supported
120 ## Check we can use "Content" to describe the content.
121 ## Check we set the sh_link field to 0 when there is no .dynstr section.
123 # RUN: yaml2obj --docnum=2 %s -o %t2
124 # RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=CONTENT
126 # CONTENT: Name: .gnu.version_d
127 # CONTENT-NEXT: Type: SHT_GNU_verdef
128 # CONTENT-NEXT: Flags [ (0x2)
129 # CONTENT-NEXT: SHF_ALLOC (0x2)
131 # CONTENT-NEXT: Address: 0x0
132 # CONTENT-NEXT: Offset: 0x40
133 # CONTENT-NEXT: Size: 3
134 # CONTENT-NEXT: Link: 0
135 # CONTENT-NEXT: Info: 0
136 # CONTENT-NEXT: AddressAlignment:
137 # CONTENT-NEXT: EntrySize:
138 # CONTENT-NEXT: SectionData (
139 # CONTENT-NEXT: 0000: 112233
148 - Name: .gnu.version_d
153 ## Check we can omit "Content" and "Entries" fields to produce an empty SHT_GNU_verdef section.
155 # RUN: yaml2obj --docnum=3 %s -o %t3
156 # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=NO-PROPS
158 # NO-PROPS: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
159 # NO-PROPS: [ 1] .gnu.version_d VERDEF 0000000000000000 000040 000000 00 A 0 0 0
167 - Name: .gnu.version_d
171 ## Check we can use the "Content" key with the "Size" key when the size is greater
172 ## than or equal to the content size.
174 # RUN: not yaml2obj --docnum=4 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
175 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
177 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
185 - Name: .gnu.version_d
187 Size: [[SIZE=<none>]]
188 Content: [[CONTENT=<none>]]
189 Entries: [[ENTRIES=<none>]]
191 # RUN: yaml2obj --docnum=4 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
192 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
193 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
195 # RUN: yaml2obj --docnum=4 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
196 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
197 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
199 # CHECK-CONTENT: Name: .gnu.version_d
200 # CHECK-CONTENT: SectionData (
201 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
202 # CHECK-CONTENT-NEXT: )
204 ## Check we can use the "Size" key alone to create the section.
206 # RUN: yaml2obj --docnum=4 -DSIZE=3 %s -o %t.size.o
207 # RUN: llvm-readobj --sections --section-data %t.size.o | \
208 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
210 ## Check we can use the "Content" key alone to create the section.
212 # RUN: yaml2obj --docnum=4 -DCONTENT="'112233'" %s -o %t.content.o
213 # RUN: llvm-readobj --sections --section-data %t.content.o | \
214 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
216 ## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
218 # RUN: not yaml2obj --docnum=4 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
219 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
220 # RUN: not yaml2obj --docnum=4 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
221 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
223 # ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"
225 ## Check we set the sh_link field to 0 when the .dynstr section is excluded
226 ## from the section header table.
228 # RUN: yaml2obj --docnum=5 %s -o %t5
229 # RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=EXCLUDED
231 # EXCLUDED: [Nr] Name {{.*}} ES Flg Lk Inf
232 # EXCLUDED: [ 1] .gnu.version_d {{.*}} 00 0 0
240 - Name: .gnu.version_d
244 - Type: SectionHeaderTable
246 - Name: .gnu.version_d