Skip to content

perf annotate: Add elfutils libasm disassembler and BPF JIT disassembly support

Ian Rogers bpf linux-perf-users lkml 3 versions New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 0 repliesNew
  2. v27 patches 0 repliesSuperseded
  3. v17 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Address review comments on v2 series.
- Explicitly link against -lasm -ldw -lelf in the feature check.
- Document that older versions of elfutils that require explicitly linking -lebl statically are unsupported.
- Fix instruction-by-instruction disassembly loop logic in libasm.c by returning 1 from output callback and checking for ret != 1.
- Pass the correct ELF machine (e_machine) to jit_write_elf instead of hardcoding host architecture.
- Update annotate.sh tests to use perf test -w workload instead of free to avoid CI environment issues.
- Expand test coverage to test all disassemblers (including libasm) on BPF JIT symbols when run with root privileges.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7tools build: Add feature check for elfutils libasmtools/build/Makefile.feature tools/build/feature/Makefile tools/build/feature/test-libasm.c+31 -00 replies
2/7perf build: Add build support and capability for elfutils libasmtools/perf/Makefile.config tools/perf/builtin-check.c+23 -00 replies
3/7perf annotate: Implement elfutils libasm disassembler backendtools/perf/util/Build tools/perf/util/annotate.c tools/perf/util/annotate.h +3 more+226 -20 replies
4/7perf annotate: Add --disassembler command-line optiontools/perf/builtin-annotate.c+10 -00 replies
5/7perf test: Enhance annotate test coverage and isolate configtools/perf/tests/shell/annotate.sh+60 -00 replies
6/7perf annotate: Support BPF JIT disassembly via genelftools/perf/tests/genelf.c tools/perf/util/disasm.c tools/perf/util/disasm.h +3 more+117 -180 replies
7/7perf test: Add BPF JIT annotation test coverage for all disassemblerstools/perf/tests/shell/annotate.sh+93 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/7] perf annotate: Add elfutils libasm disassembler and BPF JIT disassembly support

This patch series introduces support for using the elfutils libasm library as a disassembler backend in perf annotate. This provides a lightweight, library-based alternative to LLVM and Capstone for in-process disassembly.

Additionally, this series implements disassembly support for in-memory BPF JITted programs by writing the JITted instruction buffer to a temporary ELF file on the fly and disassembling it using the ELF-based backends (objdump and libasm).

Changes in v3:
- Address review comments on v2 series.
- Explicitly link against -lasm -ldw -lelf in the feature check.
- Document that older versions of elfutils that require explicitly linking -lebl statically are unsupported.
- Fix instruction-by-instruction disassembly loop logic in libasm.c by returning 1 from output callback and checking for ret != 1.
- Pass the correct ELF machine (e_machine) to jit_write_elf instead of hardcoding host architecture.
- Update annotate.sh tests to use perf test -w workload instead of free to avoid CI environment issues.
- Expand test coverage to test all disassemblers (including libasm) on BPF JIT symbols when run with root privileges.

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  |  20 ++++
 tools/perf/Makefile.config         |  22 ++++
 tools/perf/builtin-annotate.c      |  10 ++
 tools/perf/builtin-check.c         |   1 +
 tools/perf/tests/genelf.c          |   2 +-
 tools/perf/tests/shell/annotate.sh | 153 ++++++++++++++++++++++++
 tools/perf/util/Build              |   1 +
 tools/perf/util/annotate.c         |   8 +-
 tools/perf/util/annotate.h         |   3 +
 tools/perf/util/disasm.c           | 114 +++++++++++++++++-
 tools/perf/util/disasm.h           |   1 +
 tools/perf/util/genelf.c           |  16 +--
 tools/perf/util/genelf.h           |   2 +-
 tools/perf/util/jitdump.c          |   3 +-
 tools/perf/util/libasm.c           | 184 +++++++++++++++++++++++++++++
 tools/perf/util/libasm.h           |  27 +++++
 18 files changed, 559 insertions(+), 19 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
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog