Skip to content

Commit 23eafe7

Browse files
alan-maguireKernel Patches Daemon
authored andcommitted
libbpf: add API to load extra BTF
Add btf__load_btf_extra() function to load extra BTF relative to base passed in. Base can be vmlinux or module BTF. Signed-off-by: Alan Maguire <[email protected]>
1 parent 6ff0a99 commit 23eafe7

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

tools/lib/bpf/btf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5783,6 +5783,14 @@ struct btf *btf__load_module_btf(const char *module_name, struct btf *vmlinux_bt
57835783
return btf__parse_split(path, vmlinux_btf);
57845784
}
57855785

5786+
struct btf *btf__load_btf_extra(const char *name, struct btf *base)
5787+
{
5788+
char path[80];
5789+
5790+
snprintf(path, sizeof(path), "/sys/kernel/btf_extra/%s", name);
5791+
return btf__parse_split(path, base);
5792+
}
5793+
57865794
int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx)
57875795
{
57885796
const struct btf_ext_info *seg;

tools/lib/bpf/btf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ LIBBPF_API struct btf *btf__parse_raw_split(const char *path, struct btf *base_b
138138

139139
LIBBPF_API struct btf *btf__load_vmlinux_btf(void);
140140
LIBBPF_API struct btf *btf__load_module_btf(const char *module_name, struct btf *vmlinux_btf);
141+
LIBBPF_API struct btf *btf__load_btf_extra(const char *name, struct btf *base);
141142

142143
LIBBPF_API struct btf *btf__load_from_kernel_by_id(__u32 id);
143144
LIBBPF_API struct btf *btf__load_from_kernel_by_id_split(__u32 id, struct btf *base_btf);

tools/lib/bpf/libbpf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,5 @@ LIBBPF_1.7.0 {
456456
btf__add_loc_proto_param;
457457
btf__add_locsec;
458458
btf__add_locsec_loc;
459+
btf__load_btf_extra;
459460
} LIBBPF_1.6.0;

0 commit comments

Comments
 (0)