mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
bpf: libbpf: Add btf_line_info support to libbpf
This patch adds bpf_line_info support to libbpf: 1) Parsing the line_info sec from ".BTF.ext" 2) Relocating the line_info. If the main prog *_info relocation fails, it will ignore the remaining subprog line_info and continue. If the subprog *_info relocation fails, it will bail out. 3) BPF_PROG_LOAD a prog with line_info Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
f0187f0b17
commit
3d65014146
5 changed files with 238 additions and 88 deletions
|
@ -170,6 +170,10 @@ struct bpf_program {
|
|||
__u32 func_info_cnt;
|
||||
|
||||
struct bpf_capabilities *caps;
|
||||
|
||||
void *line_info;
|
||||
__u32 line_info_rec_size;
|
||||
__u32 line_info_cnt;
|
||||
};
|
||||
|
||||
struct bpf_map {
|
||||
|
@ -1342,6 +1346,19 @@ bpf_program_reloc_btf_ext(struct bpf_program *prog, struct bpf_object *obj,
|
|||
prog->func_info_rec_size = btf_ext__func_info_rec_size(obj->btf_ext);
|
||||
}
|
||||
|
||||
if (!insn_offset || prog->line_info) {
|
||||
err = btf_ext__reloc_line_info(obj->btf, obj->btf_ext,
|
||||
section_name, insn_offset,
|
||||
&prog->line_info,
|
||||
&prog->line_info_cnt);
|
||||
if (err)
|
||||
return check_btf_ext_reloc_err(prog, err,
|
||||
prog->line_info,
|
||||
"bpf_line_info");
|
||||
|
||||
prog->line_info_rec_size = btf_ext__line_info_rec_size(obj->btf_ext);
|
||||
}
|
||||
|
||||
if (!insn_offset)
|
||||
prog->btf_fd = btf__fd(obj->btf);
|
||||
|
||||
|
@ -1526,6 +1543,9 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
|
|||
load_attr.func_info = prog->func_info;
|
||||
load_attr.func_info_rec_size = prog->func_info_rec_size;
|
||||
load_attr.func_info_cnt = prog->func_info_cnt;
|
||||
load_attr.line_info = prog->line_info;
|
||||
load_attr.line_info_rec_size = prog->line_info_rec_size;
|
||||
load_attr.line_info_cnt = prog->line_info_cnt;
|
||||
if (!load_attr.insns || !load_attr.insns_cnt)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue