1## Check how yaml2obj produces SHT_HASH sections. 2 3## Check we can describe a SHT_HASH section using the "Content" tag. 4## Check default values of section fields. 5 6# RUN: yaml2obj --docnum=1 %s -o %t1 7# RUN: llvm-readobj --sections --section-data %t1 | \ 8# RUN: FileCheck %s -DENTSIZE=4 --check-prefix=CONTENT 9 10# CONTENT: Name: .hash 11# CONTENT-NEXT: Type: SHT_HASH 12# CONTENT-NEXT: Flags [ 13# CONTENT-NEXT: ] 14# CONTENT-NEXT: Address: 0x0 15# CONTENT-NEXT: Offset: 0x44 16# CONTENT-NEXT: Size: 20 17# CONTENT-NEXT: Link: 1 18# CONTENT-NEXT: Info: 0 19# CONTENT-NEXT: AddressAlignment: 0 20# CONTENT-NEXT: EntrySize: [[ENTSIZE]]{{$}} 21# CONTENT-NEXT: SectionData ( 22# CONTENT-NEXT: 0000: 01000000 02000000 03000000 04000000 23# CONTENT-NEXT: 0010: 05000000 24# CONTENT-NEXT: ) 25 26--- !ELF 27FileHeader: 28 Class: ELFCLASS32 29 Data: ELFDATA2LSB 30 Type: ET_DYN 31Sections: 32## SHT_HASH is linked to dynamic symbol table by default. 33 - Name: .dynsym 34 Type: SHT_DYNSYM 35 - Name: .hash 36 Type: SHT_HASH 37 Content: '0100000002000000030000000400000005000000' 38 EntSize: [[ENTSIZE=<none>]] 39 40## Check we can set an arbitrary entry size for the SHT_HASH section. 41 42# RUN: yaml2obj --docnum=1 -DENTSIZE=0xFF %s -o %t1.entsize 43# RUN: llvm-readobj --sections --section-data %t1.entsize | \ 44# RUN: FileCheck %s -DENTSIZE=255 --check-prefix=CONTENT 45 46## Check we can describe a SHT_HASH section using "Bucket" and "Chain" tags. 47 48# RUN: yaml2obj --docnum=2 %s -o %t2 49# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=BUCKET-CHAIN 50 51# BUCKET-CHAIN: Name: .hash 52# BUCKET-CHAIN: Size: 53# BUCKET-CHAIN-SAME: 28 54# BUCKET-CHAIN: Link: 55# BUCKET-CHAIN-SAME: 0 56# BUCKET-CHAIN: SectionData ( 57# BUCKET-CHAIN-NEXT: 0000: 02000000 03000000 01000000 02000000 | 58# BUCKET-CHAIN-NEXT: 0010: 03000000 04000000 05000000 | 59# BUCKET-CHAIN-NEXT: ) 60 61--- !ELF 62FileHeader: 63 Class: ELFCLASS32 64 Data: ELFDATA2LSB 65 Type: ET_DYN 66Sections: 67 - Name: .hash 68 Type: SHT_HASH 69 Bucket: [ 1, 2 ] 70 Chain: [ 3, 4, 5 ] 71 72## Check we can't use "Content" and "Bucket" tags together. 73 74# RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-BUCKET 75 76# CONTENT-BUCKET: "Bucket" and "Chain" cannot be used with "Content" or "Size" 77 78--- !ELF 79FileHeader: 80 Class: ELFCLASS32 81 Data: ELFDATA2LSB 82 Type: ET_DYN 83Sections: 84 - Name: .hash 85 Type: SHT_HASH 86 Bucket: [ 1 ] 87 Content: '00' 88 89## Check we can't use "Content" and "Chain" tags together. 90 91# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-CHAIN 92 93# CONTENT-CHAIN: "Chain" cannot be used with "Content" or "Size" 94 95--- !ELF 96FileHeader: 97 Class: ELFCLASS32 98 Data: ELFDATA2LSB 99 Type: ET_DYN 100Sections: 101 - Name: .hash 102 Type: SHT_HASH 103 Chain: [ 1 ] 104 Content: '00' 105 106## Check we can't use "Bucket" without "Chain". 107 108# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=NO-BUCKET-OR-CHAIN 109 110# NO-BUCKET-OR-CHAIN: error: "Bucket" and "Chain" must be used together 111 112--- !ELF 113FileHeader: 114 Class: ELFCLASS32 115 Data: ELFDATA2LSB 116 Type: ET_DYN 117Sections: 118 - Name: .hash 119 Type: SHT_HASH 120 Bucket: [ 1 ] 121 122## Check we can't use "Chain" without "Bucket". 123 124# RUN: not yaml2obj --docnum=6 %s 2>&1 | FileCheck %s --check-prefix=NO-BUCKET-OR-CHAIN 125 126--- !ELF 127FileHeader: 128 Class: ELFCLASS32 129 Data: ELFDATA2LSB 130 Type: ET_DYN 131Sections: 132 - Name: .hash 133 Type: SHT_HASH 134 Chain: [ 1 ] 135 136## Check we emit an empty section if neither "Bucket", "Chain", 137## "Content" nor "Size" were set. 138 139# RUN: yaml2obj --docnum=7 %s -o %t7 140# RUN: llvm-readelf --sections %t7 | FileCheck %s --check-prefix=NO-TAGS 141 142# NO-TAGS: [Nr] Name Type Address Off Size 143# NO-TAGS: [ 1] .hash HASH 00000000 000034 000000 144 145--- !ELF 146FileHeader: 147 Class: ELFCLASS32 148 Data: ELFDATA2LSB 149 Type: ET_DYN 150Sections: 151 - Name: .hash 152 Type: SHT_HASH 153 154## Check we can set any sh_link value with use of the "Link" tag. 155 156# RUN: yaml2obj --docnum=8 %s -o %t8 157# RUN: llvm-readobj --sections %t8 | FileCheck %s --check-prefix=LINK 158 159# LINK: Name: .hash1 160# LINK: Link: 161# LINK-SAME: 123 162 163# LINK: Name: .hash2 164# LINK: Link: 165# LINK-SAME: 1 166 167--- !ELF 168FileHeader: 169 Class: ELFCLASS32 170 Data: ELFDATA2LSB 171 Type: ET_DYN 172Sections: 173 - Name: .hash1 174 Type: SHT_HASH 175 Content: "" 176 Link: 123 177 - Name: .hash2 178 Type: SHT_HASH 179 Content: "" 180 Link: .hash1 181## SHT_HASH is linked to dynamic symbol table by default if it exists. 182 - Name: .dynsym 183 Type: SHT_DYNSYM 184 185## Check we can use only "Size" to create a SHT_HASH section. 186 187# RUN: yaml2obj --docnum=9 %s -o %t9 188# RUN: llvm-readobj --sections --section-data %t9 | FileCheck %s --check-prefix=SIZE 189 190# SIZE: Name: .hash 191# SIZE: Size: 192# SIZE-SAME: 17 193# SIZE: SectionData ( 194# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 | 195# SIZE-NEXT: 0010: 00 | 196# SIZE-NEXT: ) 197 198--- !ELF 199FileHeader: 200 Class: ELFCLASS64 201 Data: ELFDATA2LSB 202 Type: ET_EXEC 203Sections: 204 - Name: .hash 205 Type: SHT_HASH 206 Size: 0x11 207 208## Check we can use "Size" and "Content" together to create a SHT_HASH section. 209 210# RUN: yaml2obj --docnum=10 %s -o %t10 211# RUN: llvm-readobj --sections --section-data %t10 | FileCheck %s --check-prefix=SIZE-CONTENT 212 213# SIZE-CONTENT: Name: .hash 214# SIZE-CONTENT: Size: 215# SIZE-CONTENT-SAME: 5 216# SIZE-CONTENT: SectionData ( 217# SIZE-CONTENT-NEXT: 0000: 11223300 00 | 218# SIZE-CONTENT-NEXT: ) 219 220--- !ELF 221FileHeader: 222 Class: ELFCLASS64 223 Data: ELFDATA2LSB 224 Type: ET_EXEC 225Sections: 226 - Name: .hash 227 Type: SHT_HASH 228 Size: 0x5 229 Content: "112233" 230 231## Check that when "Size" and "Content" are used together, the size 232## must be greater than or equal to the content size. 233 234# RUN: not yaml2obj --docnum=11 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR 235 236# SIZE-CONTENT-ERR: error: Section size must be greater than or equal to the content size 237 238--- !ELF 239FileHeader: 240 Class: ELFCLASS64 241 Data: ELFDATA2LSB 242 Type: ET_EXEC 243Sections: 244 - Name: .hash 245 Type: SHT_HASH 246 Size: 0x1 247 Content: "1122" 248 249## Check we can't use "Size" and "Bucket" tags together. 250 251# RUN: not yaml2obj --docnum=12 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-BUCKET 252 253--- !ELF 254FileHeader: 255 Class: ELFCLASS64 256 Data: ELFDATA2LSB 257 Type: ET_EXEC 258Sections: 259 - Name: .hash 260 Type: SHT_HASH 261 Size: 0x1 262 Bucket: [ 1 ] 263 264## Check we can't use "Size" and "Chain" tags together. 265 266# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-CHAIN 267 268--- !ELF 269FileHeader: 270 Class: ELFCLASS64 271 Data: ELFDATA2LSB 272 Type: ET_EXEC 273Sections: 274 - Name: .hash 275 Type: SHT_HASH 276 Size: 0x1 277 Chain: [ 1 ] 278 279## Check we can override "nbucket" and "nchain" values of a SHT_HASH section using "NBucket" 280## and "NChain" tags. Check that the section size is unaffected when we do this. 281 282# RUN: yaml2obj --docnum=14 %s -o %t14 283# RUN: llvm-readobj --sections --section-data %t14 | FileCheck %s --check-prefix=OVERRIDE 284 285# OVERRIDE: Name: .hash 286# OVERRIDE-NEXT: Type: SHT_HASH 287# OVERRIDE-NEXT: Flags [ 288# OVERRIDE-NEXT: ] 289# OVERRIDE-NEXT: Address: 0x0 290# OVERRIDE-NEXT: Offset: 0x34 291# OVERRIDE-NEXT: Size: 28 292# OVERRIDE-NEXT: Link: 0 293# OVERRIDE-NEXT: Info: 0 294# OVERRIDE-NEXT: AddressAlignment: 0 295# OVERRIDE-NEXT: EntrySize: 4 296# OVERRIDE-NEXT: SectionData ( 297# OVERRIDE-NEXT: 0000: AA000000 BB000000 01000000 02000000 298# OVERRIDE-NEXT: 0010: 03000000 04000000 05000000 299# OVERRIDE-NEXT: ) 300 301--- !ELF 302FileHeader: 303 Class: ELFCLASS32 304 Data: ELFDATA2LSB 305 Type: ET_DYN 306Sections: 307 - Name: .hash 308 Type: SHT_HASH 309 Bucket: [ 1, 2 ] 310 Chain: [ 3, 4, 5 ] 311 NBucket: 0xAA 312 NChain: 0xBB 313