#ifndef LLVM_LIB_TARGET_BPF_BTF_H
#define LLVM_LIB_TARGET_BPF_BTF_H
#include <cstdint>
namespace llvm {
namespace BTF {
enum : uint32_t { MAGIC = 0xeB9F, VERSION = 1 };
enum {
HeaderSize = 24,
ExtHeaderSize = 32,
CommonTypeSize = 12,
BTFArraySize = 12,
BTFEnumSize = 8,
BTFEnum64Size = 12,
BTFMemberSize = 12,
BTFParamSize = 8,
BTFDataSecVarSize = 12,
SecFuncInfoSize = 8,
SecLineInfoSize = 8,
SecFieldRelocSize = 8,
BPFFuncInfoSize = 8,
BPFLineInfoSize = 16,
BPFFieldRelocSize = 16,
};
struct Header {
uint16_t Magic; uint8_t Version; uint8_t Flags; uint32_t HdrLen;
uint32_t TypeOff; uint32_t TypeLen; uint32_t StrOff; uint32_t StrLen; };
enum : uint32_t {
MAX_VLEN = 0xffff };
enum TypeKinds : uint8_t {
#define HANDLE_BTF_KIND(ID, NAME) BTF_KIND_##NAME = ID,
#include "BTF.def"
};
struct CommonType {
uint32_t NameOff;
uint32_t Info;
union {
uint32_t Size;
uint32_t Type;
};
};
enum : uint8_t {
INT_SIGNED = (1 << 0),
INT_CHAR = (1 << 1),
INT_BOOL = (1 << 2)
};
struct BTFEnum {
uint32_t NameOff; int32_t Val; };
struct BTFEnum64 {
uint32_t NameOff; uint32_t Val_Lo32; uint32_t Val_Hi32; };
struct BTFArray {
uint32_t ElemType; uint32_t IndexType; uint32_t Nelems; };
struct BTFMember {
uint32_t NameOff; uint32_t Type; uint32_t Offset; };
struct BTFParam {
uint32_t NameOff;
uint32_t Type;
};
enum : uint8_t {
FUNC_STATIC = 0,
FUNC_GLOBAL = 1,
FUNC_EXTERN = 2,
};
enum : uint8_t {
VAR_STATIC = 0, VAR_GLOBAL_ALLOCATED = 1, VAR_GLOBAL_EXTERNAL = 2, };
struct BTFDataSec {
uint32_t Type; uint32_t Offset; uint32_t Size; };
struct ExtHeader {
uint16_t Magic;
uint8_t Version;
uint8_t Flags;
uint32_t HdrLen;
uint32_t FuncInfoOff; uint32_t FuncInfoLen; uint32_t LineInfoOff; uint32_t LineInfoLen; uint32_t FieldRelocOff; uint32_t FieldRelocLen; };
struct BPFFuncInfo {
uint32_t InsnOffset; uint32_t TypeId; };
struct SecFuncInfo {
uint32_t SecNameOff; uint32_t NumFuncInfo; };
struct BPFLineInfo {
uint32_t InsnOffset; uint32_t FileNameOff; uint32_t LineOff; uint32_t LineCol; };
struct SecLineInfo {
uint32_t SecNameOff; uint32_t NumLineInfo; };
struct BPFFieldReloc {
uint32_t InsnOffset; uint32_t TypeID; uint32_t OffsetNameOff; uint32_t RelocKind; };
struct SecFieldReloc {
uint32_t SecNameOff; uint32_t NumFieldReloc; };
} }
#endif