1 ## Check how yaml2obj produces .stack_sizes sections.
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.
11 # RUN: yaml2obj --docnum=1 %s -o %t1
12 # RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s
14 ## Case 1: valid content.
17 # CHECK-NEXT: Name: .stack_sizes (1)
18 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
19 # CHECK-NEXT: Flags [ (0x0)
21 # CHECK-NEXT: Address: 0x0
22 # CHECK-NEXT: Offset: 0x40
26 # CHECK-NEXT: AddressAlignment: 0
27 # CHECK-NEXT: EntrySize: 0
28 # CHECK-NEXT: SectionData (
29 # CHECK-NEXT: 0000: 10000000 00000000 20
33 ## Case 2: truncated content.
34 # CHECK: Name: .stack_sizes
37 # CHECK: SectionData (
38 # CHECK-NEXT: 0000: 10000000 00000000
40 ## Case 3: empty content.
41 # CHECK: Name: .stack_sizes
52 - Name: '.stack_sizes (1)'
54 Content: "100000000000000020"
56 - Name: '.stack_sizes (2)'
58 Content: "1000000000000000"
60 - Name: '.stack_sizes (3)'
64 ## Check we can describe .stack_sizes section using <address, size> pairs.
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
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 |
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
85 # ENTRIES-LE32-BOTH: Name: .stack_sizes
86 # ENTRIES-LE32-BOTH: SectionData (
87 # ENTRIES-LE32-BOTH-NEXT: 0000: 10000000 20300000 0040 |
89 # ENTRIES-BE32-BOTH: Name: .stack_sizes
90 # ENTRIES-BE32-BOTH: SectionData (
91 # ENTRIES-BE32-BOTH-NEXT: 0000: 00000010 20000000 3040 |
95 Class: ELFCLASS[[BITS]]
96 Data: ELFDATA2[[ENCODE]]
107 ## Check we can omit the "Address" tag. In this case the address will be zero.
109 # RUN: yaml2obj --docnum=3 %s -o %t3
110 # RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=ENTRIES-NOADDR
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 |
129 ## Check that "Size" tag is mandatory when we describe .stack_sizes using "Entries".
131 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-NOSIZE
133 # ENTRIES-NOSIZE: error: missing required key 'Size'
146 ## Check we can't use both "Content" and "Entries" tags at the same time.
148 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-CONTENT
150 # ENTRIES-AND-CONTENT: error: "Entries" cannot be used with "Content" or "Size"
165 ## Check we emit an empty section if neither "Content", "Size" nor "Entries" were set.
167 # RUN: yaml2obj --docnum=6 %s -o %t6
168 # RUN: llvm-readelf --sections %t6 | FileCheck %s --check-prefix=NO-TAGS
170 # NO-TAGS: [Nr] Name Type Address Off Size
171 # NO-TAGS: [ 1] .stack_sizes PROGBITS 0000000000000000 000040 000000
182 ## Check we can't use both "Size" and "Entries" tags at the same time.
184 # RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-SIZE
186 # ENTRIES-AND-SIZE: error: "Entries" cannot be used with "Content" or "Size"
201 ## Check we can use only "Size" to create .stack_sizes section.
203 # RUN: yaml2obj --docnum=8 %s -o %t8
204 # RUN: llvm-readobj --sections --section-data %t8 | FileCheck %s --check-prefix=SIZE
206 # SIZE: Name: .stack_sizes
209 # SIZE: SectionData (
210 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |
211 # SIZE-NEXT: 0010: 00 |
224 ## Check we can use "Size" and "Content" together to create .stack_sizes section.
226 # RUN: yaml2obj --docnum=9 %s -o %t9
227 # RUN: llvm-readobj --sections --section-data %t9 | FileCheck %s --check-prefix=SIZE-CONTENT
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: )
247 # RUN: not yaml2obj --docnum=10 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR
249 # SIZE-CONTENT-ERR: error: Section size must be greater than or equal to the content size
262 ## Check we can describe multiple .stack_sizes sections using unique suffixes.
264 # RUN: yaml2obj --docnum=11 %s -o %t11
265 # RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=UNIQUE
267 # UNIQUE: Name: .stack_sizes
268 # UNIQUE: SectionData (
269 # UNIQUE-NEXT: 0000: 10000000 00000000 20 |
271 # UNIQUE: Name: .stack_sizes
272 # UNIQUE: SectionData (
273 # UNIQUE-NEXT: 0000: 30000000 00000000 40 |
281 - Name: '.stack_sizes (1)'
286 - Name: '.stack_sizes (2)'