1## Check how yaml2obj produces .stack_sizes sections. 2 3## Test the following cases when the .stack_sizes Content field is specified: 4## 1) We can produce a .stack_sizes section from a description with 5## a valid section content. 6## 2) We can produce an incorrect .stack_sizes section from a description with 7## a broken (truncated) section content. 8## 3) We can produce an empty .stack_sizes section from a description with 9## empty section content. 10 11# RUN: yaml2obj --docnum=1 %s -o %t1 12# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s 13 14## Case 1: valid content. 15# CHECK: Section { 16# CHECK: Index: 1 17# CHECK-NEXT: Name: .stack_sizes (1) 18# CHECK-NEXT: Type: SHT_PROGBITS (0x1) 19# CHECK-NEXT: Flags [ (0x0) 20# CHECK-NEXT: ] 21# CHECK-NEXT: Address: 0x0 22# CHECK-NEXT: Offset: 0x40 23# CHECK-NEXT: Size: 9 24# CHECK-NEXT: Link: 0 25# CHECK-NEXT: Info: 0 26# CHECK-NEXT: AddressAlignment: 0 27# CHECK-NEXT: EntrySize: 0 28# CHECK-NEXT: SectionData ( 29# CHECK-NEXT: 0000: 10000000 00000000 20 30# CHECK-NEXT: ) 31# CHECK-NEXT: } 32 33## Case 2: truncated content. 34# CHECK: Name: .stack_sizes 35# CHECK: Size: 36# CHECK-SAME: 8 37# CHECK: SectionData ( 38# CHECK-NEXT: 0000: 10000000 00000000 39 40## Case 3: empty content. 41# CHECK: Name: .stack_sizes 42# CHECK: Size: 43# CHECK-SAME: 0 44 45--- !ELF 46FileHeader: 47 Class: ELFCLASS64 48 Data: ELFDATA2LSB 49 Type: ET_EXEC 50Sections: 51## Valid. 52 - Name: '.stack_sizes (1)' 53 Type: SHT_PROGBITS 54 Content: "100000000000000020" 55## Truncated. 56 - Name: '.stack_sizes (2)' 57 Type: SHT_PROGBITS 58 Content: "1000000000000000" 59## Empty. 60 - Name: '.stack_sizes (3)' 61 Type: SHT_PROGBITS 62 Content: "" 63 64## Check we can describe .stack_sizes section using <address, size> pairs. 65 66# RUN: yaml2obj --docnum=2 -D BITS=64 -D ENCODE=LSB %s -o %t2.le64 67# RUN: llvm-readobj --sections --section-data %t2.le64 | FileCheck %s --check-prefix=ENTRIES-LE64-BOTH 68# RUN: yaml2obj --docnum=2 -D BITS=64 -D ENCODE=MSB %s -o %t2.be64 69# RUN: llvm-readobj --sections --section-data %t2.be64 | FileCheck %s --check-prefix=ENTRIES-BE64-BOTH 70# RUN: yaml2obj --docnum=2 -D BITS=32 -D ENCODE=LSB %s -o %t2.le32 71# RUN: llvm-readobj --sections --section-data %t2.le32 | FileCheck %s --check-prefix=ENTRIES-LE32-BOTH 72# RUN: yaml2obj --docnum=2 -D BITS=32 -D ENCODE=MSB %s -o %t2.be32 73# RUN: llvm-readobj --sections --section-data %t2.be32 | FileCheck %s --check-prefix=ENTRIES-BE32-BOTH 74 75# ENTRIES-LE64-BOTH: Name: .stack_sizes 76# ENTRIES-LE64-BOTH: SectionData ( 77# ENTRIES-LE64-BOTH-NEXT: 0000: 10000000 00000000 20300000 00000000 | 78# ENTRIES-LE64-BOTH-NEXT: 0010: 0040 | 79 80# ENTRIES-BE64-BOTH: Name: .stack_sizes 81# ENTRIES-BE64-BOTH: SectionData ( 82# ENTRIES-BE64-BOTH-NEXT: 0000: 00000000 00000010 20000000 00000000 | 83# ENTRIES-BE64-BOTH-NEXT: 0010: 3040 84 85# ENTRIES-LE32-BOTH: Name: .stack_sizes 86# ENTRIES-LE32-BOTH: SectionData ( 87# ENTRIES-LE32-BOTH-NEXT: 0000: 10000000 20300000 0040 | 88 89# ENTRIES-BE32-BOTH: Name: .stack_sizes 90# ENTRIES-BE32-BOTH: SectionData ( 91# ENTRIES-BE32-BOTH-NEXT: 0000: 00000010 20000000 3040 | 92 93--- !ELF 94FileHeader: 95 Class: ELFCLASS[[BITS]] 96 Data: ELFDATA2[[ENCODE]] 97 Type: ET_EXEC 98Sections: 99 - Name: .stack_sizes 100 Type: SHT_PROGBITS 101 Entries: 102 - Address: 0x10 103 Size: 0x20 104 - Address: 0x30 105 Size: 0x40 106 107## Check we can omit the "Address" tag. In this case the address will be zero. 108 109# RUN: yaml2obj --docnum=3 %s -o %t3 110# RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=ENTRIES-NOADDR 111 112# ENTRIES-NOADDR: Name: .stack_sizes 113# ENTRIES-NOADDR: SectionData ( 114# ENTRIES-NOADDR-NEXT: 0000: 00000000 00000000 10000000 00000000 | 115# ENTRIES-NOADDR-NEXT: 0010: 0020 | 116 117--- !ELF 118FileHeader: 119 Class: ELFCLASS64 120 Data: ELFDATA2LSB 121 Type: ET_EXEC 122Sections: 123 - Name: .stack_sizes 124 Type: SHT_PROGBITS 125 Entries: 126 - Size: 0x10 127 - Size: 0x20 128 129## Check that "Size" tag is mandatory when we describe .stack_sizes using "Entries". 130 131# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-NOSIZE 132 133# ENTRIES-NOSIZE: error: missing required key 'Size' 134 135--- !ELF 136FileHeader: 137 Class: ELFCLASS64 138 Data: ELFDATA2LSB 139 Type: ET_EXEC 140Sections: 141 - Name: .stack_sizes 142 Type: SHT_PROGBITS 143 Entries: 144 - Address: 0x10 145 146## Check we can't use both "Content" and "Entries" tags at the same time. 147 148# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-CONTENT 149 150# ENTRIES-AND-CONTENT: error: "Entries" cannot be used with "Content" or "Size" 151 152--- !ELF 153FileHeader: 154 Class: ELFCLASS64 155 Data: ELFDATA2LSB 156 Type: ET_EXEC 157Sections: 158 - Name: .stack_sizes 159 Type: SHT_PROGBITS 160 Content: "00" 161 Entries: 162 - Address: 0x10 163 Size: 0x20 164 165## Check we emit an empty section if neither "Content", "Size" nor "Entries" were set. 166 167# RUN: yaml2obj --docnum=6 %s -o %t6 168# RUN: llvm-readelf --sections %t6 | FileCheck %s --check-prefix=NO-TAGS 169 170# NO-TAGS: [Nr] Name Type Address Off Size 171# NO-TAGS: [ 1] .stack_sizes PROGBITS 0000000000000000 000040 000000 172 173--- !ELF 174FileHeader: 175 Class: ELFCLASS64 176 Data: ELFDATA2LSB 177 Type: ET_EXEC 178Sections: 179 - Name: .stack_sizes 180 Type: SHT_PROGBITS 181 182## Check we can't use both "Size" and "Entries" tags at the same time. 183 184# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-SIZE 185 186# ENTRIES-AND-SIZE: error: "Entries" cannot be used with "Content" or "Size" 187 188--- !ELF 189FileHeader: 190 Class: ELFCLASS64 191 Data: ELFDATA2LSB 192 Type: ET_EXEC 193Sections: 194 - Name: .stack_sizes 195 Type: SHT_PROGBITS 196 Size: 0x1 197 Entries: 198 - Address: 0x10 199 Size: 0x20 200 201## Check we can use only "Size" to create .stack_sizes section. 202 203# RUN: yaml2obj --docnum=8 %s -o %t8 204# RUN: llvm-readobj --sections --section-data %t8 | FileCheck %s --check-prefix=SIZE 205 206# SIZE: Name: .stack_sizes 207# SIZE: Size: 208# SIZE-SAME: 17 209# SIZE: SectionData ( 210# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 | 211# SIZE-NEXT: 0010: 00 | 212# SIZE-NEXT: ) 213 214--- !ELF 215FileHeader: 216 Class: ELFCLASS64 217 Data: ELFDATA2LSB 218 Type: ET_EXEC 219Sections: 220 - Name: .stack_sizes 221 Type: SHT_PROGBITS 222 Size: 0x11 223 224## Check we can use "Size" and "Content" together to create .stack_sizes section. 225 226# RUN: yaml2obj --docnum=9 %s -o %t9 227# RUN: llvm-readobj --sections --section-data %t9 | FileCheck %s --check-prefix=SIZE-CONTENT 228 229# SIZE-CONTENT: Name: .stack_sizes 230# SIZE-CONTENT: Size: 231# SIZE-CONTENT-SAME: 5 232# SIZE-CONTENT: SectionData ( 233# SIZE-CONTENT-NEXT: 0000: 11223300 00 | 234# SIZE-CONTENT-NEXT: ) 235 236--- !ELF 237FileHeader: 238 Class: ELFCLASS64 239 Data: ELFDATA2LSB 240 Type: ET_EXEC 241Sections: 242 - Name: .stack_sizes 243 Type: SHT_PROGBITS 244 Size: 0x5 245 Content: "112233" 246 247# RUN: not yaml2obj --docnum=10 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR 248 249# SIZE-CONTENT-ERR: error: Section size must be greater than or equal to the content size 250 251--- !ELF 252FileHeader: 253 Class: ELFCLASS64 254 Data: ELFDATA2LSB 255 Type: ET_EXEC 256Sections: 257 - Name: .stack_sizes 258 Type: SHT_PROGBITS 259 Size: 0x1 260 Content: "1122" 261 262## Check we can describe multiple .stack_sizes sections using unique suffixes. 263 264# RUN: yaml2obj --docnum=11 %s -o %t11 265# RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=UNIQUE 266 267# UNIQUE: Name: .stack_sizes 268# UNIQUE: SectionData ( 269# UNIQUE-NEXT: 0000: 10000000 00000000 20 | 270 271# UNIQUE: Name: .stack_sizes 272# UNIQUE: SectionData ( 273# UNIQUE-NEXT: 0000: 30000000 00000000 40 | 274 275--- !ELF 276FileHeader: 277 Class: ELFCLASS64 278 Data: ELFDATA2LSB 279 Type: ET_EXEC 280Sections: 281 - Name: '.stack_sizes (1)' 282 Type: SHT_PROGBITS 283 Entries: 284 - Address: 0x10 285 Size: 0x20 286 - Name: '.stack_sizes (2)' 287 Type: SHT_PROGBITS 288 Entries: 289 - Address: 0x30 290 Size: 0x40 291