From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FF103CF205 for ; Tue, 9 Jun 2026 07:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780988861; cv=none; b=RHNMt4JMjVZC7iyqgLJcnqfspZgRZIydbgfPCGcLED9U/X4r84oy74YmROLhU35GQAZh/Lm5FdRtj+PpGlrixO/OpS0945YIZ7AqdqewK0BXcpDKfaTdMIkFwWq6x8I1cXlLE+OQ9zX/xbeD0xvyp2s4ryR5/2p/nJRU7zd/f0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780988861; c=relaxed/simple; bh=ih/WFkHQ584rId30STWxtTkSWunNrrmDUCVGPyksHj8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Content-Type; b=YxUKgsyrThKFb5to1LMA0to5QymskaZBOwAo4JDoqLJVHLilD/JohhTMmRaEE+ChqYnW0aNaaJhSipFUjQhgOpZvJ7KDFrw/hfmMjd0oUketXjYtykkTGubD2YGAQ4WXsNrmngi9F9kX7F3YFCZohPugKUR6RE1CgSiKNmmDYR4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ELEatQW4; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ELEatQW4" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1382674ba2eso2479313c88.0 for ; Tue, 09 Jun 2026 00:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780988860; x=1781593660; darn=vger.kernel.org; h=content-transfer-encoding:to:from:subject:message-id:mime-version :date:from:to:cc:subject:date:message-id:reply-to; bh=PxckLdcG/zu0VSlVCoGLUc2yFYusbAIrF0yTwxkZNwI=; b=ELEatQW4a4iBa//T4IKmQnom7nK850FzYs2hD2uTK9bx49CL+0D8qudLtLhm/1JzIR +qMImRhqCjXauSWeg5MUy7RJKVFaJ0JT/9Eb3cpPrMmLbHvoP1Dcr57DStkPDOFa0J2/ hLRzxV1wXBPPpLhsdAU8coe9Of+NVgE91nsFal/aHNX2rnE9uiwYeAGLMQEHgaCsSab4 Fono6+yL4onj37V2tTF/M1DYifzKtgtfk2NTHkeVH/QYpzW5yLMeXXzdojAVLJ/puhvL ME5VZ/2LHtDPJ1/1DnoYZiE3bosBH2SGVxesiwLvOvVytFcozSU6XLnT21RTxkit7drc WuvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780988860; x=1781593660; h=content-transfer-encoding:to:from:subject:message-id:mime-version :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PxckLdcG/zu0VSlVCoGLUc2yFYusbAIrF0yTwxkZNwI=; b=Wp0Lw0g+GY0ZK/zQc5qdtNrikEDNWmA2Xo2L6gkxjhDwDutT9fZYqK3GQVqFJjdlI7 GC+9kHtzhs+9rmoa25mad31hnHVS7QEOtRxNqajx5Liyhs6zafYOgM8EaDwSJi5vsfNv gW+x2Vr3pWGWK7JYMPLndm6gOAaMN5o3b1ltbVyGUhy2HfsyrbUEYkHGfKV5Z7UHgMuJ 0l32mR8fOK6WKTGCUknzEYjwlWmY96s4hcUaUzqDOAPZphKdmGvEC0M+TdQBk4n5+q2g v0ZSVSm0FPhr6QpPLin8svcJiXERad5E+SLUHE57HF+pXw6msqKTJSJvPPuyrk5FN4gS TqUQ== X-Forwarded-Encrypted: i=1; AFNElJ8QaBB3+uzXZPmc7WOvRNxKOnF3y050CMtXX7/y4Fv8B22B5ji8hkvmaEP1tFajH7YMAvh/NxnYS8twLDU=@vger.kernel.org X-Gm-Message-State: AOJu0YyKhaWpQHIHxHknPeHLSFoOLcW3TWt8BO9kJqaOm/mCehXNlW10 IrKAEaxJbFvIKVpw1Mu42OYpIrEIBHGwV3XZQIDRqvMnJ7+erz64uz511DoQo4mExzs4J95UqTW EPYITYy/G/g== X-Received: from dlbrx9.prod.google.com ([2002:a05:7022:1709:b0:138:57f:8a4f]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6713:b0:130:c9cc:3395 with SMTP id a92af1059eb24-1380673186dmr9484727c88.29.1780988859141; Tue, 09 Jun 2026 00:07:39 -0700 (PDT) Date: Tue, 9 Jun 2026 00:07:25 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1064.gd145956f57-goog Message-ID: <20260609070732.545416-1-irogers@google.com> Subject: [PATCH v2 0/7] perf annotate: Add elfutils libasm disassembler support From: Ian Rogers To: Serhei Makarov , mark@klomp.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Nick Terrell , David Sterba , Nathan Chancellor , Tomas Glozar , Blake Jones , Dmitrii Dolgov <9erthalion6@gmail.com>, Alexandre Chartre , Costa Shulyupin , Yuzhuo Jing , Michael Jeanson , Leo Yan , Tianyou Li , Zecheng Li , Rong Bao , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This series adds a new `libasm` disassembly backend to `perf annotate`, leveraging the `elfutils` libasm library. This allows perf to use the widely available elfutils for disassembly alongside capstone, libLLVM, and = objdump. v2 changes: - Patch 1: Added a note to the commit message acknowledging that older elfu= tils static builds lacking `-lebl` dependencies in pkg-config are explicitl= y unsupported, while intentionally retaining the feature check and API depe= ndencies. - Patch 2: Fixed `NO_LIBELF=3D1` build breakages by implicitly disabling `l= ibasm` and removing the unconditional `#warning` in favor of silent fallbac= ks or standard warnings. - Patch 3: Fixed `libasm` block boundary tracking and corrected callback er= ror/return values, preventing memory leaks and infinite loops in the disass= embly extraction loop. - Patch 5: Fixed script robustness in `tests/shell/annotate.sh` by ensuring= cleanup functions run reliably, `set -e` doesn't abort prematurely on grep= failures, and configs are properly restored. - Patch 6: Refactored `jit_write_elf` to accept the `e_machine` parameter d= irectly instead of post-patching the generated ELF file with `libelf`. The = target architecture is now extracted dynamically and passed into `jit_write= _elf`, simplifying the interaction with BPF and making it fully compatible = with all disassemblers. - Patch 7: Fixed a TOCTOU race condition when creating the symlink in `test= s/shell/annotate.sh` by placing `perf.data` inside an isolated temporary di= rectory. - General: The cover letter now lists capstone, libLLVM, and objdump as the= existing disassemblers instead of just objdump. 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 | 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 | 133 +++++++++++++++++++++ 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 | 4 +- tools/perf/util/genelf.h | 2 +- tools/perf/util/jitdump.c | 2 +- tools/perf/util/libasm.c | 184 +++++++++++++++++++++++++++++ tools/perf/util/libasm.h | 27 +++++ 18 files changed, 531 insertions(+), 13 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