summaryrefslogtreecommitdiffstats
path: root/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch')
-rw-r--r--debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch b/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch
new file mode 100644
index 000000000..439b31bf0
--- /dev/null
+++ b/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch
@@ -0,0 +1,94 @@
+From: Andres Freund <andres@anarazel.de>
+Subject: [4/5] tools bpf_jit_disasm: Fix compilation error with new binutils
+Date: Sun, 3 Jul 2022 14:25:50 -0700
+Origin: https://lore.kernel.org/lkml/20220703212551.1114923-5-andres@anarazel.de/
+
+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 <ast@kernel.org>
+Cc: Daniel Borkmann <daniel@iogearbox.net>
+Cc: Sedat Dilek <sedat.dilek@gmail.com>
+Cc: Quentin Monnet <quentin@isovalent.com>
+Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de
+Signed-off-by: Andres Freund <andres@anarazel.de>
+---
+ 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 <sys/types.h>
+ #include <sys/stat.h>
+ #include <limits.h>
++#include <tools/dis-asm-compat.h>
+
+ #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;