Re: [RFC PATCH v1 03/11] scripts, unwind: Add build-time .eh_frame minifier
From: bot+bpf-ci
Date: Sun Nov 22 2026 - 19:40:32 EST
> scripts, unwind: Add build-time .eh_frame minifier
TL;DR:
- On big-endian build hosts, min_eh_frame may silently skip minifying every
object, so the size reduction is lost
- Kconfig depends on UNWINDER_DWARF_CFI, which is defined only later in the
series
- min_eh_frame is missing from scripts/.gitignore
> diff --git a/arch/Kconfig b/arch/Kconfig
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -528,6 +528,16 @@ config HAVE_UNWIND_USER_CFI
> select UNWIND_USER
> select UNWIND_DWARF_CFI
>
> +config UNWINDER_DWARF_CFI_MINIFY
> + bool "Minify .eh_frame tables at build time"
> + depends on UNWINDER_DWARF_CFI
A subsystem pattern flags this as potentially concerning: a depends on
naming a symbol that no Kconfig file defines.
UNWINDER_DWARF_CFI is not defined anywhere at this commit, so this option
evaluates to n on every architecture. That leaves the hostprogs-always
entry in scripts/Makefile, the cmd_min_eh_frame hooks in Makefile.lib,
Makefile.build, Makefile.vmlinux_o and rust/Makefile, and
scripts/min_eh_frame.c itself unreachable here, so the results quoted in
the commit message cannot be reproduced from this commit.
The symbol is defined later in the series, in 6cf5792e969e ("x86/unwind:
Add Minimal DWARF CFI kernel unwinder"), efdfa5f38673 ("arm64/unwind: Add
Minimal DWARF CFI kernel unwinder") and 90a680847a32 ("riscv/unwind: Add
Minimal DWARF CFI kernel unwinder"), so this looks like a forward
reference rather than a misspelling, and bisection is not broken.
Would it make sense to reorder the series so the unwinder Kconfig symbol
comes before its consumers?
> + default y
> + help
> + Strip unneeded callee-saved register opcodes and coalesce PC-advance
> + bytecodes in .eh_frame sections at build time, reducing kernel unwind
> + table memory usage while ensuring only Minimal DWARF CFA bytecodes
> + remain in vmlinux and modules.
[ ... ]
> diff --git a/scripts/Makefile b/scripts/Makefile
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -12,6 +12,7 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
> hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
> hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
> hostprogs-always-$(CONFIG_TRACEPOINTS) += tracepoint-update
> +hostprogs-always-$(CONFIG_UNWINDER_DWARF_CFI_MINIFY) += min_eh_frame
Should /min_eh_frame be added to scripts/.gitignore?
Every other host program built here has an entry there (/kallsyms,
/sorttable, /tracepoint-update, /insert-sys-cert, and so on), and
git check-ignore -v scripts/min_eh_frame matches no rule. After an in-tree
build with the option enabled, the binary shows up as untracked and could be
picked up by git add -A. No later commit in the series adds the entry.
[ ... ]
> diff --git a/scripts/min_eh_frame.c b/scripts/min_eh_frame.c
> new file mode 100644
> --- /dev/null
> +++ b/scripts/min_eh_frame.c
[ ... ]
> +int main(int argc, char **argv)
> +{
[ ... ]
> + if (memcmp(map, ELFMAG, SELFMAG) == 0 &&
> + map[EI_DATA] == ELFDATA2LSB &&
> + map[EI_CLASS] == ELFCLASS64)
> + rc = process_elf64(map, (size_t)st.st_size);
main() checks that the target object is little-endian, but not the byte
order of the host the tool runs on. process_elf64() then reads and writes
the ELF header, section header, symbol and Elf64_Rela fields as native
structs, and only the .eh_frame payload goes through get_le32()/put_le32().
On a big-endian build host cross-compiling an x86_64, arm64 or riscv64
kernel, the first check in process_elf64() sees the bytes 01 00 of e_type
as 0x0100:
if (ehdr->e_type != ET_REL)
return 0;
Won't every object then be silently left unminified while the build still
succeeds? CONFIG_UNWINDER_DWARF_CFI_MINIFY is default y and its help text
says only Minimal DWARF CFA bytecodes remain in vmlinux and modules, but on
such a host nothing is stripped, coalesced or dropped, and nothing reports
it.
Other ELF host tools in scripts/ handle this: scripts/elf-parse.c picks
rle/rbe accessors from EI_DATA, and scripts/mod/modpost.c applies
TO_NATIVE() to the ELF header fields.
The resulting kernel should still work, since kernel/unwind/dwarf_cfi.c
parses unminified CIEs and FDEs, but the documented size reduction would
not apply.
Could this either fail the build with a message when the host is not
little-endian, or read the ELF header, section, symbol and rela fields
through le16/le32/le64 accessors as elf-parse.c does?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45087188604