mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
struct bpf_core_relo is generated by llvm and processed by libbpf. It's a de-facto uapi. With CO-RE in the kernel the struct bpf_core_relo becomes uapi de-jure. Add an ability to pass a set of 'struct bpf_core_relo' to prog_load command and let the kernel perform CO-RE relocations. Note the struct bpf_line_info and struct bpf_func_info have the same layout when passed from LLVM to libbpf and from libbpf to the kernel except "insn_off" fields means "byte offset" when LLVM generates it. Then libbpf converts it to "insn index" to pass to the kernel. The struct bpf_core_relo's "insn_off" field is always "byte offset". Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-6-alexei.starovoitov@gmail.com
31 lines
836 B
C
31 lines
836 B
C
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
|
|
/* Copyright (c) 2019 Facebook */
|
|
|
|
#ifndef __RELO_CORE_H
|
|
#define __RELO_CORE_H
|
|
|
|
#include <linux/bpf.h>
|
|
|
|
struct bpf_core_cand {
|
|
const struct btf *btf;
|
|
const struct btf_type *t;
|
|
const char *name;
|
|
__u32 id;
|
|
};
|
|
|
|
/* dynamically sized list of type IDs and its associated struct btf */
|
|
struct bpf_core_cand_list {
|
|
struct bpf_core_cand *cands;
|
|
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
|