linux/tools/lib/bpf/relo_core.h

/* 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 {};

/* dynamically sized list of type IDs and its associated struct btf */
struct bpf_core_cand_list {};

#define BPF_CORE_SPEC_MAX_LEN

/* represents BPF CO-RE field or array element accessor */
struct bpf_core_accessor {};

struct bpf_core_spec {};

struct bpf_core_relo_res {};

int __bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id,
				const struct btf *targ_btf, __u32 targ_id, int level);
int bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id,
			      const struct btf *targ_btf, __u32 targ_id);
int __bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const struct btf *targ_btf,
			   __u32 targ_id, bool behind_ptr, int level);
int bpf_core_types_match(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);

int bpf_core_calc_relo_insn(const char *prog_name,
			    const struct bpf_core_relo *relo, int relo_idx,
			    const struct btf *local_btf,
			    struct bpf_core_cand_list *cands,
			    struct bpf_core_spec *specs_scratch,
			    struct bpf_core_relo_res *targ_res);

int bpf_core_patch_insn(const char *prog_name, struct bpf_insn *insn,
			int insn_idx, const struct bpf_core_relo *relo,
			int relo_idx, const struct bpf_core_relo_res *res);

int bpf_core_parse_spec(const char *prog_name, const struct btf *btf,
		        const struct bpf_core_relo *relo,
		        struct bpf_core_spec *spec);

int bpf_core_format_spec(char *buf, size_t buf_sz, const struct bpf_core_spec *spec);

#endif