Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp996080imk; Sun, 3 Jul 2022 14:27:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u+GgUU57wbeUQOS9dHSvU9j6JyzM2Wi9kOSumZaQXXtrcjBaj0xRpCTOJHCTnTlWe6a9iq X-Received: by 2002:a65:6bd6:0:b0:39d:4f85:9ecf with SMTP id e22-20020a656bd6000000b0039d4f859ecfmr23165810pgw.336.1656883626189; Sun, 03 Jul 2022 14:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656883626; cv=none; d=google.com; s=arc-20160816; b=ZJ+0rSNagdJnjhgZyy0Ebr8euA5um2KR2BHHwixksVgfZPSEAmpNzOM31A0+xb3osC 8aGSpOmBMFlhRjX8vGwmakxYykryhWr8PZC90IQPVKKl4kn8EJVPb3kafe8vUpvuDPCw 0AolnhRpQ3o0DAtTnrFCc3UOv1X9oM8MrqiYhuS+bdUWUb12rDMWacv2O9BYUxx2fCHP U4nVz2k97isWecyLyrO4Y46KrzXeLQdiqgmXoVPJVnxvaxxRUeqs5Nwopka2EHigO48a ihDlq5NZejilNUtYeBy4uQxzdkWgeCxIM0NXKORMPbYhctaHl8YvKe2UJuclj/ePzBwv UTqw== 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=7LNZ2OJwmFx4tu69CLZFrliOhrnTXltiLtzEMLeXPkc=; b=f0JdH1ROW4akJw2q7YUgF/G6k3hxxaTCMQZeauwmPvx9jCjfGMIAG200oQ8j4bK0uM ewdf1myShsskc/d/wzdKQ06Blpf4abyyx70cuLmQfcy58JM0nCHLJ7MTyRHYLgbuXh/B 8HzpVNjvxw2YjwT86NiEkV3h3XUyEXKrkhAroE0g4hjHHtaBMX+D7mjLAPFdSaJMknOg O+hukIkGxJLPnHTpgipVdkTzrE4CI/asebgtXh6P87I+7x/cCXza++wZbDnxPZWaxJbN YNLuguSmWi7CFzV+9mDEw2eKegtAhCyP3SnarLu7nDPyP7oCeQJHJ9FpI4baP0KAWm6m mQNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm2 header.b=MRi6d5uy; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="Ba4/DiEW"; 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 u189-20020a6385c6000000b003c642710cc1si20089599pgd.725.2022.07.03.14.26.53; Sun, 03 Jul 2022 14:27:06 -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=MRi6d5uy; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="Ba4/DiEW"; 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 S230108AbiGCV0E (ORCPT + 99 others); Sun, 3 Jul 2022 17:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiGCVZ7 (ORCPT ); Sun, 3 Jul 2022 17:25:59 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FAF2325; Sun, 3 Jul 2022 14:25:56 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 45DC95C00AB; Sun, 3 Jul 2022 17:25:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 03 Jul 2022 17:25:53 -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=1656883553; x=1656969953; bh=7L NZ2OJwmFx4tu69CLZFrliOhrnTXltiLtzEMLeXPkc=; b=MRi6d5uyZSacyDYNt2 ecvwTTBgkzbT7hborJlsujr93OUXioVBQrBUf590ulHTuR5CChUiZi34zGvCsAtN SbNj4AKSV6NSqoN2Lk3OCvX2Kf9AeqYL3XNAcmZevHtlpBvW1V1fqEYw/yrxzSaB uWf4nSrnkAfuMqwjg3PZn/E7u6FpAW6O64jJYa4CSv8l/E2wQJFYBbOQ7c9lNLJP qzOQhFkf5bGy61mQo/S3KZK8ffUZPAQTeOVTbobxi7HS5FD6Zr3sjWkpNPyzdPe5 7uoUFQIPtJMQjyg9ym0WdyUetCnwMpvU0u4lVJ7hjtoFsWlbbVbVAXVGM5jE1l3B d9hg== 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=1656883553; x=1656969953; bh=7LNZ2OJwmFx4t u69CLZFrliOhrnTXltiLtzEMLeXPkc=; b=Ba4/DiEWfWlWLLuUapUrUeG42EJhV SUNa/FOTjn6mDBBumVVwlOBxILBiQVQ0w/p5LYV0C92mbVCkj3prpGCz8Yu05ytX /9KQYRthtUprz73Y9UMPP2ilKXwhrYBUx6cGveiE+fVeMsSWa4cIZnhJ50+aYUSv 4XECe8piS/d52GeMhhL0A1EQWpS9f8/cPUqHAlK493Ftwuzm4vnVJlsgoy7QhdoO D9bjVgc00h6aczmYAmQQofz9f96WL0uqDb9okbFO+DUrToz3pzHskasUmpiExg48 XBb70hzWpzFwycXkiqXMLmaRNKIaPy2d0r2X+kzietsuUjxezfmamHAWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehjedgudeigecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetnhgu rhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtf frrghtthgvrhhnpeeljefgvdefhfdukedttdevgedtkeeigefftdekleejteduveffledt ieefueegieenucffohhmrghinhepshhouhhrtggvfigrrhgvrdhorhhgpdhkvghrnhgvlh drohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Jul 2022 17:25:52 -0400 (EDT) From: Andres Freund To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Arnaldo Carvalho de Melo , Jiri Olsa , Sedat Dilek , Quentin Monnet , Daniel Borkmann Subject: [PATCH v2 4/5] tools bpf_jit_disasm: Fix compilation error with new binutils Date: Sun, 3 Jul 2022 14:25:50 -0700 Message-Id: <20220703212551.1114923-5-andres@anarazel.de> X-Mailer: git-send-email 2.37.0.3.g30cc8d0f14 In-Reply-To: <20220703212551.1114923-1-andres@anarazel.de> References: <20220622231624.t63bkmkzphqvh3kx@alap3.anarazel.de> <20220703212551.1114923-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 to fail for tools/bpf/bpf_jit_disasm.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 bpf_jit_disasm can still disassemble bpf programs, both with the old and new dis-asm.h API. 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: f4: mov %r14,%rsi f7: mov %r15,%rdx fa: mov $0x2a,%ecx - ff: callq 0xffffffffea8c4988 + ff: call 0xffffffffea8c4988 104: test %rax,%rax 107: jge 0x0000000000000110 109: xor %eax,%eax - 10b: jmpq 0x0000000000000073 + 10b: jmp 0x0000000000000073 110: cmp $0x16,%rax However, I had to use an older kernel to generate the bpf_jit_enabled = 2 output, as that has been broken since 5.18 / 1022a5498f6f: https://lore.kernel.org/20220703030210.pmjft7qc2eajzi6c@alap3.anarazel.de Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Sedat Dilek Cc: Quentin Monnet Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de Signed-off-by: Andres Freund --- tools/bpf/Makefile | 7 +++++-- tools/bpf/bpf_jit_disasm.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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 FEATURE_USER = .bpf -FEATURE_TESTS = libbfd disassembler-four-args -FEATURE_DISPLAY = libbfd disassembler-four-args +FEATURE_TESTS = libbfd disassembler-four-args disassembler-init-styled +FEATURE_DISPLAY = libbfd disassembler-four-args disassembler-init-styled check_feat := 1 NON_CHECK_FEAT_TARGETS := clean bpftool_clean runqslower_clean resolve_btfids_clean @@ -56,6 +56,9 @@ endif ifeq ($(feature-disassembler-four-args), 1) CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE endif +ifeq ($(feature-disassembler-init-styled), 1) +CFLAGS += -DDISASM_INIT_STYLED +endif $(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y $(QUIET_BISON)$(YACC) -o $@ -d $< 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; -- 2.37.0.3.g30cc8d0f14