[PATCH v1 0/7] perf annotate: Add elfutils libasm disassembler backend
From: Ian Rogers
Date: Tue Jun 09 2026 - 01:18:14 EST
This series implements a new native disassembler backend for `perf annotate`
using elfutils' libasm.
Currently, `perf annotate` defaults to invoking an external `objdump`
process when native disassemblers like Capstone or LLVM are either
not compiled in or unable to handle the target binary. This fallback
incurs significant overhead due to process forking, output parsing,
and external process management. It is also inherently fragile and
complicates environments where `objdump` might not be readily available.
This series integrates `libasm` directly into the perf tools to parse
instructions natively without any external process dependencies,
providing a robust native alternative to `objdump` using elfutils.
It adds:
- Build checks and detection for the `libasm` elfutils library.
- A comprehensive `symbol__disassemble_libasm` implementation.
- A `--disassembler=<name>` flag to explicitly choose between backends
(e.g., `libasm`, `objdump`, `capstone`, `llvm`).
- Temporary ELF file generation for JITted BPF programs to allow
`objdump` and `libasm` to decode them gracefully.
- Full system-wide test coverage in `perf test` that validates normal
ELF execution and BPF JIT output across all supported backends.
`perf annotate` will continue to seamlessly prioritize the available
disassembler backends, but `libasm` now provides a robust, native fallback
for standard environments using elfutils.
Ian Rogers (7):
tools build: Add feature check for elfutils libasm
perf build: Add build support and capability for elfutils libasm
perf annotate: Implement elfutils libasm disassembler backend
perf annotate: Add --disassembler command-line option
perf test: Enhance annotate test coverage and isolate config
perf annotate: Support BPF JIT disassembly via genelf
perf test: Add BPF JIT annotation test coverage for all disassemblers
tools/build/Makefile.feature | 2 +
tools/build/feature/Makefile | 9 ++
tools/build/feature/test-libasm.c | 19 +++
tools/perf/Makefile.config | 23 ++++
tools/perf/builtin-annotate.c | 10 ++
tools/perf/builtin-check.c | 1 +
tools/perf/tests/shell/annotate.sh | 125 ++++++++++++++++++++
tools/perf/util/Build | 1 +
tools/perf/util/annotate.c | 8 +-
tools/perf/util/annotate.h | 3 +
tools/perf/util/disasm.c | 110 ++++++++++++++++-
tools/perf/util/disasm.h | 1 +
tools/perf/util/libasm.c | 182 +++++++++++++++++++++++++++++
tools/perf/util/libasm.h | 27 +++++
14 files changed, 513 insertions(+), 8 deletions(-)
create mode 100644 tools/build/feature/test-libasm.c
create mode 100644 tools/perf/util/libasm.c
create mode 100644 tools/perf/util/libasm.h
--
2.54.0.1064.gd145956f57-goog