bpftool: Honor BPF_CORE_TYPE_MATCHES relocation
authorDaniel Müller <deso@posteo.net>
Tue, 28 Jun 2022 16:01:19 +0000 (16:01 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 6 Jul 2022 03:26:18 +0000 (20:26 -0700)
commit633e7ceb2cbbae9b2f5ca69106b0de65728c5988
tree47cfcd9c4be1697a22fedf2ca36b1b03718de0cc
parent3c660a5d86f4c01cf641bfea004a49f5860a5bed
bpftool: Honor BPF_CORE_TYPE_MATCHES relocation

bpftool needs to know about the newly introduced BPF_CORE_TYPE_MATCHES
relocation for its 'gen min_core_btf' command to work properly in the
present of this relocation.
Specifically, we need to make sure to mark types and fields so that they
are present in the minimized BTF for "type match" checks to work out.
However, contrary to the existing btfgen_record_field_relo, we need to
rely on the BTF -- and not the spec -- to find fields. With this change
we handle this new variant correctly. The functionality will be tested
with follow on changes to BPF selftests, which already run against a
minimized BTF created with bpftool.

Signed-off-by: Daniel Müller <deso@posteo.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20220628160127.607834-3-deso@posteo.net
tools/bpf/bpftool/gen.c