linux/tools/bpf
Ivan Babrou f4aba3471c bpftool: Un-const bpf_func_info to fix it for llvm 17 and newer
LLVM 17 started treating const structs as constants:

* https://github.com/llvm/llvm-project/commit/0b2d5b967d98

Combined with pointer laundering via ptr_to_u64, which takes a const ptr,
but in reality treats the underlying memory as mutable, this makes clang
always pass zero to btf__type_by_id, which breaks full name resolution.

Disassembly before (LLVM 16) and after (LLVM 17):

    -    8b 75 cc                 mov    -0x34(%rbp),%esi
    -    e8 47 8d 02 00           call   3f5b0 <btf__type_by_id>
    +    31 f6                    xor    %esi,%esi
    +    e8 a9 8c 02 00           call   3f510 <btf__type_by_id>

It's a bigger project to fix this properly (and a question whether LLVM
itself should detect this), but for right now let's just fix bpftool.

For more information, see this thread in bpf mailing list:

* https://lore.kernel.org/bpf/CABWYdi0ymezpYsQsPv7qzpx2fWuTkoD1-wG1eT-9x-TSREFrQg@mail.gmail.com/T/

Fixes: b662000aff ("bpftool: Adding support for BTF program names")
Signed-off-by: Ivan Babrou <ivan@cloudflare.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20240520225149.5517-1-ivan@cloudflare.com
2024-05-21 10:36:28 -07:00
..
bpftool bpftool: Un-const bpf_func_info to fix it for llvm 17 and newer 2024-05-21 10:36:28 -07:00
resolve_btfids tools/resolve_btfids: Fix cross-compilation to non-host endianness 2024-02-07 15:56:18 -08:00
runqslower bpf: Replace deprecated -target with --target= for Clang 2023-06-29 15:46:17 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
bpf_asm.c docs: networking: convert filter.txt to ReST 2020-04-28 14:39:46 -07:00
bpf_dbg.c bpf: Simplify the calculation of variables 2021-03-04 19:24:53 -08:00
bpf_exp.l bpf: fix cbpf parser bug for octal numbers 2018-06-03 07:46:55 -07:00
bpf_exp.y tools, bpf_asm: Exit non-zero on errors 2021-02-26 22:53:50 +01:00
bpf_jit_disasm.c tools bpf_jit_disasm: Fix compilation error with new binutils 2022-08-01 15:30:48 -03:00
Makefile tools bpf_jit_disasm: Don't display disassembler-four-args feature test 2022-08-01 15:31:51 -03:00