Skip to content

Commit 4e29128

Browse files
alan-maguireanakryiko
authored andcommitted
libbpf/btf: Fix string handling to support multi-split BTF
libbpf handling of split BTF has been written largely with the assumption that multiple splits are possible, i.e. split BTF on top of split BTF on top of base BTF. One area where this does not quite work is string handling in split BTF; the start string offset should be the base BTF string section length + the base BTF string offset. This worked in the past because for a single split BTF with base the start string offset was always 0. Signed-off-by: Alan Maguire <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b615ce5 commit 4e29128

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ static struct btf *btf_new_empty(struct btf *base_btf)
996996
if (base_btf) {
997997
btf->base_btf = base_btf;
998998
btf->start_id = btf__type_cnt(base_btf);
999-
btf->start_str_off = base_btf->hdr->str_len;
999+
btf->start_str_off = base_btf->hdr->str_len + base_btf->start_str_off;
10001000
btf->swapped_endian = base_btf->swapped_endian;
10011001
}
10021002

0 commit comments

Comments
 (0)