2018-03-06 01:53:50 +01:00
|
|
|
#ifndef _BTF_ENCODER_H_
|
|
|
|
#define _BTF_ENCODER_H_ 1
|
2019-01-15 18:28:24 +01:00
|
|
|
/*
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2019-01-18 19:42:37 +01:00
|
|
|
Copyright (C) 2019 Facebook
|
|
|
|
|
|
|
|
Derived from ctf_encoder.h, which is:
|
|
|
|
Copyright (C) Arnaldo Carvalho de Melo <acme@redhat.com>
|
2019-01-15 18:28:24 +01:00
|
|
|
*/
|
2018-03-06 01:53:50 +01:00
|
|
|
|
2021-06-03 15:43:21 +02:00
|
|
|
#include <stdbool.h>
|
2021-06-03 16:10:26 +02:00
|
|
|
#include <stdint.h>
|
2021-06-03 16:45:10 +02:00
|
|
|
#include <gelf.h>
|
2021-06-08 22:52:14 +02:00
|
|
|
#include <gelf.h>
|
|
|
|
#include <gelf.h>
|
|
|
|
#include "gobuffer.h"
|
2021-06-03 15:43:21 +02:00
|
|
|
|
2021-06-02 14:32:56 +02:00
|
|
|
struct btf;
|
2018-03-06 01:53:50 +01:00
|
|
|
struct cu;
|
2021-06-03 16:35:57 +02:00
|
|
|
struct elf_symtab;
|
2021-06-03 17:34:23 +02:00
|
|
|
struct elf_function;
|
2018-03-06 01:53:50 +01:00
|
|
|
|
2021-06-03 16:10:26 +02:00
|
|
|
#define MAX_PERCPU_VAR_CNT 4096
|
|
|
|
|
|
|
|
struct var_info {
|
|
|
|
uint64_t addr;
|
|
|
|
const char *name;
|
|
|
|
uint32_t sz;
|
|
|
|
};
|
|
|
|
|
2021-06-03 15:12:41 +02:00
|
|
|
struct btf_encoder {
|
2021-06-09 14:15:49 +02:00
|
|
|
struct btf *btf;
|
2021-06-08 22:52:14 +02:00
|
|
|
struct gobuffer percpu_secinfo;
|
2021-06-08 15:10:41 +02:00
|
|
|
const char *filename;
|
2021-06-03 16:35:57 +02:00
|
|
|
struct elf_symtab *symtab;
|
2021-06-03 16:45:10 +02:00
|
|
|
GElf_Ehdr ehdr;
|
2021-06-03 16:35:57 +02:00
|
|
|
bool has_index_type,
|
|
|
|
need_index_type,
|
2021-06-08 20:17:28 +02:00
|
|
|
verbose,
|
|
|
|
force;
|
2021-06-03 16:35:57 +02:00
|
|
|
uint32_t array_index_id;
|
2021-06-03 16:10:26 +02:00
|
|
|
struct {
|
|
|
|
struct var_info vars[MAX_PERCPU_VAR_CNT];
|
|
|
|
int var_cnt;
|
2021-06-03 16:29:36 +02:00
|
|
|
uint32_t shndx;
|
|
|
|
uint64_t base_addr;
|
|
|
|
uint64_t sec_sz;
|
2021-06-03 16:10:26 +02:00
|
|
|
} percpu;
|
2021-06-03 17:34:23 +02:00
|
|
|
struct {
|
|
|
|
struct elf_function *entries;
|
|
|
|
int allocated;
|
|
|
|
int cnt;
|
|
|
|
} functions;
|
2021-06-03 15:12:41 +02:00
|
|
|
};
|
|
|
|
|
2021-06-08 20:17:28 +02:00
|
|
|
struct btf_encoder *btf_encoder__new(struct cu *cu, struct btf *base_btf, bool skip_encoding_vars, bool force, bool verbose);
|
2021-06-03 15:12:41 +02:00
|
|
|
void btf_encoder__delete(struct btf_encoder *encoder);
|
|
|
|
|
2021-06-08 19:43:35 +02:00
|
|
|
int btf_encoder__encode(struct btf_encoder *encoder, const char *detached_filename);
|
2018-12-18 23:09:39 +01:00
|
|
|
|
2021-06-08 20:35:30 +02:00
|
|
|
int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu, bool skip_encoding_vars);
|
2018-03-06 01:53:50 +01:00
|
|
|
|
|
|
|
#endif /* _BTF_ENCODER_H_ */
|