mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-30 13:19:06 +08:00
libbpf: Add typeless ksym support to gen_loader
This uses the bpf_kallsyms_lookup_name helper added in previous patches to relocate typeless ksyms. The return value ENOENT can be ignored, and the value written to 'res' can be directly stored to the insn, as it is overwritten to 0 on lookup failure. For repeating symbols, we can simply copy the previously populated bpf_insn. Also, we need to take care to not close fds for typeless ksym_desc, so reuse the 'off' member's space to add a marker for typeless ksym and use that to skip them in cleanup_relos. We add a emit_ksym_relo_log helper that avoids duplicating common logging instructions between typeless and weak ksym (for future commit). Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211028063501.2239335-3-memxor@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
1dd20d7144
commit
8e697cf9fd
13
src/libbpf.c
13
src/libbpf.c
@@ -6575,17 +6575,14 @@ static int bpf_program__record_externs(struct bpf_program *prog)
|
||||
case RELO_EXTERN_VAR:
|
||||
if (ext->type != EXT_KSYM)
|
||||
continue;
|
||||
if (!ext->ksym.type_id) {
|
||||
pr_warn("typeless ksym %s is not supported yet\n",
|
||||
ext->name);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
bpf_gen__record_extern(obj->gen_loader, ext->name, ext->is_weak,
|
||||
bpf_gen__record_extern(obj->gen_loader, ext->name,
|
||||
ext->is_weak, !ext->ksym.type_id,
|
||||
BTF_KIND_VAR, relo->insn_idx);
|
||||
break;
|
||||
case RELO_EXTERN_FUNC:
|
||||
bpf_gen__record_extern(obj->gen_loader, ext->name, ext->is_weak,
|
||||
BTF_KIND_FUNC, relo->insn_idx);
|
||||
bpf_gen__record_extern(obj->gen_loader, ext->name,
|
||||
ext->is_weak, false, BTF_KIND_FUNC,
|
||||
relo->insn_idx);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user