blob: aa33bb7f1b7f2d05157006df76e93054be9013f4 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 1b2013986271de39360cf79e62ed9b7d2cc59f9b Mon Sep 17 00:00:00 2001
2From: Andres Freund <andres@anarazel.de>
3Date: Wed, 22 Jun 2022 11:19:18 -0700
4Subject: [PATCH] init_disassemble_info() signature changes causes compile
5 failures
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Hi,
11
12binutils changed the signature of init_disassemble_info(), which now causes
13perf and bpftool to fail to compile (e.g. on debian unstable).
14
15Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=60a3da00bd5407f07d64dff82a4dae98230dfaac
16
17util/annotate.c: In function symbol__disassemble_bpf’:
18util/annotate.c:1765:9: error: too few arguments to function init_disassemble_info
19 1765 | init_disassemble_info(&info, s,
20 | ^~~~~~~~~~~~~~~~~~~~~
21In file included from util/annotate.c:1718:
22/usr/include/dis-asm.h:472:13: note: declared here
23 472 | extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream,
24 | ^~~~~~~~~~~~~~~~~~~~~
25
26with equivalent failures in
27
28tools/bpf/bpf_jit_disasm.c
29tools/bpf/bpftool/jit_disasm.c
30
31The fix is easy enough, add a wrapper around fprintf() that conforms to the
32new signature.
33
34However I assume the necessary feature test and wrapper should only be added
35once? I don't know the kernel stuff well enough to choose the right structure
36here.
37
38Attached is my local fix for perf. Obviously would need work to be a real
39solution.
40
41Greetings,
42
43Andres Freund
44---
45
46binutils 2.39 changed the signature of init_disassemble_info(),
47which now causes perf and bpftool to fail to compile.
48
49Relevant binutils commit: [1]
50
51There is a proper fix in development upstream[2].
52This is a work-around for older kernels.
53
54[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=60a3da00bd5407f07d64dff82a4dae98230dfaac
55[2] https://patchwork.kernel.org/project/netdevbpf/cover/20220801013834.156015-1-andres@anarazel.de/
56
57Upstream-Status: Pending
58Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
59
60
61 tools/perf/util/annotate.c | 15 ++++++++++++++-
62 1 file changed, 14 insertions(+), 1 deletion(-)
63
64diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
65index 6c8575e182ed..466a3a68f5cd 100644
66--- a/tools/perf/util/annotate.c
67+++ b/tools/perf/util/annotate.c
68@@ -1677,6 +1677,18 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
69 #include <bfd.h>
70 #include <dis-asm.h>
71
72+static int fprintf_styled(void *, enum disassembler_style, const char* fmt, ...)
73+{
74+ va_list args;
75+ int r;
76+
77+ va_start(args, fmt);
78+ r = vprintf(fmt, args);
79+ va_end(args);
80+
81+ return r;
82+}
83+
84 static int symbol__disassemble_bpf(struct symbol *sym,
85 struct annotate_args *args)
86 {
87@@ -1719,7 +1731,8 @@ static int symbol__disassemble_bpf(struct symbol *sym,
88 goto out;
89 }
90 init_disassemble_info(&info, s,
91- (fprintf_ftype) fprintf);
92+ (fprintf_ftype) fprintf,
93+ fprintf_styled);
94
95 info.arch = bfd_get_arch(bfdf);
96 info.mach = bfd_get_mach(bfdf);
97--
982.30.2
99