1## Check that yaml2obj limits the output size by default to 10 MB.
2## Check it is possible to change this limit using the
3## --max-size command line option.
4
5## One of the often cases to reach the limit is to create a section with a
6## large portion of data. Check this case is handled properly.
7
8## 0x9FFEC0 = 0xA00000 (10 MB) - sizeof(Elf_Ehdr) - sizeof(Elf_Shdr) * 4.
9# RUN: yaml2obj %s -DSIZE=0x9FFEC0 --docnum=1 -o /dev/null 2>&1
10# RUN: not yaml2obj %s -DSIZE=0x9FFEC1 --docnum=1 -o /dev/null 2>&1 | \
11# RUN:  FileCheck %s --check-prefix=ERROR
12
13# ERROR: error: the desired output size is greater than permitted. Use the --max-size option to change the limit
14
15## We use 0xA00008 instead of 0xA00001 here because the section header table
16## offset is aligned to 8 bytes, so we need to request 7 more bytes for it.
17# RUN: yaml2obj %s -DSIZE=0x9FFEC1 --docnum=1 --max-size=0xA00008 -o /dev/null
18
19--- !ELF
20FileHeader:
21  Class: ELFCLASS64
22  Data:  ELFDATA2LSB
23  Type:  ET_REL
24Sections:
25  - Name: .section
26    Type: SHT_PROGBITS
27    Size: [[SIZE]]
28  - Name: .strtab
29    Type: SHT_PROGBITS
30    Size: 0x0
31  - Name: .shstrtab
32    Type: SHT_PROGBITS
33    Size: 0x0
34
35## Another possible case is when an alignment gap inserted
36## is too large because of overaligning. Check it is also handled properly.
37# RUN: not yaml2obj %s --docnum=2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERROR
38
39--- !ELF
40FileHeader:
41  Class: ELFCLASS64
42  Data:  ELFDATA2LSB
43  Type:  ET_REL
44Sections:
45  - Name: .foo
46    Type: SHT_PROGBITS
47  - Name:         .bar
48    Type:         SHT_PROGBITS
49    AddressAlign: 0xA00100
50    Size: 0x0
51
52## Check that we can drop the limit with the use of --max-size=0.
53# RUN: yaml2obj --max-size=0 %s --docnum=2 -o /dev/null
54