mirror of
https://github.com/systemd/systemd
synced 2024-10-15 20:45:09 +00:00
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.
This commit is contained in:
parent
b6f2e68602
commit
e18e3c4305
|
@ -512,10 +512,11 @@ def elf2efi(args: argparse.Namespace):
|
||||||
opt.SizeOfImage = align_to(
|
opt.SizeOfImage = align_to(
|
||||||
sections[-1].VirtualAddress + sections[-1].VirtualSize, SECTION_ALIGNMENT
|
sections[-1].VirtualAddress + sections[-1].VirtualSize, SECTION_ALIGNMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
opt.SizeOfHeaders = align_to(
|
opt.SizeOfHeaders = align_to(
|
||||||
PE_OFFSET
|
PE_OFFSET
|
||||||
+ coff.SizeOfOptionalHeader
|
+ coff.SizeOfOptionalHeader
|
||||||
+ sizeof(PeSection) * coff.NumberOfSections,
|
+ sizeof(PeSection) * max(coff.NumberOfSections, args.minimum_sections),
|
||||||
FILE_ALIGNMENT,
|
FILE_ALIGNMENT,
|
||||||
)
|
)
|
||||||
# DYNAMIC_BASE|NX_COMPAT|HIGH_ENTROPY_VA or DYNAMIC_BASE|NX_COMPAT
|
# DYNAMIC_BASE|NX_COMPAT|HIGH_ENTROPY_VA or DYNAMIC_BASE|NX_COMPAT
|
||||||
|
@ -578,6 +579,12 @@ def main():
|
||||||
type=argparse.FileType("wb"),
|
type=argparse.FileType("wb"),
|
||||||
help="Output PE/EFI file",
|
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())
|
elf2efi(parser.parse_args())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue