LLVM 22.0.0git
BTF.h File Reference

This file contains the layout of .BTF and .BTF.ext ELF sections. More...

#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/TrailingObjects.h"
#include "BTF.def"

Go to the source code of this file.

Classes

struct  llvm::BTF::Header
 The .BTF section header definition. More...
struct  llvm::BTF::CommonType
 The BTF common type definition. More...
struct  llvm::BTF::BTFEnum
 BTF_KIND_ENUM is followed by multiple "struct BTFEnum". More...
struct  llvm::BTF::BTFEnum64
 BTF_KIND_ENUM64 is followed by multiple "struct BTFEnum64". More...
struct  llvm::BTF::BTFArray
 BTF_KIND_ARRAY is followed by one "struct BTFArray". More...
struct  llvm::BTF::BTFMember
 BTF_KIND_STRUCT and BTF_KIND_UNION are followed by multiple "struct BTFMember". More...
struct  llvm::BTF::BTFParam
 BTF_KIND_FUNC_PROTO are followed by multiple "struct BTFParam". More...
struct  llvm::BTF::BTFDataSec
 BTF_KIND_DATASEC are followed by multiple "struct BTFDataSecVar". More...
struct  llvm::BTF::ExtHeader
 The .BTF.ext section header definition. More...
struct  llvm::BTF::BPFFuncInfo
 Specifying one function info. More...
struct  llvm::BTF::SecFuncInfo
 Specifying function info's in one section. More...
struct  llvm::BTF::BPFLineInfo
 Specifying one line info. More...
struct  llvm::BTF::SecLineInfo
 Specifying line info's in one section. More...
struct  llvm::BTF::BPFFieldReloc
 Specifying one offset relocation. More...
struct  llvm::BTF::SecFieldReloc
 Specifying offset relocation's in one section. More...
struct  llvm::BTF::ArrayType
struct  llvm::BTF::StructType
struct  llvm::BTF::EnumType
struct  llvm::BTF::Enum64Type

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::BTF

Macros

#define HANDLE_BTF_KIND(ID, NAME)
#define BTF_DEFINE_TAIL(Type, Accessor)
#define BTF_DEFINE_TAIL_ARR(Type, Accessor)

Enumerations

enum  : uint32_t { llvm::BTF::MAGIC = 0xeB9F , llvm::BTF::VERSION = 1 }
enum  {
  llvm::BTF::HeaderSize = 24 , llvm::BTF::ExtHeaderSize = 32 , llvm::BTF::CommonTypeSize = 12 , llvm::BTF::BTFArraySize = 12 ,
  llvm::BTF::BTFEnumSize = 8 , llvm::BTF::BTFEnum64Size = 12 , llvm::BTF::BTFMemberSize = 12 , llvm::BTF::BTFParamSize = 8 ,
  llvm::BTF::BTFDataSecVarSize = 12 , llvm::BTF::SecFuncInfoSize = 8 , llvm::BTF::SecLineInfoSize = 8 , llvm::BTF::SecFieldRelocSize = 8 ,
  llvm::BTF::BPFFuncInfoSize = 8 , llvm::BTF::BPFLineInfoSize = 16 , llvm::BTF::BPFFieldRelocSize = 16
}
 Sizes in bytes of various things in the BTF format. More...
enum  : uint32_t { llvm::BTF::MAX_VLEN = 0xffff }
enum  llvm::BTF::TypeKinds : uint8_t
enum  : uint8_t { llvm::BTF::INT_SIGNED = (1 << 0) , llvm::BTF::INT_CHAR = (1 << 1) , llvm::BTF::INT_BOOL = (1 << 2) }
 Attributes stored in the INT_ENCODING. More...
enum  : uint8_t { llvm::BTF::FUNC_STATIC = 0 , llvm::BTF::FUNC_GLOBAL = 1 , llvm::BTF::FUNC_EXTERN = 2 }
 BTF_KIND_FUNC can be global, static or extern. More...
enum  : uint8_t { llvm::BTF::VAR_STATIC = 0 , llvm::BTF::VAR_GLOBAL_ALLOCATED = 1 , llvm::BTF::VAR_GLOBAL_EXTERNAL = 2 }
 Variable scoping information. More...
enum  llvm::BTF::PatchableRelocKind : uint32_t {
  llvm::BTF::FIELD_BYTE_OFFSET = 0 , llvm::BTF::FIELD_BYTE_SIZE , llvm::BTF::FIELD_EXISTENCE , llvm::BTF::FIELD_SIGNEDNESS ,
  llvm::BTF::FIELD_LSHIFT_U64 , llvm::BTF::FIELD_RSHIFT_U64 , llvm::BTF::BTF_TYPE_ID_LOCAL , llvm::BTF::BTF_TYPE_ID_REMOTE ,
  llvm::BTF::TYPE_EXISTENCE , llvm::BTF::TYPE_SIZE , llvm::BTF::ENUM_VALUE_EXISTENCE , llvm::BTF::ENUM_VALUE ,
  llvm::BTF::TYPE_MATCH , llvm::BTF::MAX_FIELD_RELOC_KIND
}
 CO-RE relocation kind codes used in .BTF.ext section. More...

Variables

constexpr uint32_t llvm::BTF::FWD_UNION_FLAG = 1u << 31
constexpr uint32_t llvm::BTF::ENUM_SIGNED_FLAG = 1u << 31

Detailed Description

This file contains the layout of .BTF and .BTF.ext ELF sections.

The binary layout for .BTF section: struct Header Type and Str subsections The Type subsection is a collection of types with type id starting with 1. The Str subsection is simply a collection of strings.

The binary layout for .BTF.ext section: struct ExtHeader FuncInfo, LineInfo, FieldReloc and ExternReloc subsections The FuncInfo subsection is defined as below: BTFFuncInfo Size struct SecFuncInfo for ELF section #1 A number of struct BPFFuncInfo for ELF section #1 struct SecFuncInfo for ELF section #2 A number of struct BPFFuncInfo for ELF section #2 ... The LineInfo subsection is defined as below: BPFLineInfo Size struct SecLineInfo for ELF section #1 A number of struct BPFLineInfo for ELF section #1 struct SecLineInfo for ELF section #2 A number of struct BPFLineInfo for ELF section #2 ... The FieldReloc subsection is defined as below: BPFFieldReloc Size struct SecFieldReloc for ELF section #1 A number of struct BPFFieldReloc for ELF section #1 struct SecFieldReloc for ELF section #2 A number of struct BPFFieldReloc for ELF section #2 ...

The section formats are also defined at https://github.com/torvalds/linux/blob/master/include/uapi/linux/btf.h

Definition in file BTF.h.

Macro Definition Documentation

◆ BTF_DEFINE_TAIL

#define BTF_DEFINE_TAIL ( Type,
Accessor )
Value:
const Type &Accessor() const { return *getTrailingObjects(); }

Definition at line 306 of file BTF.h.

◆ BTF_DEFINE_TAIL_ARR

#define BTF_DEFINE_TAIL_ARR ( Type,
Accessor )
Value:
ArrayRef<Type> Accessor() const { return getTrailingObjects(getVlen()); }

Definition at line 311 of file BTF.h.

◆ HANDLE_BTF_KIND

#define HANDLE_BTF_KIND ( ID,
NAME )
Value:
BTF_KIND_##NAME = ID,

Definition at line 97 of file BTF.h.