summaryrefslogtreecommitdiff
path: root/scripts/Makefile.thinlto
diff options
context:
space:
mode:
authorVincent Mailhol <mailhol@kernel.org>2026-09-03 23:25:15 +0200
committerArd Biesheuvel <ardb@kernel.org>2026-09-04 18:14:17 +0200
commit8de9cc08fd736b6cec57c4128f8649b1b85804be (patch)
treee88e55cd41151edf4f3432c96c860d987a46f8ab /scripts/Makefile.thinlto
parent42bf9d266e52823c68e416040984edd0f6d62938 (diff)
downloadlinux-next-8de9cc08fd736b6cec57c4128f8649b1b85804be.tar.gz
linux-next-8de9cc08fd736b6cec57c4128f8649b1b85804be.zip
efi/libstub: move direct GUID references to static storage
Some EFI stub call sites pass the address of a GUID macro directly to EFI boot services. With gcc, this makes the compiler materialize the GUID data at the call site, which is wasteful in the size-sensitive EFI stub. For example, consider this program: #include <linux/efi.h> #define GUID \ EFI_GUID(0xaaaaaaaa, 0xbbbb, 0xcccc, \ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd) void foo(const efi_guid_t *guid); void guid_direct(void) { foo(&GUID); } void guid_static(void) { static efi_guid_t guid = GUID; foo(&guid); } For guid_direct(), gcc materializes the GUID on the stack: 0: f3 0f 1e fa endbr64 4: 48 b8 aa aa aa aa bb movabs $0xccccbbbbaaaaaaaa,%rax b: bb cc cc e: 48 83 ec 18 sub $0x18,%rsp 12: 48 89 04 24 mov %rax,(%rsp) 16: 48 89 e7 mov %rsp,%rdi 19: 48 b8 dd dd dd dd dd movabs $0xdddddddddddddddd,%rax 20: dd dd dd 23: 48 89 44 24 08 mov %rax,0x8(%rsp) 28: e8 00 00 00 00 call 2d <guid_direct+0x2d> 2d: 48 83 c4 18 add $0x18,%rsp 31: c3 ret For guid_static(), gcc stores the GUID in .data and emits a RIP-relative address load: 32: f3 0f 1e fa endbr64 36: 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi 3d: e9 00 00 00 00 jmp 42 <guid_static+0x10> Overall, guid_direct() consumes 50 bytes in the .text segment whereas guid_static() needs only 32 bytes in total: 16 bytes in .data and 16 bytes in .text. Move these direct GUID references to function-local static objects and pass their address instead. EFI boot service prototypes take non-const efi_guid_t pointers, so keep the GUID non-const to prevent a -Wdiscarded-qualifiers warning. For an x86_64 build with gcc 15.3.0, bloat-o-meter reports: add/remove: 6/0 grow/shrink: 0/3 up/down: 112/-458 (-346) Function old new delta graphics_output_guid - 32 +32 smbios_guid - 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_stub_entry 4180 4136 -44 efi_get_smbios_record 283 226 -57 efi_setup_graphics 2210 1853 -357 Total: Before=29223, After=28877, chg -1.18% Signed-off-by: Vincent Mailhol <mailhol@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions