From: Luca Boccassi Date: Tue, 23 May 2023 00:43:59 +0000 (+0100) Subject: elf2efi: add parameter to increase reserved space for headers X-Git-Tag: v254-rc1~382^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e18e3c4305537ee18a0b61676b0a8f30efedac19;p=thirdparty%2Fsystemd.git elf2efi: add parameter to increase reserved space for headers When building a minimal empty addon it would not have enough space to append sections. Add an option that will later be used to reserve enough space. --- diff --git a/tools/elf2efi.py b/tools/elf2efi.py index 6179ba82132..20d25321c4d 100755 --- a/tools/elf2efi.py +++ b/tools/elf2efi.py @@ -512,10 +512,11 @@ def elf2efi(args: argparse.Namespace): 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 @@ -578,6 +579,12 @@ def main(): 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())