1 ## Check we are able to produce a valid SHT_GNU_versym
2 ## section from its description.
4 # RUN: yaml2obj --docnum=1 %s -o %t1
5 # RUN: llvm-readobj -V %t1 | FileCheck %s
7 # CHECK: VersionSymbols [
9 # CHECK-NEXT: Version: 0
12 # CHECK-NEXT: Symbol {
13 # CHECK-NEXT: Version: 3
14 # CHECK-NEXT: Name: f1@v1
16 # CHECK-NEXT: Symbol {
17 # CHECK-NEXT: Version: 4
18 # CHECK-NEXT: Name: f2@v2
21 # CHECK-NEXT: VersionDefinitions [
23 # CHECK-NEXT: VersionRequirements [
24 # CHECK-NEXT: Dependency {
25 # CHECK-NEXT: Version: 1
26 # CHECK-NEXT: Count: 2
27 # CHECK-NEXT: FileName: dso.so.0
28 # CHECK-NEXT: Entries [
30 # CHECK-NEXT: Hash: 1937
31 # CHECK-NEXT: Flags [ (0x0)
33 # CHECK-NEXT: Index: 3
34 # CHECK-NEXT: Name: v1
37 # CHECK-NEXT: Hash: 1938
38 # CHECK-NEXT: Flags [ (0x0)
40 # CHECK-NEXT: Index: 4
41 # CHECK-NEXT: Name: v2
52 Entry: 0x0000000000201000
57 Address: 0x0000000000200210
58 AddressAlign: 0x0000000000000002
59 EntSize: 0x0000000000000002
61 - Name: .gnu.version_r
64 Address: 0x0000000000200250
65 AddressAlign: 0x0000000000000004
85 ## Check we are able to set custom sh_entsize field for SHT_GNU_versym section.
86 ## Check we link the SHT_GNU_versym section to the .dynsym section by default.
88 # RUN: yaml2obj --docnum=2 %s -o %t2
89 # RUN: llvm-readelf -S %t2 | FileCheck %s -DLINK=2 --check-prefix=FIELDS
91 # FIELDS: Section Headers:
92 # FIELDS: [Nr] Name Type Address Off Size ES Flg Lk
93 # FIELDS: [ 1] .gnu.version VERSYM 0000000000000000 000040 000000 03 [[LINK]]
94 # FIELDS: [ 2] .dynsym DYNSYM 0000000000000000 000040 000018 18 A 3
100 OSABI: ELFOSABI_FREEBSD
105 EntSize: 0x0000000000000003
107 Link: [[LINK=<none>]]
108 ## Needed to emit the .dynsym section.
111 ## Check we are able to set the sh_link field to an arbitrary value.
113 # RUN: yaml2obj --docnum=2 -DLINK=0xff %s -o %t2.link
114 # RUN: llvm-readelf -S %t2.link | FileCheck %s -DLINK=255 --check-prefix=FIELDS
116 ## Check we can use the "Content" key with the "Size" key when the size is greater
117 ## than or equal to the content size.
118 ## Also, check that we set the sh_link field to 0 when there is no .dynsym section.
120 # RUN: not yaml2obj --docnum=3 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
121 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
123 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
133 Size: [[SIZE=<none>]]
134 Content: [[CONTENT=<none>]]
135 Entries: [[ENTRIES=<none>]]
137 # RUN: yaml2obj --docnum=3 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
138 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
139 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
141 # RUN: yaml2obj --docnum=3 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
142 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
143 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
145 # CHECK-CONTENT: Name: .gnu.version
146 # CHECK-CONTENT-NEXT: Type: SHT_GNU_versym (0x6FFFFFFF)
147 # CHECK-CONTENT-NEXT: Flags [ (0x0)
148 # CHECK-CONTENT-NEXT: ]
149 # CHECK-CONTENT-NEXT: Address:
150 # CHECK-CONTENT-NEXT: Offset:
151 # CHECK-CONTENT-NEXT: Size:
152 # CHECK-CONTENT-NEXT: Link: 0
153 # CHECK-CONTENT: SectionData (
154 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
155 # CHECK-CONTENT-NEXT: )
157 ## Check we can use the "Size" key alone to create the section.
159 # RUN: yaml2obj --docnum=3 -DSIZE=3 %s -o %t.size.o
160 # RUN: llvm-readobj --sections --section-data %t.size.o | \
161 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
163 ## Check we can use the "Content" key alone to create the section.
165 # RUN: yaml2obj --docnum=3 -DCONTENT="'112233'" %s -o %t.content.o
166 # RUN: llvm-readobj --sections --section-data %t.content.o | \
167 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
169 ## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
171 # RUN: not yaml2obj --docnum=3 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
172 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
173 # RUN: not yaml2obj --docnum=3 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
174 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
176 # ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"
178 ## Check we set the sh_link field to 0 when the .dynsym section is excluded
179 ## from the section header table.
181 # RUN: yaml2obj --docnum=4 %s -o %t4
182 # RUN: llvm-readelf --sections %t4 | FileCheck %s --check-prefix=EXCLUDED
184 # EXCLUDED: [Nr] Name {{.*}} ES Flg Lk Inf
185 # EXCLUDED: [ 1] .gnu.version {{.*}} 02 0 0
197 - Type: SectionHeaderTable