opt.SizeOfImage = align_to(
sections[-1].VirtualAddress + sections[-1].VirtualSize, SECTION_ALIGNMENT
)
+
opt.SizeOfHeaders = align_to(
PE_OFFSET
+ coff.SizeOfOptionalHeader
- + sizeof(PeSection) * coff.NumberOfSections,
+ + sizeof(PeSection) * max(coff.NumberOfSections, args.minimum_sections),
FILE_ALIGNMENT,
)
# DYNAMIC_BASE|NX_COMPAT|HIGH_ENTROPY_VA or DYNAMIC_BASE|NX_COMPAT
type=argparse.FileType("wb"),
help="Output PE/EFI file",
)
+ parser.add_argument(
+ "--minimum-sections",
+ type=int,
+ default=0,
+ help="Minimum number of sections to leave space for",
+ )
elf2efi(parser.parse_args())