Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp381931imk; Sat, 2 Jul 2022 21:50:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vuza8Il2QPc/EkWxlW3YXzCUSAqxBz1ddESyPh2gkauV4U3/7szhy2sK0rpVhCNOABQOze X-Received: by 2002:a17:907:7f8c:b0:726:2c53:2f82 with SMTP id qk12-20020a1709077f8c00b007262c532f82mr21927032ejc.140.1656823838385; Sat, 02 Jul 2022 21:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656823838; cv=none; d=google.com; s=arc-20160816; b=O2kT8gawExQ84vaaBwKAcNIxCmHOJzzsBtF3+HuO9hWgtel+HwLh25e74PVVa4QSH2 Uol3jRc4E24YfaNAhZgStcy9EBNBMSk0q2VlEJcEuvs79iYzLkJNRRqjjHAN/XIz7gv7 KahGwmEfUmTi96t+HI1yZUD8dlc3aM/2aVVLKLpyIPhRRRVPWBfp29KDQiUUW5Kljytc 1LCSqZMOBAhcLxEpWsbliS7vrkP4JlB1v3B4KGS1ZpSeoGUR06H9YeF9RR9mPlhV295Q bIP/IQi+ImhU4szQLvPjiEaBVn17DuyrFiMG4cJUt6fbAH9RY3gHM8VwM74KJHIAPlG7 yb6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=olCiYvC962ScfzpATAfPxC22ukY6tzWgafn4Ey43S+4=; b=AVZYr4COV2onqQaxBaVGoEgdzKeO8F5+0n/L8OgxYvt3DGO/ibJub57pYksrQPMkiY rTEFsgEzynF38msfDG3Asv37qKDoZvOaiIL11+/8gc8EXwzwm7FuF+AiaB2GYX+ru4z2 cMUqIC3kLoIlsE/WL3jdwUzDqeYIKsozAXaBApHynvgsmfnHN37iIcbQhBxTM5kyvbII TBF+JfLvUXk0qBxP34pPonN/G57pno7OqbL4JJlgkERogy2ejgMsi70ZkP9f0ixtutvW 3IAlWe4UxNnOYqSdnjc6JJTs3g95+Y3pMsqxWUkEKtBQU6e37+WqTiziZahae6oo1Y5u Gh7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm2 header.b=EfMkqEqG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="qD1hEv/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht11-20020a170907608b00b0072a87f63748si9756285ejc.908.2022.07.02.21.50.13; Sat, 02 Jul 2022 21:50:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm2 header.b=EfMkqEqG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="qD1hEv/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231352AbiGCEsa (ORCPT + 99 others); Sun, 3 Jul 2022 00:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbiGCEsU (ORCPT ); Sun, 3 Jul 2022 00:48:20 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A221D51 for ; Sat, 2 Jul 2022 21:48:17 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E0B07320084E; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 03 Jul 2022 00:48:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1656823695; x=1656910095; bh=ol CiYvC962ScfzpATAfPxC22ukY6tzWgafn4Ey43S+4=; b=EfMkqEqG0QhxvKeQZW ym5ISAdVpH1WN2eFeFeFtiswkR3fL4GrAwfN9yNJQ35E3V8TG8r9jtxu/XJ4eeQS uAUY0MmDUkbFuoTGByqQz1BGkE1jfqz4xotpGq3dsvhV5+i6uT/5Obh4KDv2qlbl OnN//vIZX8UbkJRDYLB9qW6ib9Eg/BwgJhVnpXXkSMQ7X6YJaaQG1LPUJAmu/G0p tPAD6lA/fBsQilQcVmnYesqxlM9SXv5CcOhF5t/QN6orerFUB6OBDWTQ75Ik5x2s vV5uG+1g3iTo8eXOOfR1AlqtNCYKuV/UrvznaRfuZFwv3dJUx0DwE2p7gsj0KX3F 4Cpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656823695; x=1656910095; bh=olCiYvC962Scf zpATAfPxC22ukY6tzWgafn4Ey43S+4=; b=qD1hEv/SKN0K1qPYrLjgz7eGaG1RZ 9rjaAY9wIzKRPBbiOLv+Xsi9dx7hjD8mBnk8bHttyRX4MiJ5zILAKF19/rox3FcI VC2+gJdYENX9YFsX3J6qBLxujqxLfrBdsaYX1+HfVkBzo0j08qm9DkAHSR+WPvNl +IzjfKZ+h/+hjwS5H89+aHsYf1kfa9cCWiLdQuPGSuXq0Sm8BdWOTpzdfEMClnup I9dI1+JcrcQAhoaV+gWDIvoU0Ovf71niONkZRpi93JiJrV50pG3blo8YJh0lPUU+ vYaneGzdKNgkqMmB1tyAEFY4ezGbvtg7g36QRUxtb5iGAgBwyJDgvvtog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehiedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepleejgfdvfefhudektddtveegtdekieegffdtkeeljeetudevffeltdei feeugeeinecuffhomhgrihhnpehsohhurhgtvgifrghrvgdrohhrghdpkhgvrhhnvghlrd horhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep rghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) From: Andres Freund To: linux-kernel@vger.kernel.org Cc: Quentin Monnet , Alexei Starovoitov , Arnaldo Carvalho de Melo , Jiri Olsa , Daniel Borkmann Subject: [PATCH v1 3/3] tools: Use tools/dis-asm-compat.h to fix compilation errors with new binutils Date: Sat, 2 Jul 2022 21:48:14 -0700 Message-Id: <20220703044814.892617-5-andres@anarazel.de> X-Mailer: git-send-email 2.35.1.677.gabf474a5dd In-Reply-To: <20220703044814.892617-1-andres@anarazel.de> References: <20220622231624.t63bkmkzphqvh3kx@alap3.anarazel.de> <20220703044814.892617-1-andres@anarazel.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org binutils changed the signature of init_disassemble_info(), which now causes compilation failures for tools/{perf,bpf} on e.g. debian unstable. Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 Use the previously introduced compat header to fix the build failures. I verified that: - perf can still disassemble bpf programs - bpftool can still disassemble bpf programs, both plain in json - bpf_jit_disasm still works - it does. Although it turns out that independent of these changes bpf_jit_enable = 2 currently is broken, see https://lore.kernel.org/20220703030210.pmjft7qc2eajzi6c@alap3.anarazel.de Cc: Quentin Monnet Cc: Alexei Starovoitov Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Daniel Borkmann Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de Signed-off-by: Andres Freund --- tools/bpf/bpf_jit_disasm.c | 5 ++++- tools/bpf/bpftool/jit_disasm.c | 40 +++++++++++++++++++++++++++------- tools/perf/util/annotate.c | 7 +++--- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/tools/bpf/bpf_jit_disasm.c b/tools/bpf/bpf_jit_disasm.c index c8ae95804728..a90a5d110f92 100644 --- a/tools/bpf/bpf_jit_disasm.c +++ b/tools/bpf/bpf_jit_disasm.c @@ -28,6 +28,7 @@ #include #include #include +#include #define CMD_ACTION_SIZE_BUFFER 10 #define CMD_ACTION_READ_ALL 3 @@ -64,7 +65,9 @@ static void get_asm_insns(uint8_t *image, size_t len, int opcodes) assert(bfdf); assert(bfd_check_format(bfdf, bfd_object)); - init_disassemble_info(&info, stdout, (fprintf_ftype) fprintf); + init_disassemble_info_compat(&info, stdout, + (fprintf_ftype) fprintf, + fprintf_styled); info.arch = bfd_get_arch(bfdf); info.mach = bfd_get_mach(bfdf); info.buffer = image; diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c index 24734f2249d6..f0d5c5f0eb60 100644 --- a/tools/bpf/bpftool/jit_disasm.c +++ b/tools/bpf/bpftool/jit_disasm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "json_writer.h" #include "main.h" @@ -39,15 +40,12 @@ static void get_exec_path(char *tpath, size_t size) } static int oper_count; -static int fprintf_json(void *out, const char *fmt, ...) +static int printf_json(void *out, const char *fmt, va_list ap) { - va_list ap; char *s; int err; - va_start(ap, fmt); err = vasprintf(&s, fmt, ap); - va_end(ap); if (err < 0) return -1; @@ -73,6 +71,30 @@ static int fprintf_json(void *out, const char *fmt, ...) return 0; } +static int fprintf_json(void *out, const char *fmt, ...) +{ + va_list ap; + int r; + + va_start(ap, fmt); + r = printf_json(out, fmt, ap); + va_end(ap); + + return r; +} + +static int fprintf_json_styled(void *out, enum disassembler_style style, const char *fmt, ...) +{ + va_list ap; + int r; + + va_start(ap, fmt); + r = printf_json(out, fmt, ap); + va_end(ap); + + return r; +} + void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, const char *arch, const char *disassembler_options, const struct btf *btf, @@ -99,11 +121,13 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, assert(bfd_check_format(bfdf, bfd_object)); if (json_output) - init_disassemble_info(&info, stdout, - (fprintf_ftype) fprintf_json); + init_disassemble_info_compat(&info, stdout, + (fprintf_ftype) fprintf_json, + fprintf_json_styled); else - init_disassemble_info(&info, stdout, - (fprintf_ftype) fprintf); + init_disassemble_info_compat(&info, stdout, + (fprintf_ftype) fprintf, + fprintf_styled); /* Update architecture info for offload. */ if (arch) { diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 82cc396ef516..daea1867381d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -41,6 +41,7 @@ #include #include #include +#include /* FIXME: For the HE_COLORSET */ #include "ui/browser.h" @@ -1762,9 +1763,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); -- 2.35.1.677.gabf474a5dd