tools/include/uapi/linux/btf.h

Source file repositories/reference/linux-study-clean/tools/include/uapi/linux/btf.h

File Facts

System
Linux kernel
Corpus path
tools/include/uapi/linux/btf.h
Extension
.h
Size
6056 bytes
Lines
216
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct btf_layout {
	__u8 info_sz;		/* size of singular element after btf_type */
	__u8 elem_sz;		/* size of each of btf_vlen(t) elements */
	__u16 flags;		/* currently unused */
};

struct btf_header {
	__u16	magic;
	__u8	version;
	__u8	flags;
	__u32	hdr_len;

	/* All offsets are in bytes relative to the end of this header */
	__u32	type_off;	/* offset of type section	*/
	__u32	type_len;	/* length of type section	*/
	__u32	str_off;	/* offset of string section	*/
	__u32	str_len;	/* length of string section	*/
	__u32	layout_off;	/* offset of layout section	*/
	__u32	layout_len;	/* length of layout section	*/
};

enum btf_max {
	/* Max possible kind */
	BTF_MAX_KIND =		0x0000007f,
	/* Max # of type identifier */
	BTF_MAX_TYPE =		0x000fffff,
	/* Max offset into the string section */
	BTF_MAX_NAME_OFFSET =	0x00ffffff,
	/* Max # of struct/union/enum members or func args */
	BTF_MAX_VLEN =		0x00ffffff,
};

struct btf_type {
	__u32 name_off;
	/* "info" bits arrangement
	 * bits  0-23: vlen (e.g. # of struct's members)
	 * bits 24-30: kind (e.g. int, ptr, array...etc)
	 * bit     31: kind_flag, currently used by
	 *             struct, union, enum, fwd, enum64,
	 *             decl_tag and type_tag
	 */
	__u32 info;
	/* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64.
	 * "size" tells the size of the type it is describing.
	 *
	 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
	 * FUNC, FUNC_PROTO, VAR, DECL_TAG and TYPE_TAG.
	 * "type" is a type_id referring to another type.
	 */
	union {
		__u32 size;
		__u32 type;
	};
};

#define BTF_INFO_KIND(info)	(((info) >> 24) & 0x7f)
#define BTF_INFO_VLEN(info)	((info) & 0xffffff)
#define BTF_INFO_KFLAG(info)	((info) >> 31)

enum {
	BTF_KIND_UNKN		= 0,	/* Unknown	*/
	BTF_KIND_INT		= 1,	/* Integer	*/
	BTF_KIND_PTR		= 2,	/* Pointer	*/
	BTF_KIND_ARRAY		= 3,	/* Array	*/
	BTF_KIND_STRUCT		= 4,	/* Struct	*/
	BTF_KIND_UNION		= 5,	/* Union	*/
	BTF_KIND_ENUM		= 6,	/* Enumeration up to 32-bit values */
	BTF_KIND_FWD		= 7,	/* Forward	*/
	BTF_KIND_TYPEDEF	= 8,	/* Typedef	*/
	BTF_KIND_VOLATILE	= 9,	/* Volatile	*/
	BTF_KIND_CONST		= 10,	/* Const	*/
	BTF_KIND_RESTRICT	= 11,	/* Restrict	*/
	BTF_KIND_FUNC		= 12,	/* Function	*/
	BTF_KIND_FUNC_PROTO	= 13,	/* Function Proto	*/
	BTF_KIND_VAR		= 14,	/* Variable	*/
	BTF_KIND_DATASEC	= 15,	/* Section	*/
	BTF_KIND_FLOAT		= 16,	/* Floating point	*/
	BTF_KIND_DECL_TAG	= 17,	/* Decl Tag */
	BTF_KIND_TYPE_TAG	= 18,	/* Type Tag */
	BTF_KIND_ENUM64		= 19,	/* Enumeration up to 64-bit values */

	NR_BTF_KINDS,
	BTF_KIND_MAX		= NR_BTF_KINDS - 1,
};

/* For some specific BTF_KIND, "struct btf_type" is immediately
 * followed by extra data.
 */

/* BTF_KIND_INT is followed by a u32 and the following

Annotation

Implementation Notes