1## Check how the "Content", "Size" and "Members" keys can be used to
2## describe the content for group sections.
3
4## Check we can use the "Content" key with the "Size" key when the size is greater
5## than or equal to the content size.
6
7# RUN: not yaml2obj -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
8# RUN:   FileCheck %s --check-prefix=CONTENT-SIZE-ERR
9
10# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
11
12--- !ELF
13FileHeader:
14  Class: ELFCLASS64
15  Data:  ELFDATA2LSB
16  Type:  ET_DYN
17Sections:
18  - Name:    .group
19    Type:    SHT_GROUP
20    Link:    0x1
21    Info:    0x2
22    Size:    [[SIZE=<none>]]
23    Content: [[CONTENT=<none>]]
24    Members: [[MEMBERS=<none>]]
25
26# RUN: yaml2obj -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
27# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
28# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
29
30# RUN: yaml2obj -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
31# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
32# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
33
34# CHECK-CONTENT:      Name: .group
35# CHECK-CONTENT-NEXT: Type: SHT_GROUP
36# CHECK-CONTENT-NEXT: Flags [
37# CHECK-CONTENT-NEXT: ]
38# CHECK-CONTENT-NEXT: Address:
39# CHECK-CONTENT-NEXT: Offset:
40# CHECK-CONTENT-NEXT: Size:
41# CHECK-CONTENT-NEXT: Link: 1
42# CHECK-CONTENT-NEXT: Info: 2
43# CHECK-CONTENT-NEXT: AddressAlignment:
44# CHECK-CONTENT-NEXT: EntrySize: 4
45# CHECK-CONTENT-NEXT: SectionData (
46# CHECK-CONTENT-NEXT:   0000: [[DATA]] |
47# CHECK-CONTENT-NEXT: )
48
49## Check we can use the "Size" key alone to create the section.
50
51# RUN: yaml2obj -DSIZE=3 %s -o %t.size.o
52# RUN: llvm-readobj --sections --section-data %t.size.o | \
53# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
54
55## Check we can use the "Content" key alone to create the section.
56
57# RUN: yaml2obj -DCONTENT="'112233'" %s -o %t.content.o
58# RUN: llvm-readobj --sections --section-data %t.content.o | \
59# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
60
61## Check we can't use the "Members" key together with the "Content" or "Size" keys.
62
63# RUN: not yaml2obj -DSIZE=0 -DMEMBERS="[]" %s 2>&1 | \
64# RUN:   FileCheck %s --check-prefix=MEMBERS-ERR
65# RUN: not yaml2obj -DCONTENT="'00'" -DMEMBERS="[]" %s 2>&1 | \
66# RUN:   FileCheck %s --check-prefix=MEMBERS-ERR
67
68# MEMBERS-ERR: error: "Members" cannot be used with "Content" or "Size"
69
70## Check we create an empty section when none of "Size", "Content" or "Members" are specified.
71
72# RUN: yaml2obj %s -o %t.empty.o
73# RUN: llvm-readelf --sections --section-data %t.empty.o | \
74# RUN:   FileCheck %s --check-prefix=EMPTY-SEC
75
76# EMPTY-SEC: [Nr] Name   Type  Address          Off    Size
77# EMPTY-SEC: [ 1] .group GROUP 0000000000000000 000040 000000
78