Re: [RFC PATCH v2 19/30] riscv/unwind: Add Minimal DWARF CFI kernel unwinder
From: bot+bpf-ci
Date: Wed Nov 25 2026 - 02:07:09 EST
> riscv/unwind: Add Minimal DWARF CFI kernel unwinder
TL;DR: Without KEEP(), GNU ld --gc-sections (LD_DEAD_CODE_DATA_ELIMINATION)
may discard the core kernel .eh_frame in vmlinux.lds.S, so the DWARF CFI
unwinder would fail silently for every kernel PC and degrade stack traces.
> diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> --- a/arch/riscv/kernel/vmlinux.lds.S
> +++ b/arch/riscv/kernel/vmlinux.lds.S
[ ... ]
> @@ -125,6 +125,19 @@ SECTIONS
> *(.srodata*)
> }
>
> +#ifdef CONFIG_UNWINDER_DWARF_CFI
> + .eh_frame_hdr : ALIGN(4) {
> + __start_eh_frame_hdr = .;
> + *(.eh_frame_hdr)
> + __stop_eh_frame_hdr = .;
> + }
> + .eh_frame : ALIGN(8) {
> + __start_eh_frame = .;
> + *(.eh_frame)
> + __stop_eh_frame = .;
> + }
> +#endif
Can the core kernel .eh_frame be discarded here when linking with GNU ld
and CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y?
riscv selects HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD, and the
top-level Makefile then adds --gc-sections to LDFLAGS_vmlinux.
UNWINDER_DWARF_CFI in arch/riscv/Kconfig.debug does not exclude that
option.
Nothing references the .eh_frame input sections, and the
__start_eh_frame/__stop_eh_frame assignments do not keep them alive, so
without KEEP() the garbage collector would be free to drop them.
If that happens, .eh_frame_hdr would have no FDE table and
dwarf_cfi_unwind_eh_frame_hdr() would return -EINVAL for every core
kernel PC. Oops, WARN and perf/BPF callchains would then shrink to the
heuristic fallbacks, and arch_stack_walk_reliable() would always return
-EINVAL, with no build or runtime warning.
The other sections in this file that nothing references use KEEP, for
example .alternative and __soc_early_init_table, and the riscv vDSO
script uses:
.eh_frame : { KEEP (*(.eh_frame)) }
Should this be KEEP(*(.eh_frame)), or should UNWINDER_DWARF_CFI depend
on !LD_DEAD_CODE_DATA_ELIMINATION?
---
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/45561209846