diff --git a/meson_options.txt b/meson_options.txt index e90debdd3e..46e3ac55f7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -486,6 +486,10 @@ option('efi-color-highlight', type : 'string', value : 'black,lightgray', description : 'boot loader color for selected entries') option('efi-color-edit', type : 'string', value : 'black,lightgray', description : 'boot loader color for option line edit') +option('efi-stub-extra-sections', type : 'integer', value : 30, + description : 'minimum number of sections to keep free in stub PE header') +option('efi-addon-extra-sections', type : 'integer', value : 15, + description : 'minimum number of sections to keep free in addon PE header') option('bashcompletiondir', type : 'string', description : 'directory for bash completion scripts ["no" disables]') diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index d98d2de281..ce2e798daf 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -379,9 +379,17 @@ endforeach foreach efi_elf_binary : efi_elf_binaries name = efi_elf_binary.name() name += name.startswith('systemd-boot') ? '.efi' : '.efi.stub' + # For the addon, given it's empty, we need to explicitly reserve space in the header to account for # the sections that ukify will add. - minimum_sections = name.endswith('.stub') ? '15' : '0' + if name.startswith('linux') + minimum_sections = get_option('efi-stub-extra-sections') + elif name.startswith('addon') + minimum_sections = get_option('efi-addon-extra-sections') + else + minimum_sections = 0 + endif + exe = custom_target( name, output : name, @@ -396,7 +404,7 @@ foreach efi_elf_binary : efi_elf_binaries '--efi-major=1', '--efi-minor=1', '--subsystem=10', - '--minimum-sections=' + minimum_sections, + '--minimum-sections=@0@'.format(minimum_sections), '--copy-sections=.sbat,.sdmagic,.osrel', '@INPUT@', '@OUTPUT@',