From 41a9a502a1607f5b68f4f87f08807884e824fc1a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Jul 2024 10:46:39 +0200 Subject: [PATCH] meson: increase default number of available sections for the stub Now that we have multi-profile UKIs people likely want to stick more PE sections into them than before. Hence, bump the number of available PE section slots to 30 (up from 15). Also, make this configurable at build time since some folks probably want even more, and others don't want this at all. (pre-allocating too many shouldn't matter too much btw, I'd advise everyone to overshoot, except maybe on the tiniest of embedded boards) --- meson_options.txt | 4 ++++ src/boot/efi/meson.build | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index e90debdd3e0..46e3ac55f78 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 d98d2de2817..ce2e798daf1 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@',