From patchwork Mon Apr 17 12:29:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 13213788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0023C77B76 for ; Mon, 17 Apr 2023 12:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjDQMab (ORCPT ); Mon, 17 Apr 2023 08:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjDQMaV (ORCPT ); Mon, 17 Apr 2023 08:30:21 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 278AA40C8 for ; Mon, 17 Apr 2023 05:30:14 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id a29so27047193ljq.0 for ; Mon, 17 Apr 2023 05:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681734613; x=1684326613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H9SW4BaZ1bnKVP1weVI2e85RynWnU48bLznC9wO1o9M=; b=n3zPin0s6G1kVf80R6NptUIL4S3g+P69ADkrw+7CjbBdWnHZAogR6n8d7yvle5PpkC N2qD3f66q4c1WuJJH3FC7IEyu49Ue0xXjqtxY5tz+Yd2eWdFli+V0m02Vs2vkkgobOb6 /EEatrtb5D817UZRcI4zZUpNKlarszn2yTNKMc633kSVLPqSxgDv+hIl6fQRW0Th5rud 5oJKMxbsSAn2FYb5E9GmEQTFxIKKSETJgwQToXiuD6bixtmU6h5/FXEYcmaysX9KpzuB kaQA2hMmfpEFr2V5bYiHWmVt/p17AW/+J57BCjvw7aP1yPVqYWnC7e6oHnl2kWsTAJJ3 6DaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681734613; x=1684326613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H9SW4BaZ1bnKVP1weVI2e85RynWnU48bLznC9wO1o9M=; b=doJbbzEFexj2h7V0AJjpCNuKxEjOXybYbApXm8RMRhlUsVJqQJXwilz3c5AA6eItGi Rr6D38TX7NK7eURLELJFwDpKiZqZt+AI1i4o0+75J/04v9TzdemwYdVU+OXE6ufbKv93 C4LsncOpQGICNrr0uf99CuTx8Iv/ao5SoMJx3cA0uhRqLrFcLli6A60EYbS30gl5plqh 4TFO+Dt8gV1oDy6WYrb9r/tS+H2rwKu1rfOr2LP/KreTsnDq87FYaY2jEhpgPzNzR2FI H1k+ja1Rc05EPi/u1WzJsF/BstKAhjzhvYXEOiEZbVidA4Nu29FFl7tEH1eF0Yo/9qKU 6jTw== X-Gm-Message-State: AAQBX9ejDF/T4kT+wFkVFaNkdaEK2BZjxL1PfKdwDscAxC/dwTN83YGP nGDD0h0hJwA/I4rBdTGZMblOBg== X-Google-Smtp-Source: AKy350bwGJE2C7V8hazROuRDBDgzLMhkcDD17prRT/qHi9ZNYNGhNGiMjSfhomMSdAYr9UncH37eIQ== X-Received: by 2002:a2e:9857:0:b0:2a8:c82f:2996 with SMTP id e23-20020a2e9857000000b002a8c82f2996mr759543ljj.43.1681734612901; Mon, 17 Apr 2023 05:30:12 -0700 (PDT) Received: from localhost (c-9b0ee555.07-21-73746f28.bbcust.telenor.se. [85.229.14.155]) by smtp.gmail.com with ESMTPSA id l20-20020a19c214000000b004ed149acc08sm1889569lfc.93.2023.04.17.05.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 05:30:12 -0700 (PDT) From: Anders Roxell To: stable@vger.kernel.org Cc: acme@redhat.com, andres@anarazel.de, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Quentin Monnet , Alexei Starovoitov , Ben Hutchings , Jiri Olsa , Sedat Dilek , bpf@vger.kernel.org, Anders Roxell Subject: [backport PATCH 1/2] tools perf: Fix compilation error with new binutils Date: Mon, 17 Apr 2023 14:29:42 +0200 Message-Id: <20230417122943.2155502-2-anders.roxell@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417122943.2155502-1-anders.roxell@linaro.org> References: <20230417122943.2155502-1-anders.roxell@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org From: Andres Freund binutils changed the signature of init_disassemble_info(), which now causes compilation failures for tools/perf/util/annotate.c, e.g. on debian unstable. Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 Wire up the feature test and switch to init_disassemble_info_compat(), which were introduced in prior commits, fixing the compilation failure. I verified that perf can still disassemble bpf programs by using bpftrace under load, recording a perf trace, and then annotating the bpf "function" with and without the changes. With old binutils there's no change in output before/after this patch. When comparing the output from old binutils (2.35) to new bintuils with the patch (upstream snapshot) there are a few output differences, but they are unrelated to this patch. An example hunk is: 1.15 : 55:mov %rbp,%rdx 0.00 : 58:add $0xfffffffffffffff8,%rdx 0.00 : 5c:xor %ecx,%ecx - 1.03 : 5e:callq 0xffffffffe12aca3c + 1.03 : 5e:call 0xffffffffe12aca3c 0.00 : 63:xor %eax,%eax - 2.18 : 65:leaveq - 2.82 : 66:retq + 2.18 : 65:leave + 2.82 : 66:ret Signed-off-by: Andres Freund Acked-by: Quentin Monnet Cc: Alexei Starovoitov Cc: Ben Hutchings Cc: Jiri Olsa Cc: Sedat Dilek Cc: bpf@vger.kernel.org Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de Link: https://lore.kernel.org/r/20220801013834.156015-5-andres@anarazel.de Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Anders Roxell --- tools/perf/Makefile.config | 8 ++++++++ tools/perf/util/annotate.c | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 3e7706c251e9..55905571f87b 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -281,6 +281,7 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_LDFLAGS-libaio = -lrt FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl +FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl CORE_CFLAGS += -fno-omit-frame-pointer CORE_CFLAGS += -ggdb3 @@ -838,13 +839,16 @@ else ifeq ($(feature-libbfd-liberty), 1) EXTLIBS += -lbfd -lopcodes -liberty FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl else ifeq ($(feature-libbfd-liberty-z), 1) EXTLIBS += -lbfd -lopcodes -liberty -lz FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl endif endif $(call feature_check,disassembler-four-args) + $(call feature_check,disassembler-init-styled) endif ifeq ($(feature-libbfd-buildid), 1) @@ -957,6 +961,10 @@ ifeq ($(feature-disassembler-four-args), 1) CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE endif +ifeq ($(feature-disassembler-init-styled), 1) + CFLAGS += -DDISASM_INIT_STYLED +endif + ifeq (${IS_64_BIT}, 1) ifndef NO_PERF_READ_VDSO32 $(call feature_check,compile-32) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 308189454788..f2d1741b7610 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1684,6 +1684,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil #define PACKAGE "perf" #include #include +#include static int symbol__disassemble_bpf(struct symbol *sym, struct annotate_args *args) @@ -1726,9 +1727,9 @@ static int symbol__disassemble_bpf(struct symbol *sym, ret = errno; goto out; } - init_disassemble_info(&info, s, - (fprintf_ftype) fprintf); - + init_disassemble_info_compat(&info, s, + (fprintf_ftype) fprintf, + fprintf_styled); info.arch = bfd_get_arch(bfdf); info.mach = bfd_get_mach(bfdf);