1 ## For regular sections, it is common to specify `Size` and/or `Content` fields in YAML.
2 ## Here we test the behavior in different cases.
4 ## In this case, we have both `Content` and `Size` fields specified and `Size`
5 ## is less than content size. Check we report an error.
7 # RUN: not yaml2obj --docnum=1 %s -o %t1 2>&1 | FileCheck %s --check-prefix=ERR
8 # ERR: error: Section size must be greater than or equal to the content size
22 ## In this case, we have both `Content` and `Size` fields specified and
23 ## `Size` is equal to the content size. We check that this is allowed and
24 ## that the output section has a correct size value.
26 # RUN: yaml2obj --docnum=2 %s -o %t2
27 # RUN: llvm-readobj --section-data -S %t2 | FileCheck %s --check-prefix=CASE2
30 # CASE2-NEXT: Type: SHT_PROGBITS
33 # CASE2-NEXT: Address: 0x0
34 # CASE2-NEXT: Offset: 0x180
38 # CASE2-NEXT: AddressAlignment: 0
39 # CASE2-NEXT: EntrySize: 0
40 # CASE2-NEXT: SectionData (
41 # CASE2-NEXT: 0000: FF
56 ## Check we can specify only `Content`.
58 # RUN: yaml2obj --docnum=3 %s -o %t3
59 # RUN: llvm-readobj --section-data -S %t3 | FileCheck %s --check-prefix=CASE2
72 ## Check we can specify only `Size`.
74 # RUN: yaml2obj --docnum=4 %s -o %t4
75 # RUN: llvm-readobj --section-data -S %t4 | FileCheck %s --check-prefix=CASE3
78 # CASE3-NEXT: Type: SHT_PROGBITS
81 # CASE3-NEXT: Address: 0x0
82 # CASE3-NEXT: Offset: 0x180
86 # CASE3-NEXT: AddressAlignment: 0
87 # CASE3-NEXT: EntrySize: 0
88 # CASE3-NEXT: SectionData (
89 # CASE3-NEXT: 0000: 00
103 ## Check we can specify both `Size` and `Content` when size is greater
104 ## than content size. In this case zeroes are added as padding
105 ## after the specified content.
107 # RUN: yaml2obj --docnum=5 %s -o %t5
108 # RUN: llvm-readobj --section-data -S %t5 | FileCheck %s --check-prefix=CASE4
111 # CASE4-NEXT: Type: SHT_PROGBITS
112 # CASE4-NEXT: Flags [
114 # CASE4-NEXT: Address: 0x0
115 # CASE4-NEXT: Offset: 0x180
116 # CASE4-NEXT: Size: 3
117 # CASE4-NEXT: Link: 0
118 # CASE4-NEXT: Info: 0
119 # CASE4-NEXT: AddressAlignment: 0
120 # CASE4-NEXT: EntrySize: 0
121 # CASE4-NEXT: SectionData (
122 # CASE4-NEXT: 0000: FF0000
137 ## Check we emit an empty section if neither 'Content' nor 'Size' were set.
139 # RUN: yaml2obj --docnum=6 %s -o %t6
140 # RUN: llvm-readobj %t6 --sections | FileCheck %s --check-prefix=CASE5
143 # CASE5-NEXT: Type: SHT_PROGBITS
144 # CASE5-NEXT: Flags [
146 # CASE5-NEXT: Address: 0x0
147 # CASE5-NEXT: Offset: 0x180
148 # CASE5-NEXT: Size: 0
160 # RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERR2
172 Content: 0000000000000000
175 # ERR2: error: Section size must be greater than or equal to the content size
176 # ERR2-NEXT: - Name: .data
178 # ERR2-NEXT: yaml2obj: Failed to parse YAML file!