| From: |
| Ian Rogers <irogers-AT-google.com> |
| To: |
| Peter Zijlstra <peterz-AT-infradead.org>, Ingo Molnar <mingo-AT-redhat.com>, Arnaldo Carvalho de Melo <acme-AT-kernel.org>, Namhyung Kim <namhyung-AT-kernel.org>, Jiri Olsa <jolsa-AT-kernel.org>, Ian Rogers <irogers-AT-google.com>, Adrian Hunter <adrian.hunter-AT-intel.com>, James Clark <james.clark-AT-linaro.org>, Nick Terrell <terrelln-AT-fb.com>, David Sterba <dsterba-AT-suse.com>, Nathan Chancellor <nathan-AT-kernel.org>, Tomas Glozar <tglozar-AT-redhat.com>, Blake Jones <blakejones-AT-google.com>, Dmitrii Dolgov <9erthalion6-AT-gmail.com>, Alexandre Chartre <alexandre.chartre-AT-oracle.com>, Costa Shulyupin <costa.shul-AT-redhat.com>, Yuzhuo Jing <yuzhuo-AT-google.com>, Michael Jeanson <mjeanson-AT-efficios.com>, Leo Yan <leo.yan-AT-arm.com>, Tianyou Li <tianyou.li-AT-intel.com>, Zecheng Li <zecheng-AT-google.com>, Rong Bao <rong.bao-AT-csmantle.top>, linux-kernel-AT-vger.kernel.org, linux-perf-users-AT-vger.kernel.org, bpf-AT-vger.kernel.org |
| Subject: |
| [PATCH v1 0/7] perf annotate: Add elfutils libasm disassembler backend |
| Date: |
| Mon, 08 Jun 2026 22:17:52 -0700 |
| Message-ID: |
| <20260609051759.405027-1-irogers@google.com> |
| Archive-link: |
| Article |
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