tools bpf_jit_disasm: Fix compilation error with new binutils 05/292905/1
authorAndres Freund <andres@anarazel.de>
Mon, 1 Aug 2022 01:38:31 +0000 (18:38 -0700)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 17 May 2023 02:15:43 +0000 (11:15 +0900)
commit741e46fba140238536494a3a73717c3232fed1b8
tree1122fc3f2caea1b6901cac7b8d9a5a6dbb2ba345
parenta82d1a9a9ba7bc52f47e8fd9dcec60d5fe4a8197
tools bpf_jit_disasm: Fix compilation error with new binutils

commit 96ed066054abf11c7d3e106e3011a51f3f1227a3 upstream.

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 / 1022a5498f6f745c ("bpf,
x86_64: Use bpf_jit_binary_pack_alloc").

  https://lore.kernel.org/20220703030210.pmjft7qc2eajzi6c@alap3.anarazel.de

Signed-off-by: Andres Freund <andres@anarazel.de>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Ben Hutchings <benh@debian.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Quentin Monnet <quentin@isovalent.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de
Link: https://lore.kernel.org/r/20220801013834.156015-6-andres@anarazel.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1c27fab243333821375e4d63128d60093fdbe149)

Change-Id: I1e99c6bf30a8e7554a16f15e01240a7911f20e9f
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
tools/bpf/Makefile
tools/bpf/bpf_jit_disasm.c