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. 6 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 11 12# FIELDS: [Nr] Name Type {{.*}} Flg Lk Inf Al 13# FIELDS: [ 1] .gnu.version_r VERNEED {{.*}} A [[LINK]] [[INFO]] 4 14# FIELDS: [ 3] .dynstr 15 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 [ 22# CHECK-NEXT: Entry { 23# CHECK-NEXT: Hash: 1937 24# CHECK-NEXT: Flags [ (0xA) 25# CHECK-NEXT: Weak (0x2) 26# CHECK-NEXT: ] 27# CHECK-NEXT: Index: 3 28# CHECK-NEXT: Name: v1 29# CHECK-NEXT: } 30# CHECK-NEXT: Entry { 31# CHECK-NEXT: Hash: 1938 32# CHECK-NEXT: Flags [ (0xB) 33# CHECK-NEXT: Base (0x1) 34# CHECK-NEXT: Weak (0x2) 35# CHECK-NEXT: ] 36# CHECK-NEXT: Index: 4 37# CHECK-NEXT: Name: v2 38# CHECK-NEXT: } 39# CHECK-NEXT: ] 40# CHECK-NEXT: } 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 [ 46# CHECK-NEXT: Entry { 47# CHECK-NEXT: Hash: 1939 48# CHECK-NEXT: Flags [ (0xC) 49# CHECK-NEXT: Info (0x4) 50# CHECK-NEXT: ] 51# CHECK-NEXT: Index: 2 52# CHECK-NEXT: Name: v3 53# CHECK-NEXT: } 54# CHECK-NEXT: ] 55# CHECK-NEXT: } 56# CHECK-NEXT: ] 57 58--- !ELF 59FileHeader: 60 Class: ELFCLASS64 61 Data: ELFDATA2LSB 62 Type: ET_EXEC 63 Entry: 0x0000000000201000 64Sections: 65 - Name: .gnu.version_r 66 Type: SHT_GNU_verneed 67 Flags: [ SHF_ALLOC ] 68 Address: 0x0000000000200250 69 AddressAlign: 0x0000000000000004 70 Info: [[INFO=<none>]] 71 Link: [[LINK=<none>]] 72 Dependencies: 73 - Version: 1 74 File: dso.so.0 75 Entries: 76 - Name: v1 77 Hash: 1937 78 Flags: 10 79 Other: 3 80 - Name: v2 81 Hash: 1938 82 Flags: 11 83 Other: 4 84 - Version: 1 85 File: dso.so.1 86 Entries: 87 - Name: v3 88 Hash: 1939 89 Flags: 12 90 Other: 2 91DynamicSymbols: 92 - Name: f1 93 Binding: STB_GLOBAL 94 95## Check that we are able to set sh_info and sh_link fields to arbitrary values. 96 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 100 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. 104 105# RUN: yaml2obj --docnum=2 %s -o %t3 106# RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=NO-PROPS 107 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 110 111--- !ELF 112FileHeader: 113 Class: ELFCLASS64 114 Data: ELFDATA2LSB 115 Type: ET_EXEC 116Sections: 117 - Name: .gnu.version_r 118 Type: SHT_GNU_verneed 119 Flags: [ SHF_ALLOC ] 120 Size: [[SIZE=<none>]] 121 Content: [[CONTENT=<none>]] 122 Dependencies: [[DEPS=<none>]] 123 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. 126 127# RUN: not yaml2obj --docnum=2 -DCONTENT="'00'" -DSIZE=0 %s 2>&1 | \ 128# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR 129 130# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size 131 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" 135 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" 139 140# CHECK-CONTENT: Name: .gnu.version_r 141# CHECK-CONTENT: SectionData ( 142# CHECK-CONTENT-NEXT: 0000: [[DATA]] | 143# CHECK-CONTENT-NEXT: ) 144 145## Check we can use the "Size" key alone to create the section. 146 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" 150 151## Check we can use the "Content" key alone to create the section. 152 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" 156 157## Check we can't use the "Dependencies" key together with the "Content" or "Size" keys. 158 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 163 164# DEPS-ERR: error: "Dependencies" cannot be used with "Content" or "Size" 165 166## Check we set the sh_link field to 0 when the .dynstr section is excluded 167## from the section header table. 168 169# RUN: yaml2obj --docnum=3 %s -o %t3 170# RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=EXCLUDED 171 172# EXCLUDED: [Nr] Name {{.*}} ES Flg Lk Inf 173# EXCLUDED: [ 1] .gnu.version_r {{.*}} 00 0 0 174 175--- !ELF 176FileHeader: 177 Class: ELFCLASS64 178 Data: ELFDATA2LSB 179 Type: ET_DYN 180Sections: 181 - Name: .gnu.version_r 182 Type: SHT_GNU_verneed 183 - Name: .dynstr 184 Type: SHT_STRTAB 185 - Type: SectionHeaderTable 186 Sections: 187 - Name: .gnu.version_r 188 - Name: .strtab 189 - Name: .shstrtab 190 Excluded: 191 - Name: .dynstr 192