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
21 ## In this case, we have both `Content` and `Size` fields specified and
22 ## `Size` is equal to the content size. We check that this is allowed and
23 ## that the output section has a correct size value.
25 # RUN: yaml2obj --docnum=2 %s -o %t2
26 # RUN: llvm-readobj --section-data -S %t2 | FileCheck %s --check-prefix=CASE2
29 # CASE2-NEXT: Type: SHT_PROGBITS
32 # CASE2-NEXT: Address: 0x0
33 # CASE2-NEXT: Offset: 0x40
37 # CASE2-NEXT: AddressAlignment: 0
38 # CASE2-NEXT: EntrySize: 0
39 # CASE2-NEXT: SectionData (
40 # CASE2-NEXT: 0000: FF
54 ## Check we can specify only `Content`.
56 # RUN: yaml2obj --docnum=3 %s -o %t3
57 # RUN: llvm-readobj --section-data -S %t3 | FileCheck %s --check-prefix=CASE2
69 ## Check we can specify only `Size`.
71 # RUN: yaml2obj --docnum=4 %s -o %t4
72 # RUN: llvm-readobj --section-data -S %t4 | FileCheck %s --check-prefix=CASE3
75 # CASE3-NEXT: Type: SHT_PROGBITS
78 # CASE3-NEXT: Address: 0x0
79 # CASE3-NEXT: Offset: 0x40
83 # CASE3-NEXT: AddressAlignment: 0
84 # CASE3-NEXT: EntrySize: 0
85 # CASE3-NEXT: SectionData (
86 # CASE3-NEXT: 0000: 00
99 ## Check we can specify both `Size` and `Content` when size is greater
100 ## than content size. In this case zeroes are added as padding
101 ## after the specified content.
103 # RUN: yaml2obj --docnum=5 %s -o %t5
104 # RUN: llvm-readobj --section-data -S %t5 | FileCheck %s --check-prefix=CASE4
107 # CASE4-NEXT: Type: SHT_PROGBITS
108 # CASE4-NEXT: Flags [
110 # CASE4-NEXT: Address: 0x0
111 # CASE4-NEXT: Offset: 0x40
112 # CASE4-NEXT: Size: 3
113 # CASE4-NEXT: Link: 0
114 # CASE4-NEXT: Info: 0
115 # CASE4-NEXT: AddressAlignment: 0
116 # CASE4-NEXT: EntrySize: 0
117 # CASE4-NEXT: SectionData (
118 # CASE4-NEXT: 0000: FF0000
132 ## Check we emit an empty section if neither 'Content' nor 'Size' were set.
134 # RUN: yaml2obj --docnum=6 %s -o %t6
135 # RUN: llvm-readobj %t6 --sections | FileCheck %s --check-prefix=CASE5
138 # CASE5-NEXT: Type: SHT_PROGBITS
139 # CASE5-NEXT: Flags [
141 # CASE5-NEXT: Address: 0x0
142 # CASE5-NEXT: Offset: 0x40
143 # CASE5-NEXT: Size: 0
154 # RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERR2
165 Content: 0000000000000000
168 # ERR2: error: Section size must be greater than or equal to the content size
169 # ERR2-NEXT: - Name: .data
171 # ERR2-NEXT: error: failed to parse YAML input