Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1703385imn; Sun, 31 Jul 2022 18:43:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1saF9Wv8Un0RI//kyjBespUbu7jacPoHjZyq8D7D3eWC0s0twOmAWrGhXkxKmYBZgaR6hr3 X-Received: by 2002:a17:907:6e02:b0:72b:9f16:1bc5 with SMTP id sd2-20020a1709076e0200b0072b9f161bc5mr11177812ejc.676.1659318234292; Sun, 31 Jul 2022 18:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659318234; cv=none; d=google.com; s=arc-20160816; b=udPz+z+ZF6a7bK1Ox07lBmyn3Qn+L1ogSBPanJqJn+SWZNoJ5xCFMvG+sIiElUIdnW PgX8Cx1aEwD/orxyaUiTpjAncwwoFphcwlvQRvJzORkZC9CUzP4wW+SNYGFLEB45Sli9 LenBI0POY9jI1NNh/ArHGKaWhnUCxHfInuKeH1KInow3zmL4B1f3nnScWPVv4b3pZiZX wMmo2n6LWYg5zkBwTF3UiTSj/12pNYrf8qWMARN4+Uu7npwh81JktQ5kEAWPwhM1fTya LGWM6xIbtRZGC5Oqb9PsfjCOba7gaY79E0n02kVCojA9qp//tc6BIX/TiaMXm9t95IK4 /hvQ== 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=HJdDL6MBfDtps+1FT1nNKF79Ei+JMVz6uOUMAR+aJpk=; b=NPaGo6Y2HmLqwhnsY9/S54061yYctuZWVWqh0ofxQ0WpYVEJGi1fWScnVbVLnftG8H tnZKYkf3PUgsui+h5s19uvr8ZxTNMF/UQZKiIe1jvaCOMozOWYkIXe/eo/g9Arwvh9tx HgWXoUMw8gQZ7iDgCe24C5kX3TF1oWxJJURWAsvLFXjf0yA0E81t/bfRMFYm/DQRmCNN 0gTPMZqWturHRIOHpDFNFAmBZtkM+tk43x7boY/WbgWi/Ty87zqIDlEp31zdMnUy6fPL ax5njiNYCY41euckEVo5XvtEw8x1Pv5kxR6NS1BhwWOHLJxuiUuBj/rpQMkHM3RJRSFJ koNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm3 header.b=cQL9ePY+; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BfuICqjj; 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 dp20-20020a170906c15400b0072ed9ed7276si10664963ejc.203.2022.07.31.18.43.29; Sun, 31 Jul 2022 18:43:54 -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=fm3 header.b=cQL9ePY+; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BfuICqjj; 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 S238851AbiHABjL (ORCPT + 99 others); Sun, 31 Jul 2022 21:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238774AbiHABim (ORCPT ); Sun, 31 Jul 2022 21:38:42 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7089ECE3C; Sun, 31 Jul 2022 18:38:41 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 02136320076F; Sun, 31 Jul 2022 21:38:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 31 Jul 2022 21:38:40 -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=fm3; t=1659317919; x=1659404319; bh=HJ dDL6MBfDtps+1FT1nNKF79Ei+JMVz6uOUMAR+aJpk=; b=cQL9ePY+LFViB1DpCe cHvRZsGx14+Ndw/4yX38qdhWdgx2Ybv7SS1O20Q+qNbqORfZwTmmf15wiwhMjN5r F6kU4/7tjm6+nJ1KngqwrW3ifVHaH+fVHr/ZcWFfnDEWRl+HwYd7iKc5j6EUtc4M MW8ncj9nYQJMyV51Sj1NEZzMo4yuXinkemgB4VgfXA0uGdQxifx1b/ooqh0Eko3l WQT8J66kWz/YlPo+5MexQtZ/kR4kg9b4Y1bV7nGUjsVBjIDto0X0mbNHS1JPb3dk cRWeWYmLzYUxUt3WD4KWGhUxmAL1sssvcLxMJslJK/DHpw6LPbYVXtxpUxHX9gBo bHHw== 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=fm3; t=1659317919; x=1659404319; bh=HJdDL6MBfDtps +1FT1nNKF79Ei+JMVz6uOUMAR+aJpk=; b=BfuICqjjk9YC0N7sBU4Fv+/YpDRKC 3ZO1GnJ6g1Y6efm0QwZHKwoFKlFWYUrbQ3Rt0SJzePN9VhIi0FXzSaM0O5ZYTWnb b3gSUn8AIcryQdtT5bpo7bg5ePfl4YJPfWU2HUCPio/AZppNXrDpxsznhLKcPWK3 yd25XIq/P8I38IltjBRGo9OqA8+2UORHvlPMt6gO0RUHe48CxI6d/WT0Lo9Y+JjQ epih7hrv95N7p0jc/OWri0IyQ6zUBuv6G8PZuF4pCu87wz3YvOIcggvFGcR3jLn/ 7IZbDYc27RLyefW/oKAIa1h+73ryFcDPfgKtCwqy6n1qQfMq8VnxOSoMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddvvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepleejgfdvfefhudektddtveegtdekieegffdtkeeljeetudevffeltdei feeugeeinecuffhomhgrihhnpehsohhurhgtvgifrghrvgdrohhrghdpkhgvrhhnvghlrd horhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep rghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 31 Jul 2022 21:38:38 -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 , Ben Hutchings , Daniel Borkmann Subject: [PATCH v3 5/8] tools bpf_jit_disasm: Fix compilation error with new binutils Date: Sun, 31 Jul 2022 18:38:31 -0700 Message-Id: <20220801013834.156015-6-andres@anarazel.de> X-Mailer: git-send-email 2.37.0.3.g30cc8d0f14 In-Reply-To: <20220801013834.156015-1-andres@anarazel.de> References: <20220622231624.t63bkmkzphqvh3kx@alap3.anarazel.de> <20220801013834.156015-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 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 | 5 ++++- tools/bpf/bpf_jit_disasm.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile index b11cfc86a3d0..664601ab1705 100644 --- a/tools/bpf/Makefile +++ b/tools/bpf/Makefile @@ -34,7 +34,7 @@ else endif FEATURE_USER = .bpf -FEATURE_TESTS = libbfd disassembler-four-args +FEATURE_TESTS = libbfd disassembler-four-args disassembler-init-styled FEATURE_DISPLAY = libbfd disassembler-four-args check_feat := 1 @@ -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