aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/bpf_gen_internal.h
diff options
context:
space:
mode:
authorKumar Kartikeya Dwivedi <memxor@gmail.com>2021-10-28 12:04:55 +0530
committerAlexei Starovoitov <ast@kernel.org>2021-10-28 16:30:06 -0700
commitc24941cd3766b6de682dbe6809bd6af12271ab5b (patch)
tree986c39d2900886f2dc7b7eb2366dc946020fd548 /tools/lib/bpf/bpf_gen_internal.h
parentbpf: Add bpf_kallsyms_lookup_name helper (diff)
downloadlinux-dev-c24941cd3766b6de682dbe6809bd6af12271ab5b.tar.xz
linux-dev-c24941cd3766b6de682dbe6809bd6af12271ab5b.zip
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
Diffstat (limited to 'tools/lib/bpf/bpf_gen_internal.h')
-rw-r--r--tools/lib/bpf/bpf_gen_internal.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/lib/bpf/bpf_gen_internal.h b/tools/lib/bpf/bpf_gen_internal.h
index b8d41d6fbc40..d26e5472fe50 100644
--- a/tools/lib/bpf/bpf_gen_internal.h
+++ b/tools/lib/bpf/bpf_gen_internal.h
@@ -8,13 +8,19 @@ struct ksym_relo_desc {
int kind;
int insn_idx;
bool is_weak;
+ bool is_typeless;
};
struct ksym_desc {
const char *name;
int ref;
int kind;
- int off;
+ union {
+ /* used for kfunc */
+ int off;
+ /* used for typeless ksym */
+ bool typeless;
+ };
int insn;
};
@@ -49,7 +55,7 @@ void bpf_gen__prog_load(struct bpf_gen *gen, struct bpf_prog_load_params *load_a
void bpf_gen__map_update_elem(struct bpf_gen *gen, int map_idx, void *value, __u32 value_size);
void bpf_gen__map_freeze(struct bpf_gen *gen, int map_idx);
void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *name, enum bpf_attach_type type);
-void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, bool is_weak, int kind,
- int insn_idx);
+void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, bool is_weak,
+ bool is_typeless, int kind, int insn_idx);
#endif