Re: [PATCH 0/3] efi/libstub: reduce size by optimizing GUID storage
From: Ard Biesheuvel
Date: Fri Sep 04 2026 - 12:56:49 EST
On Thu, 3 Sep 2026, at 23:25, Vincent Mailhol wrote:
> The EFI stub is size-sensitive. Several call sites currently pass GUID
> macro addresses directly, or keep GUID objects as automatic local
> variables. With gcc, this materializes the GUID at the call site,
> resulting in several assembly instructions. Using static storage instead
> emits 16 bytes of GUID data and only one instruction to pass its
> address.
>
> The first two patches convert direct GUID references and automatic GUID
> variables to static storage. The last patch factors GUID objects that
> are shared within the same translation unit.
>
> For the full series, on an x86_64 build with gcc 15.3.0, bloat-o-meter
> reports:
>
> add/remove: 21/0 grow/shrink: 0/12 up/down: 400/-1200 (-800)
> Function old new delta
> tbl_guid - 32 +32
> pci_proto - 32 +32
> guid - 32 +32
> cc_guid - 32 +32
> tpm2_guid - 16 +16
> text_to_dp_guid - 16 +16
> tcg2_guid - 16 +16
> smbios_guid - 16 +16
> rng_table_guid - 16 +16
> rng_proto - 16 +16
> rng_algo_raw - 16 +16
> proto - 16 +16
> linux_eventlog_guid - 16 +16
> lf2_proto_guid - 16 +16
> info_guid - 16 +16
> graphics_output_guid - 16 +16
> fs_proto - 16 +16
> edid_discovered_guid - 16 +16
> edid_active_guid - 16 +16
> console_out_device_guid - 16 +16
> apple_set_os_guid - 16 +16
> efi_get_memory_map 707 696 -11
> efi_pci_disable_bridge_busmaster 1199 1184 -15
> efi_get_random_bytes 216 188 -28
> efi_remap_image 357 328 -29
> efi_load_initrd 1113 1065 -48
> efi_get_smbios_record 283 226 -57
> efi_random_get_seed 1368 1297 -71
> efi_measure_tagged_event 935 854 -81
> efi_retrieve_eventlog 1686 1570 -116
> handle_cmdline_files 2501 2341 -160
> efi_stub_entry 4180 3953 -227
> efi_setup_graphics 2210 1853 -357
> Total: Before=29223, After=28423, chg -2.74%
>
> See this as my penitence for adding the BLI feature: I am giving you
> back the bytes that I consumed, and even more.
>
Thanks :-)
It would be nice if we could rely on SHF_MERGE sections here, but that
doesn't seem tractable in the context of the stub.
> Signed-off-by: Vincent Mailhol <mailhol@xxxxxxxxxx>
> ---
> Vincent Mailhol (3):
> efi/libstub: move direct GUID references to static storage
> efi/libstub: make local GUID variables static
> efi/libstub: factor shared static GUID variables
>
Applied to efi/next