From 2457ac9d44f3c2a33459eef39989f26d545fcece Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Thu, 3 Sep 2026 23:25:17 +0200 Subject: [PATCH] efi/libstub: factor shared static GUID variables Some GUIDs are used several times in the same translation unit. Factor the duplicated EFI_FILE_SYSTEM_GUID, EFI_RNG_PROTOCOL_GUID and EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID objects at file scope within their translation units. Leave the single-use GUID objects at function scope. For an x86_64 build with gcc 15.3.0, bloat-o-meter reports: add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-48 (-48) Function old new delta rng_proto 32 16 -16 graphics_output_guid 32 16 -16 fs_proto 32 16 -16 Total: Before=28471, After=28423, chg -0.17% Signed-off-by: Vincent Mailhol Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/file.c | 4 ++-- drivers/firmware/efi/libstub/gop.c | 4 ++-- drivers/firmware/efi/libstub/random.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c index 0dff9e08d49e..b2601e284695 100644 --- a/drivers/firmware/efi/libstub/file.c +++ b/drivers/firmware/efi/libstub/file.c @@ -29,6 +29,8 @@ */ #define EFI_READ_CHUNK_SIZE SZ_1M +static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; + struct finfo { efi_file_info_t info; efi_char16_t filename[MAX_FILENAME_SIZE]; @@ -74,7 +76,6 @@ static efi_status_t efi_open_file(efi_file_protocol_t *volume, static efi_status_t efi_open_volume(efi_loaded_image_t *image, efi_file_protocol_t **fh) { - static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; efi_simple_file_system_protocol_t *io; efi_status_t status; @@ -129,7 +130,6 @@ static efi_status_t efi_open_device_path(efi_file_protocol_t **volume, struct finfo *fi) { static efi_guid_t text_to_dp_guid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; - static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; static efi_device_path_from_text_protocol_t *text_to_dp = NULL; efi_device_path_protocol_t *initrd_dp; efi_simple_file_system_protocol_t *io; diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index acc2827ba4d7..fa324d4abcaa 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -24,6 +24,8 @@ enum efi_cmdline_option { EFI_CMDLINE_LIST }; +static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + static struct { enum efi_cmdline_option option; union { @@ -425,7 +427,6 @@ static void setup_edid_info(struct edid_info *edid, u32 gop_size_of_edid, u8 *go static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_handle_t handles[], efi_graphics_output_protocol_t **found_gop) { - static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static efi_guid_t console_out_device_guid = EFI_CONSOLE_OUT_DEVICE_GUID; efi_graphics_output_protocol_t *first_gop; efi_handle_t h, first_gop_handle; @@ -481,7 +482,6 @@ static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_ha efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid) { - static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static efi_guid_t edid_active_guid = EFI_EDID_ACTIVE_PROTOCOL_GUID; static efi_guid_t edid_discovered_guid = EFI_EDID_DISCOVERED_PROTOCOL_GUID; efi_handle_t *handles __free(efi_pool) = NULL; diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index 3ca230fa7aa3..d63262d36e47 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -8,6 +8,8 @@ #include "efistub.h" +static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; + typedef union efi_rng_protocol efi_rng_protocol_t; union efi_rng_protocol { @@ -38,7 +40,6 @@ union efi_rng_protocol { */ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) { - static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_status_t status; efi_rng_protocol_t *rng = NULL; @@ -64,7 +65,6 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) */ efi_status_t efi_random_get_seed(void) { - static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; static efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; static efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; struct linux_efi_random_seed *prev_seed, *seed = NULL; -- knotmirror 0.0.1