251 lines · yaml
1## Test how we create SHT_GNU_verdef sections.2 3## Check that we link the SHT_GNU_verdef section to4## the `.dynstr` section by default.5## Check that we set the value of `sh_info` field to the6## number of version definitions by default.7 8# RUN: yaml2obj --docnum=1 %s -o %t19# RUN: llvm-readobj -V %t1 | FileCheck %s10# RUN: llvm-readelf --sections %t1 | \11# RUN: FileCheck %s -DLINK=3 -DINFO=4 --check-prefix=FIELDS12 13# FIELDS: [Nr] Name Type {{.*}} Flg Lk Inf14# FIELDS: [ 1] .gnu.version_d VERDEF {{.*}} A [[LINK]] [[INFO]]15# FIELDS: [ 3] .dynstr16 17# CHECK: VersionDefinitions [18# CHECK-NEXT: Definition {19# CHECK-NEXT: Version: 120# CHECK-NEXT: Flags [ (0x0)21# CHECK-NEXT: ]22# CHECK-NEXT: Index: 023# CHECK-NEXT: Hash: 024# CHECK-NEXT: Name:25# CHECK-NEXT: Predecessors: []26# CHECK-NEXT: }27# CHECK-NEXT: Definition {28# CHECK-NEXT: Version: 129# CHECK-NEXT: Flags [ (0x1)30# CHECK-NEXT: Base (0x1)31# CHECK-NEXT: ]32# CHECK-NEXT: Index: 133# CHECK-NEXT: Hash: 17024016034# CHECK-NEXT: Name: dso.so.035# CHECK-NEXT: Predecessors: []36# CHECK-NEXT: }37# CHECK-NEXT: Definition {38# CHECK-NEXT: Version: 139# CHECK-NEXT: Flags [ (0x2)40# CHECK-NEXT: Weak (0x2)41# CHECK-NEXT: ]42# CHECK-NEXT: Index: 243# CHECK-NEXT: Hash: 10838792144# CHECK-NEXT: Name: VERSION_145# CHECK-NEXT: Predecessors: []46# CHECK-NEXT: }47# CHECK-NEXT: Definition {48# CHECK-NEXT: Version: 149# CHECK-NEXT: Flags [ (0xFFFF)50# CHECK-NEXT: Base (0x1)51# CHECK-NEXT: Info (0x4)52# CHECK-NEXT: Weak (0x2)53# CHECK-NEXT: ]54# CHECK-NEXT: Index: 355# CHECK-NEXT: Hash: 10838792256# CHECK-NEXT: Name: VERSION_257# CHECK-NEXT: Predecessors: [VERSION_3, VERSION_4]58# CHECK-NEXT: }59# CHECK-NEXT: ]60 61--- !ELF62FileHeader:63 Class: ELFCLASS6464 Data: ELFDATA2LSB65 Type: ET_DYN66Sections:67 - Name: .gnu.version_d68 Type: SHT_GNU_verdef69 Flags: [ SHF_ALLOC ]70 Info: [[INFO=<none>]]71 Link: [[LINK=<none>]]72 Entries: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 shows75## that we are able to use the "=<none>" syntax for these fields.76 - Version: [[VERSION=<none>]]77 Flags: [[FLAGS=<none>]]78 VersionNdx: [[VERNDX=<none>]]79 Hash: [[HASH=<none>]]80 Names: []81## Case 2: an arbitrary entry.82 - Flags: 183 VersionNdx: 184 Hash: 17024016085 Names:86 - dso.so.087## Case 3: one more arbitrary entry with different values.88 - Flags: 289 VersionNdx: 290 Hash: 10838792191 Names:92 - VERSION_193## Case 4: an entry that has version predecessors. Also, it sets94## all known flags as well as few unknown.95 - Flags: 0xffff96 VersionNdx: 397 Hash: 10838792298 Names:99 - VERSION_2100 - VERSION_3101 - VERSION_4102DynamicSymbols:103 - Name: foo104 Binding: STB_GLOBAL105 106## Check that we are able to set sh_info and sh_link fields to arbitrary values.107 108# RUN: yaml2obj --docnum=1 -DINFO=123 -DLINK=234 %s -o %t1.fields109# RUN: llvm-readelf --sections %t1.fields | \110# RUN: FileCheck %s -DINFO=123 -DLINK=234 --check-prefix=FIELDS111 112## Check we are able to emit a version definition which has a version revision113## (vd_version) field value that is not equal to 1.114 115# RUN: yaml2obj --docnum=1 -DVERSION=2 %s -o %t.version116# RUN: llvm-readobj -V %t.version 2>&1 | FileCheck %s --check-prefix=VERSION-ERR117 118# VERSION-ERR: unable to dump SHT_GNU_verdef section with index 1: version 2 is not yet supported119 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.122 123# RUN: yaml2obj --docnum=2 %s -o %t2124# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=CONTENT125 126# CONTENT: Name: .gnu.version_d127# CONTENT-NEXT: Type: SHT_GNU_verdef128# CONTENT-NEXT: Flags [ (0x2)129# CONTENT-NEXT: SHF_ALLOC (0x2)130# CONTENT-NEXT: ]131# CONTENT-NEXT: Address: 0x0132# CONTENT-NEXT: Offset: 0x40133# CONTENT-NEXT: Size: 3134# CONTENT-NEXT: Link: 0135# CONTENT-NEXT: Info: 0136# CONTENT-NEXT: AddressAlignment:137# CONTENT-NEXT: EntrySize:138# CONTENT-NEXT: SectionData (139# CONTENT-NEXT: 0000: 112233140# CONTENT-NEXT: )141 142--- !ELF143FileHeader:144 Class: ELFCLASS64145 Data: ELFDATA2LSB146 Type: ET_DYN147Sections:148 - Name: .gnu.version_d149 Type: SHT_GNU_verdef150 Flags: [ SHF_ALLOC ]151 Content: "112233"152 153## Check we can omit "Content" and "Entries" fields to produce an empty SHT_GNU_verdef section.154 155# RUN: yaml2obj --docnum=3 %s -o %t3156# RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=NO-PROPS157 158# NO-PROPS: [Nr] Name Type Address Off Size ES Flg Lk Inf Al159# NO-PROPS: [ 1] .gnu.version_d VERDEF 0000000000000000 000040 000000 00 A 0 0 0160 161--- !ELF162FileHeader:163 Class: ELFCLASS64164 Data: ELFDATA2LSB165 Type: ET_DYN166Sections:167 - Name: .gnu.version_d168 Type: SHT_GNU_verdef169 Flags: [ SHF_ALLOC ]170 171## Check we can use the "Content" key with the "Size" key when the size is greater172## than or equal to the content size.173 174# RUN: not yaml2obj --docnum=4 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \175# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR176 177# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size178 179--- !ELF180FileHeader:181 Class: ELFCLASS64182 Data: ELFDATA2LSB183 Type: ET_DYN184Sections:185 - Name: .gnu.version_d186 Type: SHT_GNU_verdef187 Size: [[SIZE=<none>]]188 Content: [[CONTENT=<none>]]189 Entries: [[ENTRIES=<none>]]190 191# RUN: yaml2obj --docnum=4 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o192# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \193# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"194 195# RUN: yaml2obj --docnum=4 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o196# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \197# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"198 199# CHECK-CONTENT: Name: .gnu.version_d200# CHECK-CONTENT: SectionData (201# CHECK-CONTENT-NEXT: 0000: [[DATA]] |202# CHECK-CONTENT-NEXT: )203 204## Check we can use the "Size" key alone to create the section.205 206# RUN: yaml2obj --docnum=4 -DSIZE=3 %s -o %t.size.o207# RUN: llvm-readobj --sections --section-data %t.size.o | \208# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"209 210## Check we can use the "Content" key alone to create the section.211 212# RUN: yaml2obj --docnum=4 -DCONTENT="'112233'" %s -o %t.content.o213# RUN: llvm-readobj --sections --section-data %t.content.o | \214# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"215 216## Check we can't use the "Entries" key together with the "Content" or "Size" keys.217 218# RUN: not yaml2obj --docnum=4 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \219# RUN: FileCheck %s --check-prefix=ENTRIES-ERR220# RUN: not yaml2obj --docnum=4 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \221# RUN: FileCheck %s --check-prefix=ENTRIES-ERR222 223# ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"224 225## Check we set the sh_link field to 0 when the .dynstr section is excluded226## from the section header table.227 228# RUN: yaml2obj --docnum=5 %s -o %t5229# RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=EXCLUDED230 231# EXCLUDED: [Nr] Name {{.*}} ES Flg Lk Inf232# EXCLUDED: [ 1] .gnu.version_d {{.*}} 00 0 0233 234--- !ELF235FileHeader:236 Class: ELFCLASS64237 Data: ELFDATA2LSB238 Type: ET_DYN239Sections:240 - Name: .gnu.version_d241 Type: SHT_GNU_verdef242 - Name: .dynstr243 Type: SHT_STRTAB244 - Type: SectionHeaderTable245 Sections:246 - Name: .gnu.version_d247 - Name: .strtab248 - Name: .shstrtab249 Excluded:250 - Name: .dynstr251