|
Packit Service |
154b7f |
/*
|
|
Packit Service |
154b7f |
SPDX-License-Identifier: GPL-2.0-only
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
Copyright (C) 2019 Facebook
|
|
Packit Service |
154b7f |
*/
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
#ifndef _LIBBTF_H
|
|
Packit Service |
154b7f |
#define _LIBBTF_H
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
#include "gobuffer.h"
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
#include <stdbool.h>
|
|
Packit Service |
154b7f |
#include <stdint.h>
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
struct btf_elf {
|
|
Packit Service |
154b7f |
union {
|
|
Packit Service |
154b7f |
struct btf_header *hdr;
|
|
Packit Service |
154b7f |
void *data;
|
|
Packit Service |
154b7f |
};
|
|
Packit Service |
154b7f |
void *priv;
|
|
Packit Service |
154b7f |
Elf *elf;
|
|
Packit Service |
154b7f |
GElf_Ehdr ehdr;
|
|
Packit Service |
154b7f |
struct gobuffer types;
|
|
Packit Service |
154b7f |
struct gobuffer *strings;
|
|
Packit Service |
154b7f |
char *filename;
|
|
Packit Service |
154b7f |
size_t size;
|
|
Packit Service |
154b7f |
int swapped;
|
|
Packit Service |
154b7f |
int in_fd;
|
|
Packit Service |
154b7f |
uint8_t wordsize;
|
|
Packit Service |
154b7f |
bool is_big_endian;
|
|
Packit Service |
154b7f |
bool raw_btf; // "/sys/kernel/btf/vmlinux"
|
|
Packit Service |
154b7f |
uint32_t type_index;
|
|
Packit Service |
154b7f |
};
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
extern uint8_t btf_elf__verbose;
|
|
Packit Service |
154b7f |
#define btf_elf__verbose_log(fmt, ...) { if (btf_elf__verbose) printf(fmt, __VA_ARGS__); }
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
struct base_type;
|
|
Packit Service |
154b7f |
struct ftype;
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
struct btf_elf *btf_elf__new(const char *filename, Elf *elf);
|
|
Packit Service |
154b7f |
void btf_elf__delete(struct btf_elf *btf);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_base_type(struct btf_elf *btf, const struct base_type *bt);
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_ref_type(struct btf_elf *btf, uint16_t kind, uint32_t type,
|
|
Packit Service |
154b7f |
uint32_t name, bool kind_flag);
|
|
Packit Service |
154b7f |
int btf_elf__add_member(struct btf_elf *btf, uint32_t name, uint32_t type, bool kind_flag,
|
|
Packit Service |
154b7f |
uint32_t bitfield_size, uint32_t bit_offset);
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_struct(struct btf_elf *btf, uint8_t kind, uint32_t name,
|
|
Packit Service |
154b7f |
bool kind_flag, uint32_t size, uint16_t nr_members);
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_array(struct btf_elf *btf, uint32_t type, uint32_t index_type,
|
|
Packit Service |
154b7f |
uint32_t nelems);
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_enum(struct btf_elf *btf, uint32_t name, uint32_t size,
|
|
Packit Service |
154b7f |
uint16_t nr_entries);
|
|
Packit Service |
154b7f |
int btf_elf__add_enum_val(struct btf_elf *btf, uint32_t name, int32_t value);
|
|
Packit Service |
154b7f |
int32_t btf_elf__add_func_proto(struct btf_elf *btf, struct ftype *ftype,
|
|
Packit Service |
154b7f |
uint32_t type_id_off);
|
|
Packit Service |
154b7f |
void btf_elf__set_strings(struct btf_elf *btf, struct gobuffer *strings);
|
|
Packit Service |
154b7f |
int btf_elf__encode(struct btf_elf *btf, uint8_t flags);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
char *btf_elf__string(struct btf_elf *btf, uint32_t ref);
|
|
Packit Service |
154b7f |
int btf_elf__load(struct btf_elf *btf);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
uint32_t btf_elf__get32(struct btf_elf *btf, uint32_t *p);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
void *btf_elf__get_buffer(struct btf_elf *btf);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
size_t btf_elf__get_size(struct btf_elf *btf);
|
|
Packit Service |
154b7f |
|
|
Packit Service |
154b7f |
#endif /* _LIBBTF_H */
|