]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: increase default number of available sections for the stub
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Jul 2024 08:46:39 +0000 (10:46 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 10 Sep 2024 19:47:00 +0000 (04:47 +0900)
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
src/boot/efi/meson.build

index e90debdd3e01e636fcceb29aedb00c29b74cb546..46e3ac55f7890ab784f85902c427c9536ac1b078 100644 (file)
@@ -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]')
index d98d2de281709d8e06d4efa3e28ee3b83669c00c..ce2e798daf1d22bc0c33f250ea0c1792bd1f7387 100644 (file)
@@ -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@',