From nobody Sun Apr 19 10:42:19 2026 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 89314C43334 for ; Sun, 3 Jul 2022 04:48:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbiGCEsW (ORCPT ); Sun, 3 Jul 2022 00:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiGCEsT (ORCPT ); Sun, 3 Jul 2022 00:48:19 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18791CF8 for ; Sat, 2 Jul 2022 21:48:17 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id E563C32008FE; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.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=L7 LRQqIR8WOHwS7jDqNkq63t9PzY923/O9a9gLSfxTw=; b=mcbDT4RfgZtz+gw7q0 Ho+HEZAINBpYjJAgcCSvvPfxfD0beLq08mBgH/pRgOxgAJYrgPMBIWo8TOCTnc0a lldBKZn5BIQiYW30J8IqoZfqL4MFEUWHWsd0lis177jZQP/skz3Sc38WKUY81Yz3 4Y5NCieHWyANhrSQK70T7z0UWWOe/pw7vtHaDtCnyUJ8//+dmNPY6tl0c7LbRapg UjBipbgkhNKOTkrXnZVrrt9NCAQoQ1y8JXowqmtN+cEoMHXRrO3X0U9lFRYHiXau vTc0bA0a/EEnSUIn28u75ZisW4M2XswhHaCvElqwkc0yIV5Iq5t/wSNhyjffwB6/ VBIw== 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=L7LRQqIR8WOHw S7jDqNkq63t9PzY923/O9a9gLSfxTw=; b=qJr6SL6SyR2m6KTR42ZWRtct0iINl 8bE9SVD077P0QpDl/us/W/AvpcFy2UCGvKgVA7kqSU16irXmx9RSlRqS37Mt8m/w aydVb3TF7eBLchFwdZK2ytgAXN43yBbURBNBPHSxrCe9WpYMNLgq4w4ew5KbkSd0 xwPVHOjCPi0HJMQNwb1HGdRWQP2FoEVhvKrW7iHYDf01uZMHsK4THTqMjo4fnr7j 6mzm/sg2ETVPYKLPcxaSEMC9t2VTvP9OIEvboS6fvERn/vEOnBti4F06y4ZHj/U7 mTlzLehBuSW1ppzbPY0Kck6HQS5dPuqTH/FBAo1O45Q05HccvL6QxXNXA== 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 , Arnaldo Carvalho de Melo , Jiri Olsa Subject: [PATCH v1 1/3] tools build: add feature test for init_disassemble_info API changes Date: Sat, 2 Jul 2022 21:48:11 -0700 Message-Id: <20220703044814.892617-2-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3Dbinutils-gdb.git;a=3Dcommit;h=3D60a3da00bd5= 407f07 This commit adds a feature test to detect the new signature and enables it for tools using init_disassemble_info(). Subsequent commits will change the code. Cc: Quentin Monnet Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.ana= razel.de Signed-off-by: Andres Freund --- tools/bpf/Makefile | 7 +++++-- tools/bpf/bpftool/Makefile | 7 +++++-- tools/build/Makefile.feature | 4 +++- tools/build/feature/Makefile | 4 ++++ tools/build/feature/test-all.c | 4 ++++ tools/build/feature/test-disassembler-init-styled.c | 13 +++++++++++++ tools/perf/Makefile.config | 8 ++++++++ 7 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tools/build/feature/test-disassembler-init-styled.c diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile index b11cfc86a3d0..9c4e61c3a92b 100644 --- a/tools/bpf/Makefile +++ b/tools/bpf/Makefile @@ -34,8 +34,8 @@ else endif =20 FEATURE_USER =3D .bpf -FEATURE_TESTS =3D libbfd disassembler-four-args -FEATURE_DISPLAY =3D libbfd disassembler-four-args +FEATURE_TESTS =3D libbfd disassembler-four-args disassembler-init-styled +FEATURE_DISPLAY =3D libbfd disassembler-four-args disassembler-init-styled =20 check_feat :=3D 1 NON_CHECK_FEAT_TARGETS :=3D clean bpftool_clean runqslower_clean resolve_b= tfids_clean @@ -56,6 +56,9 @@ endif ifeq ($(feature-disassembler-four-args), 1) CFLAGS +=3D -DDISASM_FOUR_ARGS_SIGNATURE endif +ifeq ($(feature-disassembler-init-styled), 1) +CFLAGS +=3D -DDISASM_INIT_STYLED +endif =20 $(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y $(QUIET_BISON)$(YACC) -o $@ -d $< diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index c6d2c77d0252..62195118d377 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -93,9 +93,9 @@ INSTALL ?=3D install RM ?=3D rm -f =20 FEATURE_USER =3D .bpftool -FEATURE_TESTS =3D libbfd disassembler-four-args zlib libcap \ +FEATURE_TESTS =3D libbfd disassembler-four-args disassembler-init-styled z= lib libcap \ clang-bpf-co-re -FEATURE_DISPLAY =3D libbfd disassembler-four-args zlib libcap \ +FEATURE_DISPLAY =3D libbfd disassembler-four-args disassembler-init-styled= zlib libcap \ clang-bpf-co-re =20 check_feat :=3D 1 @@ -117,6 +117,9 @@ endif ifeq ($(feature-disassembler-four-args), 1) CFLAGS +=3D -DDISASM_FOUR_ARGS_SIGNATURE endif +ifeq ($(feature-disassembler-init-styled), 1) + CFLAGS +=3D -DDISASM_INIT_STYLED +endif =20 LIBS =3D $(LIBBPF) -lelf -lz LIBS_BOOTSTRAP =3D $(LIBBPF_BOOTSTRAP) -lelf -lz diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 888a0421d43b..339686b99a6e 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -70,6 +70,7 @@ FEATURE_TESTS_BASIC :=3D \ libaio \ libzstd \ disassembler-four-args \ + disassembler-init-styled \ file-handle =20 # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list @@ -135,7 +136,8 @@ FEATURE_DISPLAY ?=3D \ bpf \ libaio \ libzstd \ - disassembler-four-args + disassembler-four-args \ + disassembler-init-styled =20 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. # If in the future we need per-feature checks/flags for features not diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 7c2a17e23c30..c3059739318a 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -18,6 +18,7 @@ FILES=3D \ test-libbfd.bin \ test-libbfd-buildid.bin \ test-disassembler-four-args.bin \ + test-disassembler-init-styled.bin \ test-reallocarray.bin \ test-libbfd-liberty.bin \ test-libbfd-liberty-z.bin \ @@ -248,6 +249,9 @@ $(OUTPUT)test-libbfd-buildid.bin: $(OUTPUT)test-disassembler-four-args.bin: $(BUILD) -DPACKAGE=3D'"perf"' -lbfd -lopcodes =20 +$(OUTPUT)test-disassembler-init-styled.bin: + $(BUILD) -DPACKAGE=3D'"perf"' -lbfd -lopcodes + $(OUTPUT)test-reallocarray.bin: $(BUILD) =20 diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 5ffafb967b6e..957c02c7b163 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c @@ -166,6 +166,10 @@ # include "test-disassembler-four-args.c" #undef main =20 +#define main main_test_disassembler_init_styled +# include "test-disassembler-init-styled.c" +#undef main + #define main main_test_libzstd # include "test-libzstd.c" #undef main diff --git a/tools/build/feature/test-disassembler-init-styled.c b/tools/bu= ild/feature/test-disassembler-init-styled.c new file mode 100644 index 000000000000..f1ce0ec3bee9 --- /dev/null +++ b/tools/build/feature/test-disassembler-init-styled.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +int main(void) +{ + struct disassemble_info info; + + init_disassemble_info(&info, stdout, + NULL, NULL); + + return 0; +} diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 73e0762092fe..ee417c321adb 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -298,6 +298,7 @@ FEATURE_CHECK_LDFLAGS-libpython :=3D $(PYTHON_EMBED_LDO= PTS) FEATURE_CHECK_LDFLAGS-libaio =3D -lrt =20 FEATURE_CHECK_LDFLAGS-disassembler-four-args =3D -lbfd -lopcodes -ldl +FEATURE_CHECK_LDFLAGS-disassembler-init-styled =3D -lbfd -lopcodes -ldl =20 CORE_CFLAGS +=3D -fno-omit-frame-pointer CORE_CFLAGS +=3D -ggdb3 @@ -905,13 +906,16 @@ ifndef NO_LIBBFD ifeq ($(feature-libbfd-liberty), 1) EXTLIBS +=3D -lbfd -lopcodes -liberty FEATURE_CHECK_LDFLAGS-disassembler-four-args +=3D -liberty -ldl + FEATURE_CHECK_LDFLAGS-disassembler-init-styled +=3D -liberty -ldl else ifeq ($(feature-libbfd-liberty-z), 1) EXTLIBS +=3D -lbfd -lopcodes -liberty -lz FEATURE_CHECK_LDFLAGS-disassembler-four-args +=3D -liberty -lz -ldl + FEATURE_CHECK_LDFLAGS-disassembler-init-styled +=3D -liberty -lz -= ldl endif endif $(call feature_check,disassembler-four-args) + $(call feature_check,disassembler-init-styled) endif =20 ifeq ($(feature-libbfd-buildid), 1) @@ -1025,6 +1029,10 @@ ifeq ($(feature-disassembler-four-args), 1) CFLAGS +=3D -DDISASM_FOUR_ARGS_SIGNATURE endif =20 +ifeq ($(feature-disassembler-init-styled), 1) + CFLAGS +=3D -DDISASM_INIT_STYLED +endif + ifeq (${IS_64_BIT}, 1) ifndef NO_PERF_READ_VDSO32 $(call feature_check,compile-32) --=20 2.35.1.677.gabf474a5dd From nobody Sun Apr 19 10:42:19 2026 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 BF541C433EF for ; Sun, 3 Jul 2022 04:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiGCEsZ (ORCPT ); Sun, 3 Jul 2022 00:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbiGCEsT (ORCPT ); Sun, 3 Jul 2022 00:48:19 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A353D60 for ; Sat, 2 Jul 2022 21:48:17 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id E545D320085B; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.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=If /pilaQUcOJoPemXdCwt98hRdp4GDkn/LpQze2e7pA=; b=fmcCA4HDPHbQ7xfb5D OC/UHa/I8tJW5f8NI4bZj8xgcB6VRjSH4Vzda716/DzC2cNF+xQcz59loX7DJmSF OKin5hv8FKUQqBz4rOIXMlwu8nLnCcx0aheKeJWxPR5YRHq4/0ZRqkg4GG/TJJsE Zw4JLIKe7kQg4Lfx4GfOZzZOAgF8WSeKRTARtED/bEdYRHbUyFpPuQTXizE/Ii5x pLj7Asn4J2bnKkUOTn0bLza5+USCuEO7onHncA9cHc3mMht8bowjk4x3HvAIU+lz 80TcdX7Gp71NWs2LWxQY0IZzmajn0BAt/LaQ04uJzgyVboYJooyG46cacgpfhQqz SOgw== 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=If/pilaQUcOJo PemXdCwt98hRdp4GDkn/LpQze2e7pA=; b=lLDxBgk4ym0i3Lh+u1hW/c63U9TEO torBNInjQURaIyBkmrvUyOhNpncXOZfICuhVIrM3VxOU8ccOvz8AjQVWKf9d1kVS 4cgjFPClIx+cZXjkU3f8u0ozQNVBXHUkkATi8HEUqinGqoSgvCooGjSa1ZxXD1D/ LUQzBxmCQooPLp9Asrmc5A26vqZtF2TAMVSuxelQS/qU9tiZm5QibxzG2rMm47IL gzoy9Fd3QooTV23hcLcr+VqNV3UXJkAK71dsQ2xw8tufD8hx5xYjlJn/FPs712BA SkI0LNKaQ6SMCgWQpa4QVN7qayuFxcolIV+ep/YOV/bzaRMtPDf2O9QVg== 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 , Arnaldo Carvalho de Melo , Jiri Olsa , Alexei Starovoitov Subject: [PATCH v1 2/3] tools: add dis-asm-compat.h to centralize handling of version differences Date: Sat, 2 Jul 2022 21:48:12 -0700 Message-Id: <20220703044814.892617-3-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3Dbinutils-gdb.git;a=3Dcommit;h=3D60a3da00bd5= 407f07 This commit introduces a wrapper for init_disassemble_info(), to avoid spreading #ifdef DISASM_INIT_STYLED to a bunch of places. It likely is worth adding a wrapper for disassember(), to avoid the already existing #ifdef DISASM_FOUR_ARGS_SIGNATURE. Cc: Quentin Monnet Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Alexei Starovoitov Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.ana= razel.de Signed-off-by: Andres Freund --- tools/include/tools/dis-asm-compat.h | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tools/include/tools/dis-asm-compat.h diff --git a/tools/include/tools/dis-asm-compat.h b/tools/include/tools/dis= -asm-compat.h new file mode 100644 index 000000000000..d1d003ee3e2f --- /dev/null +++ b/tools/include/tools/dis-asm-compat.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TOOLS_DIS_ASM_COMPAT_H +#define _TOOLS_DIS_ASM_COMPAT_H + +#include +#include +#include + +/* define types for older binutils version, to centralize ifdef'ery a bit = */ +#ifndef DISASM_INIT_STYLED +enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; +typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, cons= t char*, ...); +#endif + +/* + * Trivial fprintf wrapper to be used as the fprintf_styled_func argument = to + * init_disassemble_info_compat() when normal fprintf suffices. + */ +static inline int fprintf_styled(void *out, + enum disassembler_style style __maybe_unused, + const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + r =3D vfprintf(out, fmt, args); + va_end(args); + + return r; +} + +/* + * Wrapper for init_disassemble_info() that hides version + * differences. Depending on binutils version and architecture either + * fprintf_func or fprintf_styled_func will be called. + */ +static inline void init_disassemble_info_compat(struct disassemble_info *i= nfo, + void *stream, + fprintf_ftype unstyled_func, + fprintf_styled_ftype styled_func __maybe_unused) +{ +#ifdef DISASM_INIT_STYLED + init_disassemble_info(info, stream, + unstyled_func, + styled_func); +#else + init_disassemble_info(info, stream, + unstyled_func); +#endif +} + +#endif /* _TOOLS_DIS_ASM_COMPAT_H */ --=20 2.35.1.677.gabf474a5dd From nobody Sun Apr 19 10:42:19 2026 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 BA30CC43334 for ; Sun, 3 Jul 2022 04:48:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbiGCEsi (ORCPT ); Sun, 3 Jul 2022 00:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiGCEsU (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 1A159D45 for ; Sat, 2 Jul 2022 21:48:17 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id BF68A3200684 for ; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 03 Jul 2022 00:48:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= 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=OY wocANUXn60/A2NoBeSFagq8/qEqoWs1FFCQ5dENPI=; b=p98g3GeifKBPvTULvn A8a8E/S/4/aaSIWrlLAQpqOwVm1UEYhq5Y1SCAHEKCHFMSJ/OAMiputsC/+DDb3C hWqZ7WV8px6wH33L5KuKrqoA8RoI8M4qrehzvB39rXHVDo2+dcPt6v3ArW0FmLve 629bc907XUSULEopfTSP1aHI4NmBwPqx7wFBilJ6s2uRjDuYmepcw+FiLqFEtQ3e k9vNe9l6XjV33ktODibFWPSXwD3rspfGCauD+dlTKwDGtjWP2yQvHcrJ8DYRVoAi Viqj50UbeOFCUs+fwmH+ttwnrVWZQlieeUuH2JErtagwHQrqGAZu4/dTPKoOsS/k lAdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=OYwocANUXn60/ A2NoBeSFagq8/qEqoWs1FFCQ5dENPI=; b=w4Dv/eeSd57ClVg5VrPTszlfYva/6 b2wjKbHtlkFmbJT9Is+hHxr6/0JHz6UgixKX/ByVHk/KZKdmeGIRTI1l/p6moSUX 1glJMcjTu5KdzrdAOoGtNk+gWkl4VXO8vi9pG3682KHmq6TgW4F8kMn7vrCUg4JF Ve+OlaYqa1g1f+CtHlUbKc+MeP0d/Uny9RpA42V+0AIAlZXZobzQj+qO6sgEYqs1 8AQoEtondgIWdNWGgVarUf14FgXHCSDukYcsDD9NBKfiHQFNQ6D3mF3J1H0oZZIw K0wdfPbhbBA47QaVbRgl+HwBdeCkWno8v4aiL9grqtPPx7MfosRCkxBcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehiedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghn rghrrgiivghlrdguvgeqnecuggftrfgrthhtvghrnhepiefgieduueeiudeugfevffeugf dvffevgfdufeeujeeuheelffdtffetteffjefhnecuffhomhgrihhnpehsohhurhgtvgif rghrvgdrohhrghdpkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) From: Andres Freund To: linux-kernel@vger.kernel.org Subject: [PATCH v1 2/3] tools: introduce dis-asm.h wrapper to hide version differences Date: Sat, 2 Jul 2022 21:48:13 -0700 Message-Id: <20220703044814.892617-4-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" binutils changed the signature of init_disassemble_info(), which now causes perf and bpftool to fail to compile (e.g. on debian unstable). Relevant binutils commit: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3D60a3da00bd5= 407f07 This just wraps init_disassemble_info(), to avoid spreading #ifdef DISASM_INIT_STYLED to a bunch of places. It likely is worth adding a wrapper for disassember(), to avoid the already existing #ifdef DISASM_FOUR_ARGS_SIGNATURE. Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.ana= razel.de Signed-off-by: Andres Freund --- tools/include/tools/dis-asm-compat.h | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tools/include/tools/dis-asm-compat.h diff --git a/tools/include/tools/dis-asm-compat.h b/tools/include/tools/dis= -asm-compat.h new file mode 100644 index 000000000000..f44f7d9f053e --- /dev/null +++ b/tools/include/tools/dis-asm-compat.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TOOLS_DIS_ASM_COMPAT_H +#define _TOOLS_DIS_ASM_COMPAT_H + +#include +#include + +/* define types for older binutils version, to centralize ifdef'ery a bit = */ +#ifndef DISASM_INIT_STYLED +enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; +typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, cons= t char*, ...); +#endif + +/* + * Trivial fprintf wrapper to be used as the fprintf_styled_func argument = to + * init_disassemble_info_compat() when normal fprintf suffices. + */ +static inline int fprintf_styled(void *out, enum disassembler_style style,= const char *fmt, ...) +{ + va_list args; + int r; + + (void)style; + + va_start(args, fmt); + r =3D vfprintf(out, fmt, args); + va_end(args); + + return r; +} + +/* + * Wrapper for init_disassemble_info() that hides version + * differences. Depending on binutils version and architecture either + * fprintf_func or fprintf_styled_func will be called. + */ +static inline void init_disassemble_info_compat(struct disassemble_info *i= nfo, + void *stream, + fprintf_ftype fprintf_func, + fprintf_styled_ftype fprintf_styled_func) +{ +#ifdef DISASM_INIT_STYLED + init_disassemble_info(info, stream, + fprintf_func, + fprintf_styled_func); +#else + (void)fprintf_styled_func; + init_disassemble_info(info, stream, + fprintf_func); +#endif +} + +#endif /* _TOOLS_DIS_ASM_COMPAT_H */ --=20 2.35.1.677.gabf474a5dd From nobody Sun Apr 19 10:42:19 2026 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 7BC5FC433EF for ; Sun, 3 Jul 2022 04:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbiGCEsa (ORCPT ); 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3Dbinutils-gdb.git;a=3Dcommit;h=3D60a3da00bd5= 407f07 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 =3D 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.ana= razel.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 =20 #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)); =20 - init_disassemble_info(&info, stdout, (fprintf_ftype) fprintf); + init_disassemble_info_compat(&info, stdout, + (fprintf_ftype) fprintf, + fprintf_styled); info.arch =3D bfd_get_arch(bfdf); info.mach =3D bfd_get_mach(bfdf); info.buffer =3D 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 =20 #include "json_writer.h" #include "main.h" @@ -39,15 +40,12 @@ static void get_exec_path(char *tpath, size_t size) } =20 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; =20 - va_start(ap, fmt); err =3D vasprintf(&s, fmt, ap); - va_end(ap); if (err < 0) return -1; =20 @@ -73,6 +71,30 @@ static int fprintf_json(void *out, const char *fmt, ...) return 0; } =20 +static int fprintf_json(void *out, const char *fmt, ...) +{ + va_list ap; + int r; + + va_start(ap, fmt); + r =3D printf_json(out, fmt, ap); + va_end(ap); + + return r; +} + +static int fprintf_json_styled(void *out, enum disassembler_style style, c= onst char *fmt, ...) +{ + va_list ap; + int r; + + va_start(ap, fmt); + r =3D 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 l= en, int opcodes, assert(bfd_check_format(bfdf, bfd_object)); =20 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); =20 /* 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 =20 /* FIXME: For the HE_COLORSET */ #include "ui/browser.h" @@ -1762,9 +1763,9 @@ static int symbol__disassemble_bpf(struct symbol *sym, ret =3D errno; goto out; } - init_disassemble_info(&info, s, - (fprintf_ftype) fprintf); - + init_disassemble_info_compat(&info, s, + (fprintf_ftype) fprintf, + fprintf_styled); info.arch =3D bfd_get_arch(bfdf); info.mach =3D bfd_get_mach(bfdf); =20 --=20 2.35.1.677.gabf474a5dd