[PATCH] perf dwarf-aux: Check .eh_frame section for CFA

From: Namhyung Kim

Date: Fri Oct 02 2026 - 18:45:02 EST


The die_get_cfa() only calls dwarf_getcfi() which handles .debug_frame
section. But most binaries have .eh_frame instead so it would fail.
Let's call dwarf_getcfi_elf() first to try .eh_frame section and then
fallback to .debug_frame.

Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/dwarf-aux.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 54f8b5ec74a2fe70..af3913e661fce79e 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1886,9 +1886,14 @@ int die_get_cfa(Dwarf *dwarf, u64 pc, int *preg, int *poffset)
Dwarf_Op *ops = NULL;
size_t nops;

- cfi = dwarf_getcfi(dwarf);
- if (cfi == NULL)
- return -1;
+ /* try to get .eh_frame section */
+ cfi = dwarf_getcfi_elf(dwarf_getelf(dwarf));
+ if (cfi == NULL) {
+ /* and then try .debug_frame section */
+ cfi = dwarf_getcfi(dwarf);
+ if (cfi == NULL)
+ return -1;
+ }

if (!dwarf_cfi_addrframe(cfi, pc, &frame) &&
!dwarf_frame_cfa(frame, &ops, &nops) &&
--
2.56.0.rc1.315.gc6ed9934b7-goog