1## Check how "Content", "Size" and "Entries" keys can be used to
2## describe a content for relocations sections.
3
4## Check we can use the "Content" key alone.
5
6# RUN: yaml2obj -DCONTENT="01234567" %s -o %t1.content
7# RUN: llvm-readobj --sections --section-data %t1.content | \
8# RUN:   FileCheck %s --check-prefix=RAW -DDATA="01234567"
9
10# RAW:      Name: .dynamic
11# RAW:      EntrySize:
12# RAW-SAME:            255{{$}}
13# RAW:      SectionData (
14# RAW-NEXT:   0000: [[DATA]] |
15# RAW-NEXT: )
16
17--- !ELF
18FileHeader:
19  Class: ELFCLASS64
20  Data:  ELFDATA2LSB
21  Type:  ET_EXEC
22Sections:
23  - Name:    .dynamic
24    Type:    SHT_DYNAMIC
25    EntSize: 0xff
26    Content: [[CONTENT=<none>]]
27    Size:    [[SIZE=<none>]]
28    Entries: [[ENTRIES=<none>]]
29
30## Check we can use the "Size" key alone.
31
32# RUN: yaml2obj -DSIZE=3 %s -o %t1.size
33# RUN: llvm-readobj --sections --section-data %t1.size | \
34# RUN:   FileCheck %s --check-prefix=RAW -DDATA="000000"
35
36## Check we can use the "Content" key with the "Size" key when the size is greater
37## than or equal to the content size.
38
39# RUN: not yaml2obj -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
40# RUN:   FileCheck %s --check-prefix=CONTENT-SIZE-ERR
41
42# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
43
44# RUN: yaml2obj -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
45# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
46# RUN:   FileCheck %s --check-prefix=RAW -DDATA="0011"
47
48# RUN: yaml2obj -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
49# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
50# RUN:   FileCheck %s --check-prefix=RAW -DDATA="001100"
51
52## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
53
54# RUN: not yaml2obj -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
55# RUN:   FileCheck %s --check-prefix=ENT-ERR
56# RUN: not yaml2obj -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
57# RUN:   FileCheck %s --check-prefix=ENT-ERR
58
59# ENT-ERR: error: "Entries" cannot be used with "Content" or "Size"
60
61## Check we create an empty section when none of "Size", "Content" or "Entries" are specified.
62
63# RUN: yaml2obj %s -o %t.empty.o
64# RUN: llvm-readelf --sections --section-data %t.empty.o | \
65# RUN:   FileCheck %s --check-prefix=EMPTY-SEC
66
67# EMPTY-SEC: [Nr] Name     Type    Address          Off    Size
68# EMPTY-SEC: [ 1] .dynamic DYNAMIC 0000000000000000 000040 000000
69