54 lines · yaml
1## Check that yaml2obj limits the output size by default to 10 MB.2## Check it is possible to change this limit using the3## --max-size command line option.4 5## One of the often cases to reach the limit is to create a section with a6## 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>&110# RUN: not yaml2obj %s -DSIZE=0x9FFEC1 --docnum=1 -o /dev/null 2>&1 | \11# RUN: FileCheck %s --check-prefix=ERROR12 13# ERROR: error: the desired output size is greater than permitted. Use the --max-size option to change the limit14 15## We use 0xA00008 instead of 0xA00001 here because the section header table16## 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/null18 19--- !ELF20FileHeader:21 Class: ELFCLASS6422 Data: ELFDATA2LSB23 Type: ET_REL24Sections:25 - Name: .section26 Type: SHT_PROGBITS27 Size: [[SIZE]]28 - Name: .strtab29 Type: SHT_PROGBITS30 Size: 0x031 - Name: .shstrtab32 Type: SHT_PROGBITS33 Size: 0x034 35## Another possible case is when an alignment gap inserted36## 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=ERROR38 39--- !ELF40FileHeader:41 Class: ELFCLASS6442 Data: ELFDATA2LSB43 Type: ET_REL44Sections:45 - Name: .foo46 Type: SHT_PROGBITS47 - Name: .bar48 Type: SHT_PROGBITS49 AddressAlign: 0xA0010050 Size: 0x051 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/null54