btf_loader: Use btf__parse_split()

This way we use libbtf to transparently load both ELF files with a BTF
section as well as raw BTF files, such as those in /sys/kernel/btf/ or
the ones generated using 'pahole --btf_encode_detached'

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-01 15:52:46 -03:00
parent c9d4c106ab
commit 22a76fbc8b
1 changed files with 2 additions and 4 deletions

View File

@ -63,10 +63,8 @@ int btf_elf__load(struct btf_elf *btfe)
/* free initial empty BTF */
btf__free(btfe->btf);
if (btfe->raw_btf)
btfe->btf = btf__parse_raw_split(btfe->filename, btfe->base_btf);
else
btfe->btf = btf__parse_elf_split(btfe->filename, btfe->base_btf);
btfe->btf = btf__parse_split(btfe->filename, btfe->base_btf);
err = libbpf_get_error(btfe->btf);
if (err)