1 ## Check we are able to dump SHT_GNU_verneed sections properly.
2 ## Check that we link the SHT_GNU_verneed section to
3 ## the `.dynstr` section by default.
4 ## Check that we set the value of `sh_info` field to the number
5 ## of version dependencies by default.
7 # RUN: yaml2obj --docnum=1 %s -o %t1
8 # RUN: llvm-readobj -V %t1 | FileCheck %s
9 # RUN: llvm-readelf --sections %t1 | \
10 # RUN: FileCheck %s -DLINK=3 -DINFO=2 --check-prefix=FIELDS
12 # FIELDS: [Nr] Name Type {{.*}} Flg Lk Inf Al
13 # FIELDS: [ 1] .gnu.version_r VERNEED {{.*}} A [[LINK]] [[INFO]] 4
14 # FIELDS: [ 3] .dynstr
16 # CHECK: VersionRequirements [
17 # CHECK-NEXT: Dependency {
18 # CHECK-NEXT: Version: 1
19 # CHECK-NEXT: Count: 2
20 # CHECK-NEXT: FileName: dso.so.0
21 # CHECK-NEXT: Entries [
23 # CHECK-NEXT: Hash: 1937
24 # CHECK-NEXT: Flags [ (0xA)
25 # CHECK-NEXT: Weak (0x2)
27 # CHECK-NEXT: Index: 3
28 # CHECK-NEXT: Name: v1
31 # CHECK-NEXT: Hash: 1938
32 # CHECK-NEXT: Flags [ (0xB)
33 # CHECK-NEXT: Base (0x1)
34 # CHECK-NEXT: Weak (0x2)
36 # CHECK-NEXT: Index: 4
37 # CHECK-NEXT: Name: v2
41 # CHECK-NEXT: Dependency {
42 # CHECK-NEXT: Version: 1
43 # CHECK-NEXT: Count: 1
44 # CHECK-NEXT: FileName: dso.so.1
45 # CHECK-NEXT: Entries [
47 # CHECK-NEXT: Hash: 1939
48 # CHECK-NEXT: Flags [ (0xC)
49 # CHECK-NEXT: Info (0x4)
51 # CHECK-NEXT: Index: 2
52 # CHECK-NEXT: Name: v3
63 Entry: 0x0000000000201000
65 - Name: .gnu.version_r
68 Address: 0x0000000000200250
69 AddressAlign: 0x0000000000000004
95 ## Check that we are able to set sh_info and sh_link fields to arbitrary values.
97 # RUN: yaml2obj --docnum=1 -DINFO=123 -DLINK=234 %s -o %t1.fields
98 # RUN: llvm-readelf --sections %t1.fields | \
99 # RUN: FileCheck %s -DINFO=123 -DLINK=234 --check-prefix=FIELDS
101 ## Check we can omit "Content", "Size" and "Dependencies" fields to
102 ## produce an empty SHT_GNU_verneed section.
103 ## Check we set the sh_link field to 0 when there is no .dynstr section.
105 # RUN: yaml2obj --docnum=2 %s -o %t3
106 # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=NO-PROPS
108 # NO-PROPS: [Nr] Name Type Address Off Size ES Flg Lk Inf
109 # NO-PROPS: [ 1] .gnu.version_r VERNEED 0000000000000000 000040 000000 00 A 0 0
117 - Name: .gnu.version_r
118 Type: SHT_GNU_verneed
120 Size: [[SIZE=<none>]]
121 Content: [[CONTENT=<none>]]
122 Dependencies: [[DEPS=<none>]]
124 ## Check we can use the "Content" key with the "Size" key when the size is greater
125 ## than or equal to the content size.
127 # RUN: not yaml2obj --docnum=2 -DCONTENT="'00'" -DSIZE=0 %s 2>&1 | \
128 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
130 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
132 # RUN: yaml2obj --docnum=2 -DCONTENT="'00'" -DSIZE=1 %s -o %t.cont.size.eq.o
133 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
134 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00"
136 # RUN: yaml2obj --docnum=2 -DCONTENT="'00'" -DSIZE=2 %s -o %t.cont.size.gr.o
137 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
138 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0000"
140 # CHECK-CONTENT: Name: .gnu.version_r
141 # CHECK-CONTENT: SectionData (
142 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
143 # CHECK-CONTENT-NEXT: )
145 ## Check we can use the "Size" key alone to create the section.
147 # RUN: yaml2obj --docnum=2 -DSIZE=3 %s -o %t.size.o
148 # RUN: llvm-readobj --sections --section-data %t.size.o | \
149 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
151 ## Check we can use the "Content" key alone to create the section.
153 # RUN: yaml2obj --docnum=2 -DCONTENT="'112233'" %s -o %t.content.o
154 # RUN: llvm-readobj --sections --section-data %t.content.o | \
155 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
157 ## Check we can't use the "Dependencies" key together with the "Content" or "Size" keys.
159 # RUN: not yaml2obj --docnum=2 -DSIZE=0 -DDEPS="[]" %s 2>&1 | \
160 # RUN: FileCheck %s --check-prefix=DEPS-ERR
161 # RUN: not yaml2obj --docnum=2 -DCONTENT="'00'" -DDEPS="[]" %s 2>&1 | \
162 # RUN: FileCheck %s --check-prefix=DEPS-ERR
164 # DEPS-ERR: error: "Dependencies" cannot be used with "Content" or "Size"
166 ## Check we set the sh_link field to 0 when the .dynstr section is excluded
167 ## from the section header table.
169 # RUN: yaml2obj --docnum=3 %s -o %t3
170 # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=EXCLUDED
172 # EXCLUDED: [Nr] Name {{.*}} ES Flg Lk Inf
173 # EXCLUDED: [ 1] .gnu.version_r {{.*}} 00 0 0
181 - Name: .gnu.version_r
182 Type: SHT_GNU_verneed
185 - Type: SectionHeaderTable
187 - Name: .gnu.version_r