Skip to content

Commit 627be3c

Browse files
alan-maguiregregkh
authored andcommitted
libbpf: Fix parsing of multi-split BTF
[ Upstream commit 4f596ac ] When creating multi-split BTF we correctly set the start string offset to be the size of the base string section plus the base BTF start string offset; the latter is needed for multi-split BTF since the offset is non-zero there. Unfortunately the BTF parsing case needed that logic and it was missed. Fixes: 4e29128 ("libbpf/btf: Fix string handling to support multi-split BTF") Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20251104203309.318429-2-alan.maguire@oracle.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 551060e commit 627be3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/lib/bpf/btf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ static struct btf *btf_new(const void *data, __u32 size, struct btf *base_btf)
10461046
if (base_btf) {
10471047
btf->base_btf = base_btf;
10481048
btf->start_id = btf__type_cnt(base_btf);
1049-
btf->start_str_off = base_btf->hdr->str_len;
1049+
btf->start_str_off = base_btf->hdr->str_len + base_btf->start_str_off;
10501050
}
10511051

10521052
btf->raw_data = malloc(size);
@@ -5504,7 +5504,7 @@ void btf_set_base_btf(struct btf *btf, const struct btf *base_btf)
55045504
{
55055505
btf->base_btf = (struct btf *)base_btf;
55065506
btf->start_id = btf__type_cnt(base_btf);
5507-
btf->start_str_off = base_btf->hdr->str_len;
5507+
btf->start_str_off = base_btf->hdr->str_len + base_btf->start_str_off;
55085508
}
55095509

55105510
int btf__relocate(struct btf *btf, const struct btf *base_btf)

0 commit comments

Comments
 (0)