[4/5] tools bpf_jit_disasm: Fix compilation error with new binutils
authorAndres Freund <andres@anarazel.de>
Sun, 3 Jul 2022 21:25:50 +0000 (14:25 -0700)
committerSalvatore Bonaccorso <carnil@debian.org>
Wed, 10 Aug 2022 18:11:48 +0000 (19:11 +0100)
commitb35e60d0704b439c4686c1c75b3f32072492514f
tree195d0f61ab19fdb938a023b85d5edba7a7c39be6
parent9c8ea20f08212d167a67b514d3a66a1c9783be8d
[4/5] tools bpf_jit_disasm: Fix compilation error with new binutils

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>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch
tools/bpf/Makefile
tools/bpf/bpf_jit_disasm.c