diff options
Diffstat (limited to 'debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch')
-rw-r--r-- | debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch b/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch new file mode 100644 index 000000000..2a9c043c6 --- /dev/null +++ b/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch @@ -0,0 +1,142 @@ +From: Andres Freund <andres@anarazel.de> +Subject: [PATCH v2 5/5] tools bpftool: Fix compilation error with new binutils +Date: Sun, 3 Jul 2022 14:25:51 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-6-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation to fail for tools/bpf/bpftool/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 bpftool can still disassemble bpf programs, both with an +old and new dis-asm.h API. There are no output changes for plain and json +formats. 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: + 2f: pop %r14 + 31: pop %r13 + 33: pop %rbx +- 34: leaveq +- 35: retq ++ 34: leave ++ 35: ret + +Cc: Alexei Starovoitov <ast@kernel.org> +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/bpftool/Makefile | 7 ++++-- + tools/bpf/bpftool/jit_disasm.c | 42 +++++++++++++++++++++++++++------- + 2 files changed, 39 insertions(+), 10 deletions(-) + +diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile +index c6d2c77d0252..62195118d377 100644 +--- a/tools/bpf/bpftool/Makefile ++++ b/tools/bpf/bpftool/Makefile +@@ -93,9 +93,9 @@ INSTALL ?= install + RM ?= rm -f + + FEATURE_USER = .bpftool +-FEATURE_TESTS = libbfd disassembler-four-args zlib libcap \ ++FEATURE_TESTS = libbfd disassembler-four-args disassembler-init-styled zlib libcap \ + clang-bpf-co-re +-FEATURE_DISPLAY = libbfd disassembler-four-args zlib libcap \ ++FEATURE_DISPLAY = libbfd disassembler-four-args disassembler-init-styled zlib libcap \ + clang-bpf-co-re + + check_feat := 1 +@@ -117,6 +117,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 + + LIBS = $(LIBBPF) -lelf -lz + LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz +diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c +index 24734f2249d6..aaf99a0168c9 100644 +--- a/tools/bpf/bpftool/jit_disasm.c ++++ b/tools/bpf/bpftool/jit_disasm.c +@@ -24,6 +24,7 @@ + #include <sys/stat.h> + #include <limits.h> + #include <bpf/libbpf.h> ++#include <tools/dis-asm-compat.h> + + #include "json_writer.h" + #include "main.h" +@@ -39,15 +40,12 @@ static void get_exec_path(char *tpath, size_t size) + } + + static int oper_count; +-static int fprintf_json(void *out, const char *fmt, ...) ++static int printf_json(void *out, const char *fmt, va_list ap) + { +- va_list ap; + char *s; + int err; + +- va_start(ap, fmt); + err = vasprintf(&s, fmt, ap); +- va_end(ap); + if (err < 0) + return -1; + +@@ -73,6 +71,32 @@ static int fprintf_json(void *out, const char *fmt, ...) + return 0; + } + ++static int fprintf_json(void *out, const char *fmt, ...) ++{ ++ va_list ap; ++ int r; ++ ++ va_start(ap, fmt); ++ r = printf_json(out, fmt, ap); ++ va_end(ap); ++ ++ return r; ++} ++ ++static int fprintf_json_styled(void *out, ++ enum disassembler_style style __maybe_unused, ++ const char *fmt, ...) ++{ ++ va_list ap; ++ int r; ++ ++ va_start(ap, fmt); ++ r = printf_json(out, fmt, ap); ++ va_end(ap); ++ ++ return r; ++} ++ + void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, + const char *arch, const char *disassembler_options, + const struct btf *btf, +@@ -99,11 +123,13 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, + assert(bfd_check_format(bfdf, bfd_object)); + + if (json_output) +- init_disassemble_info(&info, stdout, +- (fprintf_ftype) fprintf_json); ++ init_disassemble_info_compat(&info, stdout, ++ (fprintf_ftype) fprintf_json, ++ fprintf_json_styled); + else +- init_disassemble_info(&info, stdout, +- (fprintf_ftype) fprintf); ++ init_disassemble_info_compat(&info, stdout, ++ (fprintf_ftype) fprintf, ++ fprintf_styled); + + /* Update architecture info for offload. */ + if (arch) { |