Commit b0588390 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Andrii Nakryiko

libbpf: Split CO-RE logic into relo_core.c.

Move CO-RE logic into separate file.
The internal interface between libbpf and CO-RE is through
bpf_core_apply_relo_insn() function and few structs defined in relo_core.h.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210721000822.40958-5-alexei.starovoitov@gmail.com
parent 301ba4d7
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o \ libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o \
netlink.o bpf_prog_linfo.o libbpf_probes.o xsk.o hashmap.o \ netlink.o bpf_prog_linfo.o libbpf_probes.o xsk.o hashmap.o \
btf_dump.o ringbuf.o strset.o linker.o gen_loader.o btf_dump.o ringbuf.o strset.o linker.o gen_loader.o relo_core.o
This diff is collapsed.
...@@ -425,4 +425,14 @@ static inline void *libbpf_ptr(void *ret) ...@@ -425,4 +425,14 @@ static inline void *libbpf_ptr(void *ret)
return ret; return ret;
} }
static inline bool str_is_empty(const char *s)
{
return !s || !s[0];
}
static inline bool is_ldimm64_insn(struct bpf_insn *insn)
{
return insn->code == (BPF_LD | BPF_IMM | BPF_DW);
}
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */ #endif /* __LIBBPF_LIBBPF_INTERNAL_H */
This diff is collapsed.
...@@ -75,8 +75,7 @@ struct bpf_core_relo { ...@@ -75,8 +75,7 @@ struct bpf_core_relo {
enum bpf_core_relo_kind kind; enum bpf_core_relo_kind kind;
}; };
struct bpf_core_cand struct bpf_core_cand {
{
const struct btf *btf; const struct btf *btf;
const struct btf_type *t; const struct btf_type *t;
const char *name; const char *name;
...@@ -89,4 +88,13 @@ struct bpf_core_cand_list { ...@@ -89,4 +88,13 @@ struct bpf_core_cand_list {
int len; int len;
}; };
int bpf_core_apply_relo_insn(const char *prog_name,
struct bpf_insn *insn, int insn_idx,
const struct bpf_core_relo *relo, int relo_idx,
const struct btf *local_btf,
struct bpf_core_cand_list *cands);
int bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id,
const struct btf *targ_btf, __u32 targ_id);
size_t bpf_core_essential_name_len(const char *name);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment