Now the only method to configure ELF section's content and size is to assign a hexadecimal string to the Content field. Unfortunately this way is completely useless when you need to declare a really large section.
To solve this problem this patch adds one more optional field Size to the RawContentSection structure. When yaml2obj generates an ELF file it uses the following algorithm:
- If both Content and Size fields are missed create an empty section.
- If only Content field is missed take section length from the Size field and fill the section by zero.
- If only Size field is missed create a section using data from the Content field.
- If both Content and Size fields are provided validate that the Size value is not less than size of Content data. Than take section length from the Size, fill beginning of the section by Content and the rest by zero.
Examples
- Create a section 0x10000 bytes long filled by zero
Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Size: 0x10000
- Create a section 0x10000 bytes long starting from 'CA' 'FE' 'BA' 'BE'
Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Content: CAFEBABE Size: 0x10000