27fb4011fc9090881b6d9cade0e478dfdea3ec11
[openwrt/staging/neocturne.git] /
1 From 3bc373152a3a00742750dbbe974d541af78231e6 Mon Sep 17 00:00:00 2001
2 From: Andres Freund <andres@anarazel.de>
3 Date: Sun, 31 Jul 2022 18:38:30 -0700
4 Subject: [PATCH 3/5] tools perf: Fix compilation error with new binutils
5
6 binutils changed the signature of init_disassemble_info(), which now causes
7 compilation failures for tools/perf/util/annotate.c, e.g. on debian
8 unstable.
9
10 Relevant binutils commit:
11
12 https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07
13
14 Wire up the feature test and switch to init_disassemble_info_compat(),
15 which were introduced in prior commits, fixing the compilation failure.
16
17 I verified that perf can still disassemble bpf programs by using bpftrace
18 under load, recording a perf trace, and then annotating the bpf "function"
19 with and without the changes. With old binutils there's no change in output
20 before/after this patch. When comparing the output from old binutils (2.35)
21 to new bintuils with the patch (upstream snapshot) there are a few output
22 differences, but they are unrelated to this patch. An example hunk is:
23
24 1.15 : 55:mov %rbp,%rdx
25 0.00 : 58:add $0xfffffffffffffff8,%rdx
26 0.00 : 5c:xor %ecx,%ecx
27 - 1.03 : 5e:callq 0xffffffffe12aca3c
28 + 1.03 : 5e:call 0xffffffffe12aca3c
29 0.00 : 63:xor %eax,%eax
30 - 2.18 : 65:leaveq
31 - 2.82 : 66:retq
32 + 2.18 : 65:leave
33 + 2.82 : 66:ret
34
35 Signed-off-by: Andres Freund <andres@anarazel.de>
36 Acked-by: Quentin Monnet <quentin@isovalent.com>
37 Cc: Alexei Starovoitov <ast@kernel.org>
38 Cc: Ben Hutchings <benh@debian.org>
39 Cc: Jiri Olsa <jolsa@kernel.org>
40 Cc: Sedat Dilek <sedat.dilek@gmail.com>
41 Cc: bpf@vger.kernel.org
42 Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de
43 Link: https://lore.kernel.org/r/20220801013834.156015-5-andres@anarazel.de
44 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
45 (cherry picked from commit 83aa0120487e8bc3f231e72c460add783f71f17c)
46 ---
47 tools/perf/Makefile.config | 8 ++++++++
48 tools/perf/util/annotate.c | 7 ++++---
49 2 files changed, 12 insertions(+), 3 deletions(-)
50
51 --- a/tools/perf/Makefile.config
52 +++ b/tools/perf/Makefile.config
53 @@ -296,6 +296,7 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYT
54 FEATURE_CHECK_LDFLAGS-libaio = -lrt
55
56 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
57 +FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
58
59 CORE_CFLAGS += -fno-omit-frame-pointer
60 CORE_CFLAGS += -ggdb3
61 @@ -872,13 +873,16 @@ ifndef NO_LIBBFD
62 ifeq ($(feature-libbfd-liberty), 1)
63 EXTLIBS += -lbfd -lopcodes -liberty
64 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
65 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl
66 else
67 ifeq ($(feature-libbfd-liberty-z), 1)
68 EXTLIBS += -lbfd -lopcodes -liberty -lz
69 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
70 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl
71 endif
72 endif
73 $(call feature_check,disassembler-four-args)
74 + $(call feature_check,disassembler-init-styled)
75 endif
76
77 ifeq ($(feature-libbfd-buildid), 1)
78 @@ -992,6 +996,10 @@ ifeq ($(feature-disassembler-four-args),
79 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
80 endif
81
82 +ifeq ($(feature-disassembler-init-styled), 1)
83 + CFLAGS += -DDISASM_INIT_STYLED
84 +endif
85 +
86 ifeq (${IS_64_BIT}, 1)
87 ifndef NO_PERF_READ_VDSO32
88 $(call feature_check,compile-32)
89 --- a/tools/perf/util/annotate.c
90 +++ b/tools/perf/util/annotate.c
91 @@ -1694,6 +1694,7 @@ fallback:
92 #include <bpf/btf.h>
93 #include <bpf/libbpf.h>
94 #include <linux/btf.h>
95 +#include <tools/dis-asm-compat.h>
96
97 static int symbol__disassemble_bpf(struct symbol *sym,
98 struct annotate_args *args)
99 @@ -1736,9 +1737,9 @@ static int symbol__disassemble_bpf(struc
100 ret = errno;
101 goto out;
102 }
103 - init_disassemble_info(&info, s,
104 - (fprintf_ftype) fprintf);
105 -
106 + init_disassemble_info_compat(&info, s,
107 + (fprintf_ftype) fprintf,
108 + fprintf_styled);
109 info.arch = bfd_get_arch(bfdf);
110 info.mach = bfd_get_mach(bfdf);
111