libbpf: Support raw BTF placed in the default search path
authorTao Chen <chentao.kernel@linux.alibaba.com>
Mon, 12 Sep 2022 16:43:00 +0000 (00:43 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 22 Sep 2022 00:26:16 +0000 (17:26 -0700)
commit01f2e36c959c813a532ae836db49b2ac9de46de4
treeebfe4a27368556686e6aebb55f3b0e3de9217274
parent272d1f4cfa3c75d4828b62ef33ccb207da3b7350
libbpf: Support raw BTF placed in the default search path

Currently, the default vmlinux files at '/boot/vmlinux-*',
'/lib/modules/*/vmlinux-*' etc. are parsed with 'btf__parse_elf()' to
extract BTF. It is possible that these files are actually raw BTF files
similar to /sys/kernel/btf/vmlinux. So parse these files with
'btf__parse' which tries both raw format and ELF format.

This might be useful in some scenarios where users put their custom BTF
into known locations and don't want to specify btf_custom_path option.

Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/3f59fb5a345d2e4f10e16fe9e35fbc4c03ecaa3e.1662999860.git.chentao.kernel@linux.alibaba.com
tools/lib/bpf/btf.c