From b2a33041799bafda7b0fd9d02340da9668019e92 Mon Sep 17 00:00:00 2001 From: Ivaylo Ivanov Date: Wed, 27 May 2026 16:08:17 +0000 Subject: [PATCH] arch: discard runtime-unused metadata sections The toolchain emits several sections that have no meaning for a flat binary bootloader: .eh_frame DWARF unwind tables (we never unwind) .note.gnu.property BTI/PAC ELF markers (lost at objcopy) .note.gnu.build-id debug identity (lost at objcopy) .comment compiler version string .ARM.attributes ABI metadata Gcc emits roughly 7-8 KB of .eh_frame by default for a build of this size; the others are smaller but equally pointless. Just drop all of them in the linker scripts. Net effect on dreamlte_defconfig w/ empty embedded blobs: 61960 -> ~54000 bytes. Stonks. --- arch/aarch64/linker.lds.S | 10 ++++++++++ arch/arm/linker.lds.S | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/aarch64/linker.lds.S b/arch/aarch64/linker.lds.S index 30de9b0..3bd6a8f 100644 --- a/arch/aarch64/linker.lds.S +++ b/arch/aarch64/linker.lds.S @@ -89,4 +89,14 @@ SECTIONS #ifdef CONFIG_LINUX_KRNL_HEADER_IMG _kernel_size = _stack_end - _start; #endif + + /* size optimization for flat binaries */ + /DISCARD/ : { + *(.eh_frame) + *(.eh_frame.*) + *(.note.gnu.property) + *(.note.gnu.build-id) + *(.comment) + *(.ARM.attributes) + } } diff --git a/arch/arm/linker.lds.S b/arch/arm/linker.lds.S index bd415d4..507c34f 100644 --- a/arch/arm/linker.lds.S +++ b/arch/arm/linker.lds.S @@ -45,4 +45,14 @@ SECTIONS } _end = .; + + /* size optimization for flat binaries. */ + /DISCARD/ : { + *(.eh_frame) + *(.eh_frame.*) + *(.note.gnu.property) + *(.note.gnu.build-id) + *(.comment) + *(.ARM.attributes) + } }