Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | From 1b2013986271de39360cf79e62ed9b7d2cc59f9b Mon Sep 17 00:00:00 2001 |
| 2 | From: Andres Freund <andres@anarazel.de> |
| 3 | Date: Wed, 22 Jun 2022 11:19:18 -0700 |
| 4 | Subject: [PATCH] init_disassemble_info() signature changes causes compile |
| 5 | failures |
| 6 | MIME-Version: 1.0 |
| 7 | Content-Type: text/plain; charset=UTF-8 |
| 8 | Content-Transfer-Encoding: 8bit |
| 9 | |
| 10 | Hi, |
| 11 | |
| 12 | binutils changed the signature of init_disassemble_info(), which now causes |
| 13 | perf and bpftool to fail to compile (e.g. on debian unstable). |
| 14 | |
| 15 | Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=60a3da00bd5407f07d64dff82a4dae98230dfaac |
| 16 | |
| 17 | util/annotate.c: In function ‘symbol__disassemble_bpf’: |
| 18 | util/annotate.c:1765:9: error: too few arguments to function ‘init_disassemble_info’ |
| 19 | 1765 | init_disassemble_info(&info, s, |
| 20 | | ^~~~~~~~~~~~~~~~~~~~~ |
| 21 | In 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 | |
| 26 | with equivalent failures in |
| 27 | |
| 28 | tools/bpf/bpf_jit_disasm.c |
| 29 | tools/bpf/bpftool/jit_disasm.c |
| 30 | |
| 31 | The fix is easy enough, add a wrapper around fprintf() that conforms to the |
| 32 | new signature. |
| 33 | |
| 34 | However I assume the necessary feature test and wrapper should only be added |
| 35 | once? I don't know the kernel stuff well enough to choose the right structure |
| 36 | here. |
| 37 | |
| 38 | Attached is my local fix for perf. Obviously would need work to be a real |
| 39 | solution. |
| 40 | |
| 41 | Greetings, |
| 42 | |
| 43 | Andres Freund |
| 44 | --- |
| 45 | |
| 46 | binutils 2.39 changed the signature of init_disassemble_info(), |
| 47 | which now causes perf and bpftool to fail to compile. |
| 48 | |
| 49 | Relevant binutils commit: [1] |
| 50 | |
| 51 | There is a proper fix in development upstream[2]. |
| 52 | This 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 | |
| 57 | Upstream-Status: Pending |
| 58 | Signed-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 | |
| 64 | diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c |
| 65 | index 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 | -- |
| 98 | 2.30.2 |
| 99 | |