[PATCH 0/3] efi/libstub: reduce size by optimizing GUID storage
From: Vincent Mailhol
Date: Thu Sep 03 2026 - 17:26:27 EST
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.
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
drivers/firmware/efi/libstub/efi-stub-entry.c | 2 +-
drivers/firmware/efi/libstub/efi-stub-helper.c | 10 +++++-----
drivers/firmware/efi/libstub/efi-stub.c | 2 +-
drivers/firmware/efi/libstub/file.c | 8 ++++----
drivers/firmware/efi/libstub/gop.c | 17 ++++++++++-------
drivers/firmware/efi/libstub/kaslr.c | 2 +-
drivers/firmware/efi/libstub/mem.c | 2 +-
drivers/firmware/efi/libstub/pci.c | 2 +-
drivers/firmware/efi/libstub/random.c | 8 ++++----
drivers/firmware/efi/libstub/riscv.c | 2 +-
drivers/firmware/efi/libstub/smbios.c | 3 ++-
drivers/firmware/efi/libstub/tpm.c | 8 ++++----
drivers/firmware/efi/libstub/unaccepted_memory.c | 2 +-
drivers/firmware/efi/libstub/x86-stub.c | 13 +++++++------
drivers/firmware/efi/libstub/zboot.c | 3 ++-
15 files changed, 45 insertions(+), 39 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260903-libstub_guid_cleanup-7aad27f1c0c5
Best regards,
--
Vincent Mailhol <mailhol@xxxxxxxxxx>