sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget/translations/zh_CN/bpf/btfmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/zh_TW/bpf/btfmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/it_IT/bpf/btfmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ja_JP/bpf/btfmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ko_KR/bpf/btfmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/sp_SP/bpf/btfmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hBPF Type Format (BTF)h]hBPF Type Format (BTF)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh5/var/lib/git/docbuild/linux/Documentation/bpf/btf.rsthKubh)}(hhh](h)}(h1. Introductionh]h1. Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXBTF (BPF Type Format) is the metadata format which encodes the debug info related to BPF program/map. The name BTF was used initially to describe data types. The BTF was later extended to include function info for defined subroutines, and line info for source/line information.h]hXBTF (BPF Type Format) is the metadata format which encodes the debug info related to BPF program/map. The name BTF was used initially to describe data types. The BTF was later extended to include function info for defined subroutines, and line info for source/line information.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe debug info is used for map pretty print, function signature, etc. The function signature enables better bpf program/function kernel symbol. The line info helps generate source annotated translated byte code, jited code and verifier log.h]hThe debug info is used for map pretty print, function signature, etc. The function signature enables better bpf program/function kernel symbol. The line info helps generate source annotated translated byte code, jited code and verifier log.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubhdefinition_list)}(hhh]hdefinition_list_item)}(hQThe BTF specification contains two parts, * BTF kernel API * BTF ELF file format h](hterm)}(h)The BTF specification contains two parts,h]h)The BTF specification contains two parts,}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh definition)}(hhh]h bullet_list)}(hhh](h list_item)}(hBTF kernel APIh]h)}(hjh]hBTF kernel API}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(hBTF ELF file format h]h)}(hBTF ELF file formath]hBTF ELF file format}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]bullet*uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhNhNubh)}(hThe kernel API is the contract between user space and kernel. The kernel verifies the BTF info before using it. The ELF file format is a user space contract between ELF file and libbpf loader.h]hThe kernel API is the contract between user space and kernel. The kernel verifies the BTF info before using it. The ELF file format is a user space contract between ELF file and libbpf loader.}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe type and string sections are part of the BTF kernel API, describing the debug info (mostly types related) referenced by the bpf program. These two sections are discussed in details in :ref:`BTF_Type_String`.h](hThe type and string sections are part of the BTF kernel API, describing the debug info (mostly types related) referenced by the bpf program. These two sections are discussed in details in }(hjdhhhNhNubh)}(h:ref:`BTF_Type_String`h]hinline)}(hjnh]hBTF_Type_String}(hjrhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1jphjlubah}(h]h ]h"]h$]h&]refdocbpf/btf refdomainj}reftyperef refexplicitrefwarn reftargetbtf_type_stringuh1hhhhKhjdubh.}(hjdhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhtarget)}(h.. _BTF_Type_String:h]h}(h]h ]h"]h$]h&]refidbtf-type-stringuh1jhKhhhhhhubeh}(h] introductionah ]h"]1. introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h2. BTF Type and String Encodingh]h2. BTF Type and String Encoding}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK!ubh)}(hfThe file ``include/uapi/linux/btf.h`` provides high-level definition of how types/strings are encoded.h](h The file }(hjhhhNhNubhliteral)}(h``include/uapi/linux/btf.h``h]hinclude/uapi/linux/btf.h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhA provides high-level definition of how types/strings are encoded.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK#hjhhubh)}(h$The beginning of data blob must be::h]h#The beginning of data blob must be:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjhhubh literal_block)}(hXstruct 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 */ };h]hXstruct 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 */ };}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhK(hjhhubh)}(hX2The magic is ``0xeB9F``, which has different encoding for big and little endian systems, and can be used to test whether BTF is generated for big- or little-endian target. The ``btf_header`` is designed to be extensible with ``hdr_len`` equal to ``sizeof(struct btf_header)`` when a data blob is generated.h](h The magic is }(hjhhhNhNubj)}(h ``0xeB9F``h]h0xeB9F}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh, which has different encoding for big and little endian systems, and can be used to test whether BTF is generated for big- or little-endian target. The }(hjhhhNhNubj)}(h``btf_header``h]h btf_header}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh# is designed to be extensible with }(hjhhhNhNubj)}(h ``hdr_len``h]hhdr_len}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh equal to }(hjhhhNhNubj)}(h``sizeof(struct btf_header)``h]hsizeof(struct btf_header)}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh when a data blob is generated.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK5hjhhubh)}(hhh](h)}(h2.1 String Encodingh]h2.1 String Encoding}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjZhhhhhKhjZhhubeh}(h]string-encodingah ]h"]2.1 string encodingah$]h&]uh1hhjhhhhhK> 24) #define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16) #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)h]h#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) #define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16) #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjRhhubh)}(h7The ``BTF_INT_ENCODING`` has the following attributes::h](hThe }(hjhhhNhNubj)}(h``BTF_INT_ENCODING``h]hBTF_INT_ENCODING}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh has the following attributes:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubj)}(hb#define BTF_INT_SIGNED (1 << 0) #define BTF_INT_CHAR (1 << 1) #define BTF_INT_BOOL (1 << 2)h]hb#define BTF_INT_SIGNED (1 << 0) #define BTF_INT_CHAR (1 << 1) #define BTF_INT_BOOL (1 << 2)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjRhhubh)}(hThe ``BTF_INT_ENCODING()`` provides extra information: signedness, char, or bool, for the int type. The char and bool encoding are mostly useful for pretty print. At most one encoding can be specified for the int type.h](hThe }(hjhhhNhNubj)}(h``BTF_INT_ENCODING()``h]hBTF_INT_ENCODING()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh provides extra information: signedness, char, or bool, for the int type. The char and bool encoding are mostly useful for pretty print. At most one encoding can be specified for the int type.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubh)}(hX#The ``BTF_INT_BITS()`` specifies the number of actual bits held by this int type. For example, a 4-bit bitfield encodes ``BTF_INT_BITS()`` equals to 4. The ``btf_type.size * 8`` must be equal to or greater than ``BTF_INT_BITS()`` for the type. The maximum value of ``BTF_INT_BITS()`` is 128.h](hThe }(hjhhhNhNubj)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhb specifies the number of actual bits held by this int type. For example, a 4-bit bitfield encodes }(hjhhhNhNubj)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh equals to 4. The }(hjhhhNhNubj)}(h``btf_type.size * 8``h]hbtf_type.size * 8}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh" must be equal to or greater than }(hjhhhNhNubj)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh$ for the type. The maximum value of }(hjhhhNhNubj)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh is 128.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubh)}(hThe ``BTF_INT_OFFSET()`` specifies the starting bit offset to calculate values for this int. For example, a bitfield struct member has:h](hThe }(hjPhhhNhNubj)}(h``BTF_INT_OFFSET()``h]hBTF_INT_OFFSET()}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjPubho specifies the starting bit offset to calculate values for this int. For example, a bitfield struct member has:}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubh block_quote)}(h* btf member bit offset 100 from the start of the structure, * btf member pointing to an int type, * the int type has ``BTF_INT_OFFSET() = 2`` and ``BTF_INT_BITS() = 4`` h]j)}(hhh](j )}(h:btf member bit offset 100 from the start of the structure,h]h)}(hj{h]h:btf member bit offset 100 from the start of the structure,}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjyubah}(h]h ]h"]h$]h&]uh1j hjvubj )}(h#btf member pointing to an int type,h]h)}(hjh]h#btf member pointing to an int type,}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjvubj )}(hEthe int type has ``BTF_INT_OFFSET() = 2`` and ``BTF_INT_BITS() = 4`` h]h)}(hDthe int type has ``BTF_INT_OFFSET() = 2`` and ``BTF_INT_BITS() = 4``h](hthe int type has }(hjhhhNhNubj)}(h``BTF_INT_OFFSET() = 2``h]hBTF_INT_OFFSET() = 2}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and }(hjhhhNhNubj)}(h``BTF_INT_BITS() = 4``h]hBTF_INT_BITS() = 4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjvubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhjrubah}(h]h ]h"]h$]h&]uh1jphhhKhjRhhubh)}(hjThen in the struct memory layout, this member will occupy ``4`` bits starting from bits ``100 + 2 = 102``.h](h:Then in the struct memory layout, this member will occupy }(hjhhhNhNubj)}(h``4``h]h4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh bits starting from bits }(hjhhhNhNubj)}(h``100 + 2 = 102``h]h 100 + 2 = 102}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubh)}(hdAlternatively, the bitfield struct member can be the following to access the same bits as the above:h]hdAlternatively, the bitfield struct member can be the following to access the same bits as the above:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubjq)}(h* btf member bit offset 102, * btf member pointing to an int type, * the int type has ``BTF_INT_OFFSET() = 0`` and ``BTF_INT_BITS() = 4`` h]j)}(hhh](j )}(hbtf member bit offset 102,h]h)}(hj4h]hbtf member bit offset 102,}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj2ubah}(h]h ]h"]h$]h&]uh1j hj/ubj )}(h#btf member pointing to an int type,h]h)}(hjKh]h#btf member pointing to an int type,}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjIubah}(h]h ]h"]h$]h&]uh1j hj/ubj )}(hEthe int type has ``BTF_INT_OFFSET() = 0`` and ``BTF_INT_BITS() = 4`` h]h)}(hDthe int type has ``BTF_INT_OFFSET() = 0`` and ``BTF_INT_BITS() = 4``h](hthe int type has }(hjdhhhNhNubj)}(h``BTF_INT_OFFSET() = 0``h]hBTF_INT_OFFSET() = 0}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjdubh and }(hjdhhhNhNubj)}(h``BTF_INT_BITS() = 4``h]hBTF_INT_BITS() = 4}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjdubeh}(h]h ]h"]h$]h&]uh1hhhhKhj`ubah}(h]h ]h"]h$]h&]uh1j hj/ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhj+ubah}(h]h ]h"]h$]h&]uh1jphhhKhjRhhubh)}(hThe original intention of ``BTF_INT_OFFSET()`` is to provide flexibility of bitfield encoding. Currently, both llvm and pahole generate ``BTF_INT_OFFSET() = 0`` for all int types.h](hThe original intention of }(hjhhhNhNubj)}(h``BTF_INT_OFFSET()``h]hBTF_INT_OFFSET()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhZ is to provide flexibility of bitfield encoding. Currently, both llvm and pahole generate }(hjhhhNhNubj)}(h``BTF_INT_OFFSET() = 0``h]hBTF_INT_OFFSET() = 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh for all int types.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjRhhubeh}(h] btf-kind-intah ]h"]2.2.1 btf_kind_intah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h2.2.2 BTF_KIND_PTRh]h2.2.2 BTF_KIND_PTR}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_PTR * ``info.vlen``: 0 * ``type``: the pointee type of the pointer h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hj?h](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjAubh: 0}(hjAhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj=ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind``: BTF_KIND_PTRh]h)}(hjdh](j)}(h ``info.kind``h]h info.kind}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1jhjfubh: BTF_KIND_PTR}(hjfhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjbubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h*``type``: the pointee type of the pointer h]h)}(h)``type``: the pointee type of the pointerh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh!: the pointee type of the pointer}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h] btf-kind-ptrah ]h"]2.2.2 btf_kind_ptrah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h2.2.3 BTF_KIND_ARRAYh]h2.2.3 BTF_KIND_ARRAY}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_ARRAY * ``info.vlen``: 0 * ``size/type``: 0, not used h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj*ubh encoding requirement:}(hj*hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj&ubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjNh](j)}(h ``name_off``h]hname_off}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1jhjPubh: 0}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjLubah}(h]h ]h"]h$]h&]uh1j hjIubj )}(h``info.kind_flag``: 0h]h)}(hjsh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjuubh: 0}(hjuhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjqubah}(h]h ]h"]h$]h&]uh1j hjIubj )}(h``info.kind``: BTF_KIND_ARRAYh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_ARRAY}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjIubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjIubj )}(h``size/type``: 0, not used h]h)}(h``size/type``: 0, not usedh](j)}(h ``size/type``h]h size/type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : 0, not used}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjIubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhjFubah}(h]h ]h"]h$]h&]uh1jhj&ubeh}(h]h ]h"]h$]h&]uh1hhhhKhj#ubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(h6``btf_type`` is followed by one ``struct btf_array``::h](j)}(h ``btf_type``h]hbtf_type}(hj" hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh is followed by one }(hj hhhNhNubj)}(h``struct btf_array``h]hstruct btf_array}(hj4 hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hSstruct btf_array { __u32 type; __u32 index_type; __u32 nelems; };h]hSstruct btf_array { __u32 type; __u32 index_type; __u32 nelems; };}hjL sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubh)}(hhh]h)}(hThe ``struct btf_array`` encoding: * ``type``: the element type * ``index_type``: the index type * ``nelems``: the number of elements for this array (``0`` is also allowed). h](h)}(h"The ``struct btf_array`` encoding:h](hThe }(hja hhhNhNubj)}(h``struct btf_array``h]hstruct btf_array}(hji hhhNhNubah}(h]h ]h"]h$]h&]uh1jhja ubh encoding:}(hja hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj] ubj)}(hhh]j)}(hhh](j )}(h``type``: the element typeh]h)}(hj h](j)}(h``type``h]htype}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: the element type}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h``index_type``: the index typeh]h)}(hj h](j)}(h``index_type``h]h index_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: the index type}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(hK``nelems``: the number of elements for this array (``0`` is also allowed). h]h)}(hJ``nelems``: the number of elements for this array (``0`` is also allowed).h](j)}(h ``nelems``h]hnelems}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh): the number of elements for this array (}(hj hhhNhNubj)}(h``0``h]h0}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh is also allowed).}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj] ubeh}(h]h ]h"]h$]h&]uh1hhhhKhjZ ubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(hX%The ``index_type`` can be any regular int type (``u8``, ``u16``, ``u32``, ``u64``, ``unsigned __int128``). The original design of including ``index_type`` follows DWARF, which has an ``index_type`` for its array type. Currently in BTF, beyond type verification, the ``index_type`` is not used.h](hThe }(hj! hhhNhNubj)}(h``index_type``h]h index_type}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh can be any regular int type (}(hj! hhhNhNubj)}(h``u8``h]hu8}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh, }(hj! hhhNhNubj)}(h``u16``h]hu16}(hjM hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh, }hj! sbj)}(h``u32``h]hu32}(hj_ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh, }(hj! hhhNhNubj)}(h``u64``h]hu64}(hjq hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh, }hj! sbj)}(h``unsigned __int128``h]hunsigned __int128}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh$). The original design of including }(hj! hhhNhNubj)}(h``index_type``h]h index_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh follows DWARF, which has an }(hj! hhhNhNubj)}(h``index_type``h]h index_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubhE for its array type. Currently in BTF, beyond type verification, the }(hj! hhhNhNubj)}(h``index_type``h]h index_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubh is not used.}(hj! hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe ``struct btf_array`` allows chaining through element type to represent multidimensional arrays. For example, for ``int a[5][6]``, the following type information illustrates the chaining:h](hThe }(hj hhhNhNubj)}(h``struct btf_array``h]hstruct btf_array}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh] allows chaining through element type to represent multidimensional arrays. For example, for }(hj hhhNhNubj)}(h``int a[5][6]``h]h int a[5][6]}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh:, the following type information illustrates the chaining:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjq)}(h* [1]: int * [2]: array, ``btf_array.type = [1]``, ``btf_array.nelems = 6`` * [3]: array, ``btf_array.type = [2]``, ``btf_array.nelems = 5`` h]j)}(hhh](j )}(h[1]: inth]h)}(hj h]h[1]: int}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h>[2]: array, ``btf_array.type = [1]``, ``btf_array.nelems = 6``h]h)}(hj# h](h [2]: array, }(hj% hhhNhNubj)}(h``btf_array.type = [1]``h]hbtf_array.type = [1]}(hj, hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj% ubh, }(hj% hhhNhNubj)}(h``btf_array.nelems = 6``h]hbtf_array.nelems = 6}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj% ubeh}(h]h ]h"]h$]h&]uh1hhhhKhj! ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h?[3]: array, ``btf_array.type = [2]``, ``btf_array.nelems = 5`` h]h)}(h>[3]: array, ``btf_array.type = [2]``, ``btf_array.nelems = 5``h](h [3]: array, }(hj\ hhhNhNubj)}(h``btf_array.type = [2]``h]hbtf_array.type = [2]}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj\ ubh, }(hj\ hhhNhNubj)}(h``btf_array.nelems = 5``h]hbtf_array.nelems = 5}(hjv hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj\ ubeh}(h]h ]h"]h$]h&]uh1hhhhKhjX ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhj ubah}(h]h ]h"]h$]h&]uh1jphhhKhjhhubh)}(hXCurrently, both pahole and llvm collapse multidimensional array into one-dimensional array, e.g., for ``a[5][6]``, the ``btf_array.nelems`` is equal to ``30``. This is because the original use case is map pretty print where the whole array is dumped out so one-dimensional array is enough. As more BTF usage is explored, pahole and llvm can be changed to generate proper chained representation for multidimensional arrays.h](hfCurrently, both pahole and llvm collapse multidimensional array into one-dimensional array, e.g., for }(hj hhhNhNubj)}(h ``a[5][6]``h]ha[5][6]}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, the }(hj hhhNhNubj)}(h``btf_array.nelems``h]hbtf_array.nelems}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh is equal to }(hj hhhNhNubj)}(h``30``h]h30}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhX. This is because the original use case is map pretty print where the whole array is dumped out so one-dimensional array is enough. As more BTF usage is explored, pahole and llvm can be changed to generate proper chained representation for multidimensional arrays.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]btf-kind-arrayah ]h"]2.2.3 btf_kind_arrayah$]h&]uh1hhjhhhhhKubh)}(hhh]h)}(h2.2.4 BTF_KIND_STRUCTh]h2.2.4 BTF_KIND_STRUCT}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKubah}(h]btf-kind-structah ]h"]2.2.4 btf_kind_structah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h2.2.5 BTF_KIND_UNIONh]h2.2.5 BTF_KIND_UNION}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKubh)}(hhh]h)}(hX``struct btf_type`` encoding requirement: * ``name_off``: 0 or offset to a valid C identifier * ``info.kind_flag``: 0 or 1 * ``info.kind``: BTF_KIND_STRUCT or BTF_KIND_UNION * ``info.vlen``: the number of struct/union members * ``info.size``: the size of the struct/union in bytes h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh encoding requirement:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubj)}(hhh]j)}(hhh](j )}(h1``name_off``: 0 or offset to a valid C identifierh]h)}(hj= h](j)}(h ``name_off``h]hname_off}(hjB hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj? ubh%: 0 or offset to a valid C identifier}(hj? hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj; ubah}(h]h ]h"]h$]h&]uh1j hj8 ubj )}(h``info.kind_flag``: 0 or 1h]h)}(hjb h](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjg hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjd ubh: 0 or 1}(hjd hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj` ubah}(h]h ]h"]h$]h&]uh1j hj8 ubj )}(h0``info.kind``: BTF_KIND_STRUCT or BTF_KIND_UNIONh]h)}(hj h](j)}(h ``info.kind``h]h info.kind}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh#: BTF_KIND_STRUCT or BTF_KIND_UNION}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj8 ubj )}(h1``info.vlen``: the number of struct/union membersh]h)}(hj h](j)}(h ``info.vlen``h]h info.vlen}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh$: the number of struct/union members}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj8 ubj )}(h5``info.size``: the size of the struct/union in bytes h]h)}(h4``info.size``: the size of the struct/union in bytesh](j)}(h ``info.size``h]h info.size}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh': the size of the struct/union in bytes}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj8 ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhj5 ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1hhj hhhNhNubh)}(hL``btf_type`` is followed by ``info.vlen`` number of ``struct btf_member``.::h](j)}(h ``btf_type``h]hbtf_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh is followed by }(hj hhhNhNubj)}(h ``info.vlen``h]h info.vlen}(hj# hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh number of }(hj hhhNhNubj)}(h``struct btf_member``h]hstruct btf_member}(hj5 hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh.:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj)}(hRstruct btf_member { __u32 name_off; __u32 type; __u32 offset; };h]hRstruct btf_member { __u32 name_off; __u32 type; __u32 offset; };}hjM sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj hhubh)}(hhh]h)}(h``struct btf_member`` encoding: * ``name_off``: offset to a valid C identifier * ``type``: the member type * ``offset``: h](h)}(h``struct btf_member`` encoding:h](j)}(h``struct btf_member``h]hstruct btf_member}(hjf hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjb ubh encoding:}(hjb hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj^ ubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hj h](j)}(h ``name_off``h]hname_off}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh : offset to a valid C identifier}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h``type``: the member typeh]h)}(hj h](j)}(h``type``h]htype}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: the member type}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h``offset``: h]h)}(h``offset``: h](j)}(h ``offset``h]hoffset}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh : }(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhKhj~ ubah}(h]h ]h"]h$]h&]uh1jhj^ ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj[ ubah}(h]h ]h"]h$]h&]uh1hhj hhhNhNubh)}(hXcIf the type info ``kind_flag`` is not set, the offset contains only bit offset of the member. Note that the base type of the bitfield can only be int or enum type. If the bitfield size is 32, the base type can be either int or enum type. If the bitfield size is not 32, the base type must be int, and int type ``BTF_INT_BITS()`` encodes the bitfield size.h](hIf the type info }(hj hhhNhNubj)}(h ``kind_flag``h]h kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhX is not set, the offset contains only bit offset of the member. Note that the base type of the bitfield can only be int or enum type. If the bitfield size is 32, the base type can be either int or enum type. If the bitfield size is not 32, the base type must be int, and int type }(hj hhhNhNubj)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh encodes the bitfield size.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hIf the ``kind_flag`` is set, the ``btf_member.offset`` contains both member bitfield size and bit offset. The bitfield size and bit offset are calculated as below.::h](hIf the }(hj>hhhNhNubj)}(h ``kind_flag``h]h kind_flag}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj>ubh is set, the }(hj>hhhNhNubj)}(h``btf_member.offset``h]hbtf_member.offset}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj>ubhn contains both member bitfield size and bit offset. The bitfield size and bit offset are calculated as below.:}(hj>hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hp#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24) #define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff)h]hp#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24) #define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff)}hjpsbah}(h]h ]h"]h$]h&]jjuh1jhhhM hj hhubh)}(hMIn this case, if the base type is an int type, it must be a regular int type:h]hMIn this case, if the base type is an int type, it must be a regular int type:}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubjq)}(h^* ``BTF_INT_OFFSET()`` must be 0. * ``BTF_INT_BITS()`` must be equal to ``{1,2,4,8,16} * 8``. h]j)}(hhh](j )}(h``BTF_INT_OFFSET()`` must be 0.h]h)}(hjh](j)}(h``BTF_INT_OFFSET()``h]hBTF_INT_OFFSET()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh must be 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h:``BTF_INT_BITS()`` must be equal to ``{1,2,4,8,16} * 8``. h]h)}(h9``BTF_INT_BITS()`` must be equal to ``{1,2,4,8,16} * 8``.h](j)}(h``BTF_INT_BITS()``h]hBTF_INT_BITS()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh must be equal to }(hjhhhNhNubj)}(h``{1,2,4,8,16} * 8``h]h{1,2,4,8,16} * 8}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jphhhMhj hhubh)}(hOCommit 9d5f9f701b18 introduced ``kind_flag`` and explains why both modes exist.h](hCommit 9d5f9f701b18 introduced }(hjhhhNhNubj)}(h ``kind_flag``h]h kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh# and explains why both modes exist.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]btf-kind-unionah ]h"]2.2.5 btf_kind_unionah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h2.2.6 BTF_KIND_ENUMh]h2.2.6 BTF_KIND_ENUM}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 or offset to a valid C identifier * ``info.kind_flag``: 0 for unsigned, 1 for signed * ``info.kind``: BTF_KIND_ENUM * ``info.vlen``: number of enum values * ``size``: 1/2/4/8 h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj<ubh encoding requirement:}(hj<hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj8ubj)}(hhh]j)}(hhh](j )}(h1``name_off``: 0 or offset to a valid C identifierh]h)}(hj`h](j)}(h ``name_off``h]hname_off}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhjbubh%: 0 or offset to a valid C identifier}(hjbhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj^ubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h0``info.kind_flag``: 0 for unsigned, 1 for signedh]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0 for unsigned, 1 for signed}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h``info.kind``: BTF_KIND_ENUMh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_ENUM}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h$``info.vlen``: number of enum valuesh]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: number of enum values}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h``size``: 1/2/4/8 h]h)}(h``size``: 1/2/4/8h](j)}(h``size``h]hsize}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : 1/2/4/8}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj[ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjXubah}(h]h ]h"]h$]h&]uh1jhj8ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj5ubah}(h]h ]h"]h$]h&]uh1hhj$hhhNhNubh)}(hJ``btf_type`` is followed by ``info.vlen`` number of ``struct btf_enum``.::h](j)}(h ``btf_type``h]hbtf_type}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh is followed by }(hj0hhhNhNubj)}(h ``info.vlen``h]h info.vlen}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh number of }(hj0hhhNhNubj)}(h``struct btf_enum``h]hstruct btf_enum}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh.:}(hj0hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM!hj$hhubj)}(h;struct btf_enum { __u32 name_off; __s32 val; };h]h;struct btf_enum { __u32 name_off; __s32 val; };}hjpsbah}(h]h ]h"]h$]h&]jjuh1jhhhM#hj$hhubh)}(hhh]h)}(h_The ``btf_enum`` encoding: * ``name_off``: offset to a valid C identifier * ``val``: any value h](h)}(hThe ``btf_enum`` encoding:h](hThe }(hjhhhNhNubj)}(h ``btf_enum``h]hbtf_enum}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM*hjubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : offset to a valid C identifier}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM)hjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``val``: any value h]h)}(h``val``: any valueh](j)}(h``val``h]hval}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : any value}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM*hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM)hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhM*hj~ubah}(h]h ]h"]h$]h&]uh1hhj$hhhNhNubh)}(hIf the original enum value is signed and the size is less than 4, that value will be sign extended into 4 bytes. If the size is 8, the value will be truncated into 4 bytes.h]hIf the original enum value is signed and the size is less than 4, that value will be sign extended into 4 bytes. If the size is 8, the value will be truncated into 4 bytes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM,hj$hhubeh}(h] btf-kind-enumah ]h"]2.2.6 btf_kind_enumah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.7 BTF_KIND_FWDh]h2.2.7 BTF_KIND_FWD}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhM1ubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: offset to a valid C identifier * ``info.kind_flag``: 0 for struct, 1 for union * ``info.kind``: BTF_KIND_FWD * ``info.vlen``: 0 * ``type``: 0 h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj<ubh encoding requirement:}(hj<hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM8hj8ubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hj`h](j)}(h ``name_off``h]hname_off}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhjbubh : offset to a valid C identifier}(hjbhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM4hj^ubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h-``info.kind_flag``: 0 for struct, 1 for unionh]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0 for struct, 1 for union}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM5hjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h``info.kind``: BTF_KIND_FWDh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_FWD}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM6hjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM7hjubah}(h]h ]h"]h$]h&]uh1j hj[ubj )}(h ``type``: 0 h]h)}(h ``type``: 0h](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM8hjubah}(h]h ]h"]h$]h&]uh1j hj[ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM4hjXubah}(h]h ]h"]h$]h&]uh1jhj8ubeh}(h]h ]h"]h$]h&]uh1hhhhM8hj5ubah}(h]h ]h"]h$]h&]uh1hhj$hhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hj0hhhNhNubj)}(h ``btf_type``h]hbtf_type}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh.}(hj0hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM:hj$hhubeh}(h] btf-kind-fwdah ]h"]2.2.7 btf_kind_fwdah$]h&]uh1hhjhhhhhM1ubh)}(hhh](h)}(h2.2.8 BTF_KIND_TYPEDEFh]h2.2.8 BTF_KIND_TYPEDEF}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjXhhhhhM=ubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: offset to a valid C identifier * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_TYPEDEF * ``info.vlen``: 0 * ``type``: the type which can be referred by name at ``name_off`` h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1jhjpubh encoding requirement:}(hjphhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMDhjlubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : offset to a valid C identifier}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM@hjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMAhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind``: BTF_KIND_TYPEDEFh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_TYPEDEF}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMBhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMChjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(hA``type``: the type which can be referred by name at ``name_off`` h]h)}(h@``type``: the type which can be referred by name at ``name_off``h](j)}(h``type``h]htype}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj*ubh,: the type which can be referred by name at }(hj*hhhNhNubj)}(h ``name_off``h]hname_off}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj*ubeh}(h]h ]h"]h$]h&]uh1hhhhMDhj&ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM@hjubah}(h]h ]h"]h$]h&]uh1jhjlubeh}(h]h ]h"]h$]h&]uh1hhhhMDhjiubah}(h]h ]h"]h$]h&]uh1hhjXhhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjrhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjrubh.}(hjrhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMFhjXhhubeh}(h]btf-kind-typedefah ]h"]2.2.8 btf_kind_typedefah$]h&]uh1hhjhhhhhM=ubh)}(hhh](h)}(h2.2.9 BTF_KIND_VOLATILEh]h2.2.9 BTF_KIND_VOLATILE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMIubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_VOLATILE * ``info.vlen``: 0 * ``type``: the type with ``volatile`` qualifier h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMPhjubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMLhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h ``info.kind``: BTF_KIND_VOLATILEh]h)}(hj h](j)}(h ``info.kind``h]h info.kind}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj"ubh: BTF_KIND_VOLATILE}(hj"hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMNhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: 0h]h)}(hjEh](j)}(h ``info.vlen``h]h info.vlen}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjGubh: 0}(hjGhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMOhjCubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h/``type``: the type with ``volatile`` qualifier h]h)}(h.``type``: the type with ``volatile`` qualifierh](j)}(h``type``h]htype}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1jhjlubh: the type with }(hjlhhhNhNubj)}(h ``volatile``h]hvolatile}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjlubh qualifier}(hjlhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMPhjhubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMLhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMPhjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMRhjhhubeh}(h]btf-kind-volatileah ]h"]2.2.9 btf_kind_volatileah$]h&]uh1hhjhhhhhMIubh)}(hhh](h)}(h2.2.10 BTF_KIND_CONSTh]h2.2.10 BTF_KIND_CONST}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMUubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_CONST * ``info.vlen``: 0 * ``type``: the type with ``const`` qualifier h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjh](j)}(h ``name_off``h]hname_off}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMXhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjAh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjCubh: 0}(hjChhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMYhj?ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind``: BTF_KIND_CONSTh]h)}(hjfh](j)}(h ``info.kind``h]h info.kind}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh: BTF_KIND_CONST}(hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMZhjdubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM[hjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h,``type``: the type with ``const`` qualifier h]h)}(h+``type``: the type with ``const`` qualifierh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: the type with }(hjhhhNhNubj)}(h ``const``h]hconst}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh qualifier}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMXhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM^hjhhubeh}(h]btf-kind-constah ]h"]2.2.10 btf_kind_constah$]h&]uh1hhjhhhhhMUubh)}(hhh](h)}(h2.2.11 BTF_KIND_RESTRICTh]h2.2.11 BTF_KIND_RESTRICT}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj&hhhhhMaubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_RESTRICT * ``info.vlen``: 0 * ``type``: the type with ``restrict`` qualifier h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj>ubh encoding requirement:}(hj>hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhhj:ubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjbh](j)}(h ``name_off``h]hname_off}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1jhjdubh: 0}(hjdhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMdhj`ubah}(h]h ]h"]h$]h&]uh1j hj]ubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMehjubah}(h]h ]h"]h$]h&]uh1j hj]ubj )}(h ``info.kind``: BTF_KIND_RESTRICTh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_RESTRICT}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMfhjubah}(h]h ]h"]h$]h&]uh1j hj]ubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMghjubah}(h]h ]h"]h$]h&]uh1j hj]ubj )}(h/``type``: the type with ``restrict`` qualifier h]h)}(h.``type``: the type with ``restrict`` qualifierh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: the type with }(hjhhhNhNubj)}(h ``restrict``h]hrestrict}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh qualifier}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhhjubah}(h]h ]h"]h$]h&]uh1j hj]ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMdhjZubah}(h]h ]h"]h$]h&]uh1jhj:ubeh}(h]h ]h"]h$]h&]uh1hhhhMhhj7ubah}(h]h ]h"]h$]h&]uh1hhj&hhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjDhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjDubh.}(hjDhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMjhj&hhubeh}(h]btf-kind-restrictah ]h"]2.2.11 btf_kind_restrictah$]h&]uh1hhjhhhhhMaubh)}(hhh](h)}(h2.2.12 BTF_KIND_FUNCh]h2.2.12 BTF_KIND_FUNC}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhjlhhhhhMmubh)}(hhh]h)}(hXO``struct btf_type`` encoding requirement: * ``name_off``: offset to a valid C identifier * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_FUNC * ``info.vlen``: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBAL or BTF_FUNC_EXTERN - see :ref:`BTF_Function_Linkage_Constants`) * ``type``: a BTF_KIND_FUNC_PROTO type h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMuhjubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh : offset to a valid C identifier}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMphjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMqhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind``: BTF_KIND_FUNCh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_FUNC}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMrhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBAL or BTF_FUNC_EXTERN - see :ref:`BTF_Function_Linkage_Constants`)h]h)}(hhh]h)}(h``info.vlen``: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBAL or BTF_FUNC_EXTERN - see :ref:`BTF_Function_Linkage_Constants`)h](h)}(hD``info.vlen``: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBALh](j)}(h ``info.vlen``h]h info.vlen}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh7: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBAL}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMshjubj)}(hhh]h)}(h?or BTF_FUNC_EXTERN - see :ref:`BTF_Function_Linkage_Constants`)h](hor BTF_FUNC_EXTERN - see }(hj?hhhNhNubh)}(h%:ref:`BTF_Function_Linkage_Constants`h]jq)}(hjIh]hBTF_Function_Linkage_Constants}(hjKhhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphjGubah}(h]h ]h"]h$]h&]refdocj refdomainjUreftyperef refexplicitrefwarnjbtf_function_linkage_constantsuh1hhhhMthj?ubh)}(hj?hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMthj<ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMshjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h%``type``: a BTF_KIND_FUNC_PROTO type h]h)}(h$``type``: a BTF_KIND_FUNC_PROTO typeh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: a BTF_KIND_FUNC_PROTO type}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMuhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMphjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMuhj}ubah}(h]h ]h"]h$]h&]uh1hhjlhhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hjhhhNhNubj)}(h ``btf_type``h]hbtf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMwhjlhhubh)}(hX*A BTF_KIND_FUNC defines not a type, but a subprogram (function) whose signature is defined by ``type``. The subprogram is thus an instance of that type. The BTF_KIND_FUNC may in turn be referenced by a func_info in the :ref:`BTF_Ext_Section` (ELF) or in the arguments to :ref:`BPF_Prog_Load` (ABI).h](h^A BTF_KIND_FUNC defines not a type, but a subprogram (function) whose signature is defined by }(hjhhhNhNubj)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhu. The subprogram is thus an instance of that type. The BTF_KIND_FUNC may in turn be referenced by a func_info in the }(hjhhhNhNubh)}(h:ref:`BTF_Ext_Section`h]jq)}(hjh]hBTF_Ext_Section}(hjhhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjbtf_ext_sectionuh1hhhhMyhjubh (ELF) or in the arguments to }(hjhhhNhNubh)}(h:ref:`BPF_Prog_Load`h]jq)}(hj'h]h BPF_Prog_Load}(hj)hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphj%ubah}(h]h ]h"]h$]h&]refdocj refdomainj3reftyperef refexplicitrefwarnj bpf_prog_loaduh1hhhhMyhjubh (ABI).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMyhjlhhubh)}(hbCurrently, only linkage values of BTF_FUNC_STATIC and BTF_FUNC_GLOBAL are supported in the kernel.h]hbCurrently, only linkage values of BTF_FUNC_STATIC and BTF_FUNC_GLOBAL are supported in the kernel.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjlhhubeh}(h] btf-kind-funcah ]h"]2.2.12 btf_kind_funcah$]h&]uh1hhjhhhhhMmubh)}(hhh](h)}(h2.2.13 BTF_KIND_FUNC_PROTOh]h2.2.13 BTF_KIND_FUNC_PROTO}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjehhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_FUNC_PROTO * ``info.vlen``: # of parameters * ``type``: the return type h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj}ubh encoding requirement:}(hj}hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjyubj)}(hhh]j)}(hhh](j )}(h``name_off``: 0h]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h"``info.kind``: BTF_KIND_FUNC_PROTOh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_FUNC_PROTO}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: # of parametersh]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: # of parameters}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``type``: the return type h]h)}(h``type``: the return typeh](j)}(h``type``h]htype}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj7ubh: the return type}(hj7hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj3ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjyubeh}(h]h ]h"]h$]h&]uh1hhhhMhjvubah}(h]h ]h"]h$]h&]uh1hhjehhhNhNubh)}(hK``btf_type`` is followed by ``info.vlen`` number of ``struct btf_param``.::h](j)}(h ``btf_type``h]hbtf_type}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjqubh is followed by }(hjqhhhNhNubj)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjqubh number of }(hjqhhhNhNubj)}(h``struct btf_param``h]hstruct btf_param}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjqubh.:}(hjqhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjehhubj)}(h=struct btf_param { __u32 name_off; __u32 type; };h]h=struct btf_param { __u32 name_off; __u32 type; };}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjehhubh)}(hIf a BTF_KIND_FUNC_PROTO type is referred by a BTF_KIND_FUNC type, then ``btf_param.name_off`` must point to a valid C identifier except for the possible last argument representing the variable argument. The btf_param.type refers to parameter type.h](hHIf a BTF_KIND_FUNC_PROTO type is referred by a BTF_KIND_FUNC type, then }(hjhhhNhNubj)}(h``btf_param.name_off``h]hbtf_param.name_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh must point to a valid C identifier except for the possible last argument representing the variable argument. The btf_param.type refers to parameter type.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjehhubh)}(hmIf the function has variable arguments, the last parameter is encoded with ``name_off = 0`` and ``type = 0``.h](hKIf the function has variable arguments, the last parameter is encoded with }(hjhhhNhNubj)}(h``name_off = 0``h]h name_off = 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and }(hjhhhNhNubj)}(h ``type = 0``h]htype = 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjehhubeh}(h]btf-kind-func-protoah ]h"]2.2.13 btf_kind_func_protoah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.14 BTF_KIND_VARh]h2.2.14 BTF_KIND_VAR}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: offset to a valid C identifier * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_VAR * ``info.vlen``: 0 * ``type``: the type of the variable h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj1ubh encoding requirement:}(hj1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-ubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hjUh](j)}(h ``name_off``h]hname_off}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjWubh : offset to a valid C identifier}(hjWhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjSubah}(h]h ]h"]h$]h&]uh1j hjPubj )}(h``info.kind_flag``: 0h]h)}(hjzh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj|ubh: 0}(hj|hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjxubah}(h]h ]h"]h$]h&]uh1j hjPubj )}(h``info.kind``: BTF_KIND_VARh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_VAR}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjPubj )}(h``info.vlen``: 0h]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjPubj )}(h#``type``: the type of the variable h]h)}(h"``type``: the type of the variableh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: the type of the variable}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjPubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjMubah}(h]h ]h"]h$]h&]uh1jhj-ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj*ubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(hV``btf_type`` is followed by a single ``struct btf_variable`` with the following data::h](j)}(h ``btf_type``h]hbtf_type}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh is followed by a single }(hj%hhhNhNubj)}(h``struct btf_variable``h]hstruct btf_variable}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh with the following data:}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h(struct btf_var { __u32 linkage; };h]h(struct btf_var { __u32 linkage; };}hjSsbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjhhubh)}(h``btf_var.linkage`` may take the values: BTF_VAR_STATIC, BTF_VAR_GLOBAL_ALLOCATED or BTF_VAR_GLOBAL_EXTERN - see :ref:`BTF_Var_Linkage_Constants`.h](j)}(h``btf_var.linkage``h]hbtf_var.linkage}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhjaubh^ may take the values: BTF_VAR_STATIC, BTF_VAR_GLOBAL_ALLOCATED or BTF_VAR_GLOBAL_EXTERN - see }(hjahhhNhNubh)}(h :ref:`BTF_Var_Linkage_Constants`h]jq)}(hjyh]hBTF_Var_Linkage_Constants}(hj{hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphjwubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjbtf_var_linkage_constantsuh1hhhhMhjaubh.}(hjahhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hkNot all type of global variables are supported by LLVM at this point. The following is currently available:h]hkNot all type of global variables are supported by LLVM at this point. The following is currently available:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjq)}(ha* static variables with or without section attributes * global variables with section attributes h]j)}(hhh](j )}(h3static variables with or without section attributesh]h)}(hjh]h3static variables with or without section attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h)global variables with section attributes h]h)}(h(global variables with section attributesh]h(global variables with section attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jphhhMhjhhubh)}(hUThe latter is for future extraction of map key/value type id's from a map definition.h]hWThe latter is for future extraction of map key/value type id’s from a map definition.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h] btf-kind-varah ]h"]2.2.14 btf_kind_varah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.15 BTF_KIND_DATASECh]h2.2.15 BTF_KIND_DATASEC}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hhh]h)}(hXu``struct btf_type`` encoding requirement: * ``name_off``: offset to a valid name associated with a variable or one of .data/.bss/.rodata * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_DATASEC * ``info.vlen``: # of variables * ``size``: total section size in bytes (0 at compilation time, patched to actual size by BPF loaders such as libbpf) h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubj)}(hhh]j)}(hhh](j )}(hj``name_off``: offset to a valid name associated with a variable or one of .data/.bss/.rodatah]h)}(hhh]h)}(h\``name_off``: offset to a valid name associated with a variable or one of .data/.bss/.rodatah](h)}(hB``name_off``: offset to a valid name associated with a variable orh](j)}(h ``name_off``h]hname_off}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjLubh6: offset to a valid name associated with a variable or}(hjLhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjHubj)}(hhh]h)}(hone of .data/.bss/.rodatah]hone of .data/.bss/.rodata}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhubah}(h]h ]h"]h$]h&]uh1jhjHubeh}(h]h ]h"]h$]h&]uh1hhhhMhjEubah}(h]h ]h"]h$]h&]uh1hhjAubah}(h]h ]h"]h$]h&]uh1j hj>ubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj>ubj )}(h``info.kind``: BTF_KIND_DATASECh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_DATASEC}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj>ubj )}(h``info.vlen``: # of variablesh]h)}(hjh](j)}(h ``info.vlen``h]h info.vlen}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: # of variables}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hj>ubj )}(h~``size``: total section size in bytes (0 at compilation time, patched to actual size by BPF loaders such as libbpf) h]h)}(hhh]h)}(ht``size``: total section size in bytes (0 at compilation time, patched to actual size by BPF loaders such as libbpf) h](h)}(hE``size``: total section size in bytes (0 at compilation time, patchedh](j)}(h``size``h]hsize}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh=: total section size in bytes (0 at compilation time, patched}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubj)}(hhh]h)}(h-to actual size by BPF loaders such as libbpf)h]h-to actual size by BPF loaders such as libbpf)}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1j hj>ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhj;ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(hQ``btf_type`` is followed by ``info.vlen`` number of ``struct btf_var_secinfo``.::h](j)}(h ``btf_type``h]hbtf_type}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh is followed by }(hjhhhhNhNubj)}(h ``info.vlen``h]h info.vlen}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh number of }(hjhhhhNhNubj)}(h``struct btf_var_secinfo``h]hstruct btf_var_secinfo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh.:}(hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hSstruct btf_var_secinfo { __u32 type; __u32 offset; __u32 size; };h]hSstruct btf_var_secinfo { __u32 type; __u32 offset; __u32 size; };}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjhhubh)}(hhh]h)}(h``struct btf_var_secinfo`` encoding: * ``type``: the type of the BTF_KIND_VAR variable * ``offset``: the in-section offset of the variable * ``size``: the size of the variable in bytes h](h)}(h$``struct btf_var_secinfo`` encoding:h](j)}(h``struct btf_var_secinfo``h]hstruct btf_var_secinfo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubj)}(hhh]j)}(hhh](j )}(h/``type``: the type of the BTF_KIND_VAR variableh]h)}(hjh](j)}(h``type``h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh': the type of the BTF_KIND_VAR variable}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h1``offset``: the in-section offset of the variableh]h)}(hjh](j)}(h ``offset``h]hoffset}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh': the in-section offset of the variable}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h,``size``: the size of the variable in bytes h]h)}(h+``size``: the size of the variable in bytesh](j)}(h``size``h]hsize}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj-ubh#: the size of the variable in bytes}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj)ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubeh}(h]btf-kind-datasecah ]h"]2.2.15 btf_kind_datasecah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.16 BTF_KIND_FLOATh]h2.2.16 BTF_KIND_FLOAT}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjohhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: any valid offset * ``info.kind_flag``: 0 * ``info.kind``: BTF_KIND_FLOAT * ``info.vlen``: 0 * ``size``: the size of the float type in bytes: 2, 4, 8, 12 or 16. h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh encoding requirement:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubj)}(hhh]j)}(hhh](j )}(h``name_off``: any valid offseth]h)}(hjh](j)}(h ``name_off``h]hname_off}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: any valid offset}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind_flag``: 0h]h)}(hjh](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: 0}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.kind``: BTF_KIND_FLOATh]h)}(hjh](j)}(h ``info.kind``h]h info.kind}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh: BTF_KIND_FLOAT}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h``info.vlen``: 0h]h)}(hj h](j)}(h ``info.vlen``h]h info.vlen}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: 0}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(hB``size``: the size of the float type in bytes: 2, 4, 8, 12 or 16. h]h)}(hA``size``: the size of the float type in bytes: 2, 4, 8, 12 or 16.h](j)}(h``size``h]hsize}(hjE hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA ubh9: the size of the float type in bytes: 2, 4, 8, 12 or 16.}(hjA hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj= ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjohhhNhNubh)}(h,No additional type data follow ``btf_type``.h](hNo additional type data follow }(hj{ hhhNhNubj)}(h ``btf_type``h]hbtf_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj{ ubh.}(hj{ hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjohhubeh}(h]btf-kind-floatah ]h"]2.2.16 btf_kind_floatah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.17 BTF_KIND_DECL_TAGh]h2.2.17 BTF_KIND_DECL_TAG}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: offset to a non-empty string * ``info.kind_flag``: 0 or 1 * ``info.kind``: BTF_KIND_DECL_TAG * ``info.vlen``: 0 * ``type``: ``struct``, ``union``, ``func``, ``var`` or ``typedef`` h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh encoding requirement:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubj)}(hhh]j)}(hhh](j )}(h*``name_off``: offset to a non-empty stringh]h)}(hj h](j)}(h ``name_off``h]hname_off}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: offset to a non-empty string}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h``info.kind_flag``: 0 or 1h]h)}(hj!h](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hj !hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj!ubh: 0 or 1}(hj!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj!ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h ``info.kind``: BTF_KIND_DECL_TAGh]h)}(hj)!h](j)}(h ``info.kind``h]h info.kind}(hj.!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj+!ubh: BTF_KIND_DECL_TAG}(hj+!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj'!ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(h``info.vlen``: 0h]h)}(hjN!h](j)}(h ``info.vlen``h]h info.vlen}(hjS!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjP!ubh: 0}(hjP!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjL!ubah}(h]h ]h"]h$]h&]uh1j hj ubj )}(hB``type``: ``struct``, ``union``, ``func``, ``var`` or ``typedef`` h]h)}(hA``type``: ``struct``, ``union``, ``func``, ``var`` or ``typedef``h](j)}(h``type``h]htype}(hjy!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubh: }(hju!hhhNhNubj)}(h ``struct``h]hstruct}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubh, }(hju!hhhNhNubj)}(h ``union``h]hunion}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubh, }hju!sbj)}(h``func``h]hfunc}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubh, }hju!sbj)}(h``var``h]hvar}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubh or }(hju!hhhNhNubj)}(h ``typedef``h]htypedef}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhju!ubeh}(h]h ]h"]h$]h&]uh1hhhhMhjq!ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1hhj hhhNhNubh)}(h6``btf_type`` is followed by ``struct btf_decl_tag``.::h](j)}(h ``btf_type``h]hbtf_type}(hj "hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj"ubh is followed by }(hj"hhhNhNubj)}(h``struct btf_decl_tag``h]hstruct btf_decl_tag}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj"ubh.:}(hj"hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(h3struct btf_decl_tag { __u32 component_idx; };h]h3struct btf_decl_tag { __u32 component_idx; };}hj3"sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj hhubh)}(hXThe ``type`` should be ``struct``, ``union``, ``func``, ``var`` or ``typedef``. For ``var`` or ``typedef`` type, ``btf_decl_tag.component_idx`` must be ``-1``. For the other three types, if the btf_decl_tag attribute is applied to the ``struct``, ``union`` or ``func`` itself, ``btf_decl_tag.component_idx`` must be ``-1``. Otherwise, the attribute is applied to a ``struct``/``union`` member or a ``func`` argument, and ``btf_decl_tag.component_idx`` should be a valid index (starting from 0) pointing to a member or an argument.h](hThe }(hjA"hhhNhNubj)}(h``type``h]htype}(hjI"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh should be }(hjA"hhhNhNubj)}(h ``struct``h]hstruct}(hj["hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh, }(hjA"hhhNhNubj)}(h ``union``h]hunion}(hjm"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh, }hjA"sbj)}(h``func``h]hfunc}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh, }hjA"sbj)}(h``var``h]hvar}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh or }(hjA"hhhNhNubj)}(h ``typedef``h]htypedef}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh. For }(hjA"hhhNhNubj)}(h``var``h]hvar}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh or }hjA"sbj)}(h ``typedef``h]htypedef}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh type, }(hjA"hhhNhNubj)}(h``btf_decl_tag.component_idx``h]hbtf_decl_tag.component_idx}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh must be }(hjA"hhhNhNubj)}(h``-1``h]h-1}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubhM. For the other three types, if the btf_decl_tag attribute is applied to the }(hjA"hhhNhNubj)}(h ``struct``h]hstruct}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh, }hjA"sbj)}(h ``union``h]hunion}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh or }hjA"sbj)}(h``func``h]hfunc}(hj!#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh itself, }(hjA"hhhNhNubj)}(h``btf_decl_tag.component_idx``h]hbtf_decl_tag.component_idx}(hj3#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh must be }hjA"sbj)}(h``-1``h]h-1}(hjE#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh+. Otherwise, the attribute is applied to a }(hjA"hhhNhNubj)}(h ``struct``h]hstruct}(hjW#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh/}(hjA"hhhNhNubj)}(h ``union``h]hunion}(hji#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh member or a }(hjA"hhhNhNubj)}(h``func``h]hfunc}(hj{#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubh argument, and }(hjA"hhhNhNubj)}(h``btf_decl_tag.component_idx``h]hbtf_decl_tag.component_idx}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjA"ubhO should be a valid index (starting from 0) pointing to a member or an argument.}(hjA"hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hwIf ``info.kind_flag`` is 0, then this is a normal decl tag, and the ``name_off`` encodes btf_decl_tag attribute string.h](hIf }(hj#hhhNhNubj)}(h``info.kind_flag``h]hinfo.kind_flag}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubh/ is 0, then this is a normal decl tag, and the }(hj#hhhNhNubj)}(h ``name_off``h]hname_off}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubh' encodes btf_decl_tag attribute string.}(hj#hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hXIf ``info.kind_flag`` is 1, then the decl tag represents an arbitrary __attribute__. In this case, ``name_off`` encodes a string representing the attribute-list of the attribute specifier. For example, for an ``__attribute__((aligned(4)))`` the string's contents is ``aligned(4)``.h](hIf }(hj#hhhNhNubj)}(h``info.kind_flag``h]hinfo.kind_flag}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubhN is 1, then the decl tag represents an arbitrary __attribute__. In this case, }(hj#hhhNhNubj)}(h ``name_off``h]hname_off}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubhb encodes a string representing the attribute-list of the attribute specifier. For example, for an }(hj#hhhNhNubj)}(h``__attribute__((aligned(4)))``h]h__attribute__((aligned(4)))}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubh the string’s contents is }(hj#hhhNhNubj)}(h``aligned(4)``h]h aligned(4)}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubh.}(hj#hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]btf-kind-decl-tagah ]h"]2.2.17 btf_kind_decl_tagah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.18 BTF_KIND_TYPE_TAGh]h2.2.18 BTF_KIND_TYPE_TAG}(hj8$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj5$hhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: offset to a non-empty string * ``info.kind_flag``: 0 or 1 * ``info.kind``: BTF_KIND_TYPE_TAG * ``info.vlen``: 0 * ``type``: the type with ``btf_type_tag`` attribute h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hjQ$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjM$ubh encoding requirement:}(hjM$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjI$ubj)}(hhh]j)}(hhh](j )}(h*``name_off``: offset to a non-empty stringh]h)}(hjq$h](j)}(h ``name_off``h]hname_off}(hjv$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjs$ubh: offset to a non-empty string}(hjs$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjo$ubah}(h]h ]h"]h$]h&]uh1j hjl$ubj )}(h``info.kind_flag``: 0 or 1h]h)}(hj$h](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh: 0 or 1}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj$ubah}(h]h ]h"]h$]h&]uh1j hjl$ubj )}(h ``info.kind``: BTF_KIND_TYPE_TAGh]h)}(hj$h](j)}(h ``info.kind``h]h info.kind}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh: BTF_KIND_TYPE_TAG}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj$ubah}(h]h ]h"]h$]h&]uh1j hjl$ubj )}(h``info.vlen``: 0h]h)}(hj$h](j)}(h ``info.vlen``h]h info.vlen}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh: 0}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj$ubah}(h]h ]h"]h$]h&]uh1j hjl$ubj )}(h3``type``: the type with ``btf_type_tag`` attribute h]h)}(h2``type``: the type with ``btf_type_tag`` attributeh](j)}(h``type``h]htype}(hj %hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh: the type with }(hj%hhhNhNubj)}(h``btf_type_tag``h]h btf_type_tag}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh attribute}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj%ubah}(h]h ]h"]h$]h&]uh1j hjl$ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhji$ubah}(h]h ]h"]h$]h&]uh1jhjI$ubeh}(h]h ]h"]h$]h&]uh1hhhhMhjF$ubah}(h]h ]h"]h$]h&]uh1hhj5$hhhNhNubh)}(hkCurrently, ``BTF_KIND_TYPE_TAG`` is only emitted for pointer types. It has the following btf type chain: ::h](h Currently, }(hjS%hhhNhNubj)}(h``BTF_KIND_TYPE_TAG``h]hBTF_KIND_TYPE_TAG}(hj[%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjS%ubhH is only emitted for pointer types. It has the following btf type chain:}(hjS%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hj5$hhubj)}(hSptr -> [type_tag]* -> [const | volatile | restrict | typedef]* -> base_typeh]hSptr -> [type_tag]* -> [const | volatile | restrict | typedef]* -> base_type}hjs%sbah}(h]h ]h"]h$]h&]jjuh1jhhhM hj5$hhubh)}(hBasically, a pointer type points to zero or more type_tag, then zero or more const/volatile/restrict/typedef and finally the base type. The base type is one of int, ptr, array, struct, union, enum, func_proto and float types.h]hBasically, a pointer type points to zero or more type_tag, then zero or more const/volatile/restrict/typedef and finally the base type. The base type is one of int, ptr, array, struct, union, enum, func_proto and float types.}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj5$hhubh)}(hSimilarly to decl tags, if the ``info.kind_flag`` is 0, then this is a normal type tag, and the ``name_off`` encodes btf_type_tag attribute string.h](hSimilarly to decl tags, if the }(hj%hhhNhNubj)}(h``info.kind_flag``h]hinfo.kind_flag}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh/ is 0, then this is a normal type tag, and the }(hj%hhhNhNubj)}(h ``name_off``h]hname_off}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubh' encodes btf_type_tag attribute string.}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj5$hhubh)}(hIf ``info.kind_flag`` is 1, then the type tag represents an arbitrary __attribute__, and the ``name_off`` encodes a string representing the attribute-list of the attribute specifier.h](hIf }(hj%hhhNhNubj)}(h``info.kind_flag``h]hinfo.kind_flag}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubhH is 1, then the type tag represents an arbitrary __attribute__, and the }(hj%hhhNhNubj)}(h ``name_off``h]hname_off}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj%ubhM encodes a string representing the attribute-list of the attribute specifier.}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj5$hhubeh}(h]btf-kind-type-tagah ]h"]2.2.18 btf_kind_type_tagah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h2.2.19 BTF_KIND_ENUM64h]h2.2.19 BTF_KIND_ENUM64}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%hhhhhMubh)}(hhh]h)}(h``struct btf_type`` encoding requirement: * ``name_off``: 0 or offset to a valid C identifier * ``info.kind_flag``: 0 for unsigned, 1 for signed * ``info.kind``: BTF_KIND_ENUM64 * ``info.vlen``: number of enum values * ``size``: 1/2/4/8 h](h)}(h)``struct btf_type`` encoding requirement:h](j)}(h``struct btf_type``h]hstruct btf_type}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj&ubh encoding requirement:}(hj&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM&hj&ubj)}(hhh]j)}(hhh](j )}(h1``name_off``: 0 or offset to a valid C identifierh]h)}(hj7&h](j)}(h ``name_off``h]hname_off}(hj<&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj9&ubh%: 0 or offset to a valid C identifier}(hj9&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM"hj5&ubah}(h]h ]h"]h$]h&]uh1j hj2&ubj )}(h0``info.kind_flag``: 0 for unsigned, 1 for signedh]h)}(hj\&h](j)}(h``info.kind_flag``h]hinfo.kind_flag}(hja&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj^&ubh: 0 for unsigned, 1 for signed}(hj^&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM#hjZ&ubah}(h]h ]h"]h$]h&]uh1j hj2&ubj )}(h``info.kind``: BTF_KIND_ENUM64h]h)}(hj&h](j)}(h ``info.kind``h]h info.kind}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj&ubh: BTF_KIND_ENUM64}(hj&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM$hj&ubah}(h]h ]h"]h$]h&]uh1j hj2&ubj )}(h$``info.vlen``: number of enum valuesh]h)}(hj&h](j)}(h ``info.vlen``h]h info.vlen}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj&ubh: number of enum values}(hj&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM%hj&ubah}(h]h ]h"]h$]h&]uh1j hj2&ubj )}(h``size``: 1/2/4/8 h]h)}(h``size``: 1/2/4/8h](j)}(h``size``h]hsize}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj&ubh : 1/2/4/8}(hj&hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM&hj&ubah}(h]h ]h"]h$]h&]uh1j hj2&ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM"hj/&ubah}(h]h ]h"]h$]h&]uh1jhj&ubeh}(h]h ]h"]h$]h&]uh1hhhhM&hj &ubah}(h]h ]h"]h$]h&]uh1hhj%hhhNhNubh)}(hL``btf_type`` is followed by ``info.vlen`` number of ``struct btf_enum64``.::h](j)}(h ``btf_type``h]hbtf_type}(hj 'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh is followed by }(hj'hhhNhNubj)}(h ``info.vlen``h]h info.vlen}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh number of }(hj'hhhNhNubj)}(h``struct btf_enum64``h]hstruct btf_enum64}(hj/'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh.:}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM(hj%hhubj)}(hXstruct btf_enum64 { __u32 name_off; __u32 val_lo32; __u32 val_hi32; };h]hXstruct btf_enum64 { __u32 name_off; __u32 val_lo32; __u32 val_hi32; };}hjG'sbah}(h]h ]h"]h$]h&]jjuh1jhhhM*hj%hhubh)}(hhh]h)}(hThe ``btf_enum64`` encoding: * ``name_off``: offset to a valid C identifier * ``val_lo32``: lower 32-bit value for a 64-bit value * ``val_hi32``: high 32-bit value for a 64-bit value h](h)}(hThe ``btf_enum64`` encoding:h](hThe }(hj\'hhhNhNubj)}(h``btf_enum64``h]h btf_enum64}(hjd'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj\'ubh encoding:}(hj\'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM3hjX'ubj)}(hhh]j)}(hhh](j )}(h,``name_off``: offset to a valid C identifierh]h)}(hj'h](j)}(h ``name_off``h]hname_off}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh : offset to a valid C identifier}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM1hj'ubah}(h]h ]h"]h$]h&]uh1j hj'ubj )}(h3``val_lo32``: lower 32-bit value for a 64-bit valueh]h)}(hj'h](j)}(h ``val_lo32``h]hval_lo32}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh': lower 32-bit value for a 64-bit value}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM2hj'ubah}(h]h ]h"]h$]h&]uh1j hj'ubj )}(h3``val_hi32``: high 32-bit value for a 64-bit value h]h)}(h2``val_hi32``: high 32-bit value for a 64-bit valueh](j)}(h ``val_hi32``h]hval_hi32}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj'ubh&: high 32-bit value for a 64-bit value}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM3hj'ubah}(h]h ]h"]h$]h&]uh1j hj'ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM1hj|'ubah}(h]h ]h"]h$]h&]uh1jhjX'ubeh}(h]h ]h"]h$]h&]uh1hhhhM3hjU'ubah}(h]h ]h"]h$]h&]uh1hhj%hhhNhNubh)}(hpIf the original enum value is signed and the size is less than 8, that value will be sign extended into 8 bytes.h]hpIf the original enum value is signed and the size is less than 8, that value will be sign extended into 8 bytes.}(hj (hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM5hj%hhubeh}(h]btf-kind-enum64ah ]h"]2.2.19 btf_kind_enum64ah$]h&]uh1hhjhhhhhMubeh}(h] type-encodingah ]h"]2.2 type encodingah$]h&]uh1hhjhhhhhKBubh)}(hhh](h)}(h2.3 Constant Valuesh]h2.3 Constant Values}(hj+(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj((hhhhhM9ubj)}(h#.. _BTF_Function_Linkage_Constants:h]h}(h]h ]h"]h$]h&]jbtf-function-linkage-constantsuh1jhM;hj((hhhhubh)}(hhh](h)}(h&2.3.1 Function Linkage Constant Valuesh]h&2.3.1 Function Linkage Constant Values}(hjG(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjD(hhhhhM>ubhtable)}(hhh](h)}(h$Function Linkage Values and Meaningsh]h$Function Linkage Values and Meanings}(hjZ(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM?hjW(ubhtgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jm(hjj(ubjn()}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jm(hjj(ubjn()}(hhh]h}(h]h ]h"]h$]h&]colwidthKWuh1jm(hjj(ubhthead)}(hhh]hrow)}(hhh](hentry)}(hhh]h)}(hkindh]hkind}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhj(ubah}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh]h)}(hvalueh]hvalue}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhj(ubah}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh]h)}(h descriptionh]h description}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhj(ubah}(h]h ]h"]h$]h&]uh1j(hj(ubeh}(h]h ]h"]h$]h&]uh1j(hj(ubah}(h]h ]h"]h$]h&]uh1j(hjj(ubhtbody)}(hhh](j()}(hhh](j()}(hhh]h)}(h``BTF_FUNC_STATIC``h]j)}(hj(h]hBTF_FUNC_STATIC}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj(ubah}(h]h ]h"]h$]h&]uh1hhhhMDhj(ubah}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh]h)}(h0x0h]h0x0}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhj)ubah}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh]h)}(hHdefinition of subprogram not visible outside containing compilation unith]hHdefinition of subprogram not visible outside containing compilation unit}(hj,)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhj))ubah}(h]h ]h"]h$]h&]uh1j(hj(ubeh}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh](j()}(hhh]h)}(h``BTF_FUNC_GLOBAL``h]j)}(hjN)h]hBTF_FUNC_GLOBAL}(hjP)hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjL)ubah}(h]h ]h"]h$]h&]uh1hhhhMEhjI)ubah}(h]h ]h"]h$]h&]uh1j(hjF)ubj()}(hhh]h)}(h0x1h]h0x1}(hjl)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMEhji)ubah}(h]h ]h"]h$]h&]uh1j(hjF)ubj()}(hhh]h)}(hDdefinition of subprogram visible outside containing compilation unith]hDdefinition of subprogram visible outside containing compilation unit}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMEhj)ubah}(h]h ]h"]h$]h&]uh1j(hjF)ubeh}(h]h ]h"]h$]h&]uh1j(hj(ubj()}(hhh](j()}(hhh]h)}(h``BTF_FUNC_EXTERN``h]j)}(hj)h]hBTF_FUNC_EXTERN}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj)ubah}(h]h ]h"]h$]h&]uh1hhhhMFhj)ubah}(h]h ]h"]h$]h&]uh1j(hj)ubj()}(hhh]h)}(h0x2h]h0x2}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhj)ubah}(h]h ]h"]h$]h&]uh1j(hj)ubj()}(hhh]h)}(hWdeclaration of a subprogram whose definition is outside the containing compilation unith]hWdeclaration of a subprogram whose definition is outside the containing compilation unit}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhj)ubah}(h]h ]h"]h$]h&]uh1j(hj)ubeh}(h]h ]h"]h$]h&]uh1j(hj(ubeh}(h]h ]h"]h$]h&]uh1j(hjj(ubeh}(h]h ]h"]h$]h&]colsKuh1jh(hjW(ubeh}(h]id3ah ]h"]h$]h&]uh1jU(hjD(hhhhhNubj)}(h.. _BTF_Var_Linkage_Constants:h]h}(h]h ]h"]h$]h&]jbtf-var-linkage-constantsuh1jhMJhjD(hhhhubeh}(h]( function-linkage-constant-valuesjC(eh ]h"](&2.3.1 function linkage constant valuesbtf_function_linkage_constantseh$]h&]uh1hhj((hhhhhM>expect_referenced_by_name}j*j9(sexpect_referenced_by_id}jC(j9(subh)}(hhh](h)}(h&2.3.2 Variable Linkage Constant Valuesh]h&2.3.2 Variable Linkage Constant Values}(hj#*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj *hhhhhMMubjV()}(hhh](h)}(h$Variable Linkage Values and Meaningsh]h$Variable Linkage Values and Meanings}(hj4*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhj1*ubji()}(hhh](jn()}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jm(hjB*ubjn()}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jm(hjB*ubjn()}(hhh]h}(h]h ]h"]h$]h&]colwidthKZuh1jm(hjB*ubj()}(hhh]j()}(hhh](j()}(hhh]h)}(hkindh]hkind}(hjl*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhji*ubah}(h]h ]h"]h$]h&]uh1j(hjf*ubj()}(hhh]h)}(hvalueh]hvalue}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhj*ubah}(h]h ]h"]h$]h&]uh1j(hjf*ubj()}(hhh]h)}(h descriptionh]h description}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhj*ubah}(h]h ]h"]h$]h&]uh1j(hjf*ubeh}(h]h ]h"]h$]h&]uh1j(hjc*ubah}(h]h ]h"]h$]h&]uh1j(hjB*ubj()}(hhh](j()}(hhh](j()}(hhh]h)}(h``BTF_VAR_STATIC``h]j)}(hj*h]hBTF_VAR_STATIC}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj*ubah}(h]h ]h"]h$]h&]uh1hhhhMShj*ubah}(h]h ]h"]h$]h&]uh1j(hj*ubj()}(hhh]h)}(h0x0h]h0x0}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShj*ubah}(h]h ]h"]h$]h&]uh1j(hj*ubj()}(hhh]h)}(hMdefinition of global variable not visible outside containing compilation unith]hMdefinition of global variable not visible outside containing compilation unit}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShj*ubah}(h]h ]h"]h$]h&]uh1j(hj*ubeh}(h]h ]h"]h$]h&]uh1j(hj*ubj()}(hhh](j()}(hhh]h)}(h``BTF_VAR_GLOBAL_ALLOCATED``h]j)}(hj+h]hBTF_VAR_GLOBAL_ALLOCATED}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj+ubah}(h]h ]h"]h$]h&]uh1hhhhMThj+ubah}(h]h ]h"]h$]h&]uh1j(hj+ubj()}(hhh]h)}(h0x1h]h0x1}(hj:+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMThj7+ubah}(h]h ]h"]h$]h&]uh1j(hj+ubj()}(hhh]h)}(hIdefinition of global variable visible outside containing compilation unith]hIdefinition of global variable visible outside containing compilation unit}(hjQ+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMThjN+ubah}(h]h ]h"]h$]h&]uh1j(hj+ubeh}(h]h ]h"]h$]h&]uh1j(hj*ubj()}(hhh](j()}(hhh]h)}(h``BTF_VAR_GLOBAL_EXTERN``h]j)}(hjs+h]hBTF_VAR_GLOBAL_EXTERN}(hju+hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjq+ubah}(h]h ]h"]h$]h&]uh1hhhhMUhjn+ubah}(h]h ]h"]h$]h&]uh1j(hjk+ubj()}(hhh]h)}(h0x2h]h0x2}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMUhj+ubah}(h]h ]h"]h$]h&]uh1j(hjk+ubj()}(hhh]h)}(hZdeclaration of global variable whose definition is outside the containing compilation unith]hZdeclaration of global variable whose definition is outside the containing compilation unit}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMUhj+ubah}(h]h ]h"]h$]h&]uh1j(hjk+ubeh}(h]h ]h"]h$]h&]uh1j(hj*ubeh}(h]h ]h"]h$]h&]uh1j(hjB*ubeh}(h]h ]h"]h$]h&]colsKuh1jh(hj1*ubeh}(h]id4ah ]h"]h$]h&]uh1jU(hj *hhhhhNubeh}(h]( variable-linkage-constant-valuesj*eh ]h"](&2.3.2 variable linkage constant valuesbtf_var_linkage_constantseh$]h&]uh1hhj((hhhhhMMj*}j+j*sj*}j*j*subeh}(h]constant-valuesah ]h"]2.3 constant valuesah$]h&]uh1hhjhhhhhM9ubeh}(h](btf-type-and-string-encodingjeh ]h"](2. btf type and string encodingbtf_type_stringeh$]h&]uh1hhhhhhhhK!j*}j+jsj*}jjsubh)}(hhh](h)}(h3. BTF Kernel APIh]h3. BTF Kernel API}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj+hhhhhMYubh)}(hhh]h)}(hXeThe following bpf syscall command involves BTF: * BPF_BTF_LOAD: load a blob of BTF data into kernel * BPF_MAP_CREATE: map creation with btf key and value type info. * BPF_PROG_LOAD: prog load with btf function and line info. * BPF_BTF_GET_FD_BY_ID: get a btf fd * BPF_OBJ_GET_INFO_BY_FD: btf, func_info, line_info and other btf related info are returned. h](h)}(h/The following bpf syscall command involves BTF:h]h/The following bpf syscall command involves BTF:}(hj ,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMahj,ubj)}(hhh]j)}(hhh](j )}(h1BPF_BTF_LOAD: load a blob of BTF data into kernelh]h)}(hj",h]h1BPF_BTF_LOAD: load a blob of BTF data into kernel}(hj$,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hj ,ubah}(h]h ]h"]h$]h&]uh1j hj,ubj )}(h>BPF_MAP_CREATE: map creation with btf key and value type info.h]h)}(hj9,h]h>BPF_MAP_CREATE: map creation with btf key and value type info.}(hj;,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM]hj7,ubah}(h]h ]h"]h$]h&]uh1j hj,ubj )}(h9BPF_PROG_LOAD: prog load with btf function and line info.h]h)}(hjP,h]h9BPF_PROG_LOAD: prog load with btf function and line info.}(hjR,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM^hjN,ubah}(h]h ]h"]h$]h&]uh1j hj,ubj )}(h"BPF_BTF_GET_FD_BY_ID: get a btf fdh]h)}(hjg,h]h"BPF_BTF_GET_FD_BY_ID: get a btf fd}(hji,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM_hje,ubah}(h]h ]h"]h$]h&]uh1j hj,ubj )}(h[BPF_OBJ_GET_INFO_BY_FD: btf, func_info, line_info and other btf related info are returned. h]h)}(hZBPF_OBJ_GET_INFO_BY_FD: btf, func_info, line_info and other btf related info are returned.h]hZBPF_OBJ_GET_INFO_BY_FD: btf, func_info, line_info and other btf related info are returned.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM`hj|,ubah}(h]h ]h"]h$]h&]uh1j hj,ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhM\hj,ubah}(h]h ]h"]h$]h&]uh1jhj,ubeh}(h]h ]h"]h$]h&]uh1hhhhMahj,ubah}(h]h ]h"]h$]h&]uh1hhj+hhhNhNubh)}(h%The workflow typically looks like: ::h]h"The workflow typically looks like:}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchj+hhubj)}(hX-Application: BPF_BTF_LOAD | v BPF_MAP_CREATE and BPF_PROG_LOAD | V ...... Introspection tool: ...... BPF_{PROG,MAP}_GET_NEXT_ID (get prog/map id's) | V BPF_{PROG,MAP}_GET_FD_BY_ID (get a prog/map fd) | V BPF_OBJ_GET_INFO_BY_FD (get bpf_prog_info/bpf_map_info with btf_id) | | V | BPF_BTF_GET_FD_BY_ID (get btf_fd) | | | V | BPF_OBJ_GET_INFO_BY_FD (get btf) | | | V V pretty print types, dump func signatures and line info, etc.h]hX-Application: BPF_BTF_LOAD | v BPF_MAP_CREATE and BPF_PROG_LOAD | V ...... Introspection tool: ...... BPF_{PROG,MAP}_GET_NEXT_ID (get prog/map id's) | V BPF_{PROG,MAP}_GET_FD_BY_ID (get a prog/map fd) | V BPF_OBJ_GET_INFO_BY_FD (get bpf_prog_info/bpf_map_info with btf_id) | | V | BPF_BTF_GET_FD_BY_ID (get btf_fd) | | | V | BPF_OBJ_GET_INFO_BY_FD (get btf) | | | V V pretty print types, dump func signatures and line info, etc.}hj,sbah}(h]h ]h"]h$]h&]jjuh1jhhhMfhj+hhubh)}(hhh](h)}(h3.1 BPF_BTF_LOADh]h3.1 BPF_BTF_LOAD}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj,hhhhhMubh)}(hLoad a blob of BTF data into kernel. A blob of data, described in :ref:`BTF_Type_String`, can be directly loaded into the kernel. A ``btf_fd`` is returned to a userspace.h](hBLoad a blob of BTF data into kernel. A blob of data, described in }(hj,hhhNhNubh)}(h:ref:`BTF_Type_String`h]jq)}(hj,h]hBTF_Type_String}(hj,hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphj,ubah}(h]h ]h"]h$]h&]refdocj refdomainj,reftyperef refexplicitrefwarnjbtf_type_stringuh1hhhhMhj,ubh,, can be directly loaded into the kernel. A }(hj,hhhNhNubj)}(h ``btf_fd``h]hbtf_fd}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj,ubh is returned to a userspace.}(hj,hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj,hhubeh}(h] bpf-btf-loadah ]h"]3.1 bpf_btf_loadah$]h&]uh1hhj+hhhhhMubh)}(hhh](h)}(h3.2 BPF_MAP_CREATEh]h3.2 BPF_MAP_CREATE}(hj(-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%-hhhhhMubh)}(hGA map can be created with ``btf_fd`` and specified key/value type id.::h](hA map can be created with }(hj6-hhhNhNubj)}(h ``btf_fd``h]hbtf_fd}(hj>-hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj6-ubh" and specified key/value type id.:}(hj6-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj%-hhubj)}(h__u32 btf_fd; /* fd pointing to a BTF type data */ __u32 btf_key_type_id; /* BTF type_id of the key */ __u32 btf_value_type_id; /* BTF type_id of the value */h]h__u32 btf_fd; /* fd pointing to a BTF type data */ __u32 btf_key_type_id; /* BTF type_id of the key */ __u32 btf_value_type_id; /* BTF type_id of the value */}hjV-sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj%-hhubh)}(hFIn libbpf, the map can be defined with extra annotation like below: ::h]hCIn libbpf, the map can be defined with extra annotation like below:}(hjd-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj%-hhubj)}(hstruct { __uint(type, BPF_MAP_TYPE_ARRAY); __type(key, int); __type(value, struct ipv_counts); __uint(max_entries, 4); } btf_map SEC(".maps");h]hstruct { __uint(type, BPF_MAP_TYPE_ARRAY); __type(key, int); __type(value, struct ipv_counts); __uint(max_entries, 4); } btf_map SEC(".maps");}hjr-sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj%-hhubh)}(h}During ELF parsing, libbpf is able to extract key/value type_id's and assign them to BPF_MAP_CREATE attributes automatically.h]hDuring ELF parsing, libbpf is able to extract key/value type_id’s and assign them to BPF_MAP_CREATE attributes automatically.}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj%-hhubj)}(h.. _BPF_Prog_Load:h]h}(h]h ]h"]h$]h&]j bpf-prog-loaduh1jhMhj%-hhhhubeh}(h]bpf-map-createah ]h"]3.2 bpf_map_createah$]h&]uh1hhj+hhhhhMubh)}(hhh](h)}(h3.3 BPF_PROG_LOADh]h3.3 BPF_PROG_LOAD}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj-hhhhhMubh)}(huDuring prog_load, func_info and line_info can be passed to kernel with proper values for the following attributes: ::h]hrDuring prog_load, func_info and line_info can be passed to kernel with proper values for the following attributes:}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubj)}(hX__u32 insn_cnt; __aligned_u64 insns; ...... __u32 prog_btf_fd; /* fd pointing to BTF type data */ __u32 func_info_rec_size; /* userspace bpf_func_info size */ __aligned_u64 func_info; /* func info */ __u32 func_info_cnt; /* number of bpf_func_info records */ __u32 line_info_rec_size; /* userspace bpf_line_info size */ __aligned_u64 line_info; /* line info */ __u32 line_info_cnt; /* number of bpf_line_info records */h]hX__u32 insn_cnt; __aligned_u64 insns; ...... __u32 prog_btf_fd; /* fd pointing to BTF type data */ __u32 func_info_rec_size; /* userspace bpf_func_info size */ __aligned_u64 func_info; /* func info */ __u32 func_info_cnt; /* number of bpf_func_info records */ __u32 line_info_rec_size; /* userspace bpf_line_info size */ __aligned_u64 line_info; /* line info */ __u32 line_info_cnt; /* number of bpf_line_info records */}hj-sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj-hhubh)}(hBThe func_info and line_info are an array of below, respectively.::h]hAThe func_info and line_info are an array of below, respectively.:}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubj)}(hXstruct bpf_func_info { __u32 insn_off; /* [0, insn_cnt - 1] */ __u32 type_id; /* pointing to a BTF_KIND_FUNC type */ }; struct bpf_line_info { __u32 insn_off; /* [0, insn_cnt - 1] */ __u32 file_name_off; /* offset to string table for the filename */ __u32 line_off; /* offset to string table for the source line */ __u32 line_col; /* line number and column number */ };h]hXstruct bpf_func_info { __u32 insn_off; /* [0, insn_cnt - 1] */ __u32 type_id; /* pointing to a BTF_KIND_FUNC type */ }; struct bpf_line_info { __u32 insn_off; /* [0, insn_cnt - 1] */ __u32 file_name_off; /* offset to string table for the filename */ __u32 line_off; /* offset to string table for the source line */ __u32 line_col; /* line number and column number */ };}hj-sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj-hhubh)}(hfunc_info_rec_size is the size of each func_info record, and line_info_rec_size is the size of each line_info record. Passing the record size to kernel make it possible to extend the record itself in the future.h]hfunc_info_rec_size is the size of each func_info record, and line_info_rec_size is the size of each line_info record. Passing the record size to kernel make it possible to extend the record itself in the future.}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubh)}(hhh](h)}(hBelow are requirements for func_info: * func_info[0].insn_off must be 0. * the func_info insn_off is in strictly increasing order and matches bpf func boundaries. h](h)}(h%Below are requirements for func_info:h]h%Below are requirements for func_info:}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-ubj)}(hhh]j)}(hhh](j )}(h func_info[0].insn_off must be 0.h]h)}(hj.h]h func_info[0].insn_off must be 0.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj.ubah}(h]h ]h"]h$]h&]uh1j hj.ubj )}(hXthe func_info insn_off is in strictly increasing order and matches bpf func boundaries. h]h)}(hWthe func_info insn_off is in strictly increasing order and matches bpf func boundaries.h]hWthe func_info insn_off is in strictly increasing order and matches bpf func boundaries.}(hj..hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj*.ubah}(h]h ]h"]h$]h&]uh1j hj.ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhj .ubah}(h]h ]h"]h$]h&]uh1jhj-ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-ubh)}(hBelow are requirements for line_info: * the first insn in each func must have a line_info record pointing to it. * the line_info insn_off is in strictly increasing order. h](h)}(h%Below are requirements for line_info:h]h%Below are requirements for line_info:}(hjX.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjT.ubj)}(hhh]j)}(hhh](j )}(hHthe first insn in each func must have a line_info record pointing to it.h]h)}(hjn.h]hHthe first insn in each func must have a line_info record pointing to it.}(hjp.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjl.ubah}(h]h ]h"]h$]h&]uh1j hji.ubj )}(h8the line_info insn_off is in strictly increasing order. h]h)}(h7the line_info insn_off is in strictly increasing order.h]h7the line_info insn_off is in strictly increasing order.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj.ubah}(h]h ]h"]h$]h&]uh1j hji.ubeh}(h]h ]h"]h$]h&]jBjCuh1jhhhMhjf.ubah}(h]h ]h"]h$]h&]uh1jhjT.ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubeh}(h]h ]h"]h$]h&]uh1hhj-hhhNhNubh)}(hIFor line_info, the line number and column number are defined as below: ::h]hFFor line_info, the line number and column number are defined as below:}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubj)}(h#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10) #define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)h]h#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10) #define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)}hj.sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj-hhubeh}(h](j-id1eh ]h"](3.3 bpf_prog_load bpf_prog_loadeh$]h&]uh1hhj+hhhhhMj*}j.j-sj*}j-j-subh)}(hhh](h)}(h3.4 BPF_{PROG,MAP}_GET_NEXT_IDh]h3.4 BPF_{PROG,MAP}_GET_NEXT_ID}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj.hhhhhMubh)}(hIn kernel, every loaded program, map or btf has a unique id. The id won't change during the lifetime of a program, map, or btf.h]hIn kernel, every loaded program, map or btf has a unique id. The id won’t change during the lifetime of a program, map, or btf.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj.hhubh)}(hThe bpf syscall command BPF_{PROG,MAP}_GET_NEXT_ID returns all id's, one for each command, to user space, for bpf program or maps, respectively, so an inspection tool can inspect all programs and maps.h]hThe bpf syscall command BPF_{PROG,MAP}_GET_NEXT_ID returns all id’s, one for each command, to user space, for bpf program or maps, respectively, so an inspection tool can inspect all programs and maps.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj.hhubeh}(h]bpf-prog-map-get-next-idah ]h"]3.4 bpf_{prog,map}_get_next_idah$]h&]uh1hhj+hhhhhMubh)}(hhh](h)}(h3.5 BPF_{PROG,MAP}_GET_FD_BY_IDh]h3.5 BPF_{PROG,MAP}_GET_FD_BY_ID}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj/hhhhhMubh)}(hAn introspection tool cannot use id to get details about program or maps. A file descriptor needs to be obtained first for reference-counting purpose.h]hAn introspection tool cannot use id to get details about program or maps. A file descriptor needs to be obtained first for reference-counting purpose.}(hj /hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubeh}(h]bpf-prog-map-get-fd-by-idah ]h"]3.5 bpf_{prog,map}_get_fd_by_idah$]h&]uh1hhj+hhhhhMubh)}(hhh](h)}(h3.6 BPF_OBJ_GET_INFO_BY_FDh]h3.6 BPF_OBJ_GET_INFO_BY_FD}(hj9/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6/hhhhhMubh)}(hXOOnce a program/map fd is acquired, an introspection tool can get the detailed information from kernel about this fd, some of which are BTF-related. For example, ``bpf_map_info`` returns ``btf_id`` and key/value type ids. ``bpf_prog_info`` returns ``btf_id``, func_info, and line info for translated bpf byte codes, and jited_line_info.h](hOnce a program/map fd is acquired, an introspection tool can get the detailed information from kernel about this fd, some of which are BTF-related. For example, }(hjG/hhhNhNubj)}(h``bpf_map_info``h]h bpf_map_info}(hjO/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjG/ubh returns }(hjG/hhhNhNubj)}(h ``btf_id``h]hbtf_id}(hja/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjG/ubh and key/value type ids. }(hjG/hhhNhNubj)}(h``bpf_prog_info``h]h bpf_prog_info}(hjs/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjG/ubh returns }hjG/sbj)}(h ``btf_id``h]hbtf_id}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjG/ubhN, func_info, and line info for translated bpf byte codes, and jited_line_info.}(hjG/hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj6/hhubeh}(h]bpf-obj-get-info-by-fdah ]h"]3.6 bpf_obj_get_info_by_fdah$]h&]uh1hhj+hhhhhMubh)}(hhh](h)}(h3.7 BPF_BTF_GET_FD_BY_IDh]h3.7 BPF_BTF_GET_FD_BY_ID}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj/hhhhhMubh)}(hXWith ``btf_id`` obtained in ``bpf_map_info`` and ``bpf_prog_info``, bpf syscall command BPF_BTF_GET_FD_BY_ID can retrieve a btf fd. Then, with command BPF_OBJ_GET_INFO_BY_FD, the btf blob, originally loaded into the kernel with BPF_BTF_LOAD, can be retrieved.h](hWith }(hj/hhhNhNubj)}(h ``btf_id``h]hbtf_id}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj/ubh obtained in }(hj/hhhNhNubj)}(h``bpf_map_info``h]h bpf_map_info}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj/ubh and }(hj/hhhNhNubj)}(h``bpf_prog_info``h]h bpf_prog_info}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj/ubh, bpf syscall command BPF_BTF_GET_FD_BY_ID can retrieve a btf fd. Then, with command BPF_OBJ_GET_INFO_BY_FD, the btf blob, originally loaded into the kernel with BPF_BTF_LOAD, can be retrieved.}(hj/hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(hWith the btf blob, ``bpf_map_info``, and ``bpf_prog_info``, an introspection tool has full btf knowledge and is able to pretty print map key/values, dump func signatures and line info, along with byte/jit codes.h](hWith the btf blob, }(hj/hhhNhNubj)}(h``bpf_map_info``h]h bpf_map_info}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj/ubh, and }(hj/hhhNhNubj)}(h``bpf_prog_info``h]h bpf_prog_info}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj/ubh, an introspection tool has full btf knowledge and is able to pretty print map key/values, dump func signatures and line info, along with byte/jit codes.}(hj/hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubeh}(h]bpf-btf-get-fd-by-idah ]h"]3.7 bpf_btf_get_fd_by_idah$]h&]uh1hhj+hhhhhMubeh}(h]btf-kernel-apiah ]h"]3. btf kernel apiah$]h&]uh1hhhhhhhhMYubh)}(hhh](h)}(h4. ELF File Format Interfaceh]h4. ELF File Format Interface}(hj?0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj<0hhhhhMubh)}(hhh](h)}(h4.1 .BTF sectionh]h4.1 .BTF section}(hjP0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjM0hhhhhMubh)}(hThe .BTF section contains type and string data. The format of this section is same as the one describe in :ref:`BTF_Type_String`.h](hjThe .BTF section contains type and string data. The format of this section is same as the one describe in }(hj^0hhhNhNubh)}(h:ref:`BTF_Type_String`h]jq)}(hjh0h]hBTF_Type_String}(hjj0hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphjf0ubah}(h]h ]h"]h$]h&]refdocj refdomainjt0reftyperef refexplicitrefwarnjbtf_type_stringuh1hhhhMhj^0ubh.}(hj^0hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjM0hhubj)}(h.. _BTF_Ext_Section:h]h}(h]h ]h"]h$]h&]jbtf-ext-sectionuh1jhMhjM0hhhhubeh}(h] btf-sectionah ]h"]4.1 .btf sectionah$]h&]uh1hhj<0hhhhhMubh)}(hhh](h)}(h4.2 .BTF.ext sectionh]h4.2 .BTF.ext section}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj0hhhhhMubh)}(hThe .BTF.ext section encodes func_info, line_info and CO-RE relocations which needs loader manipulation before loading into the kernel.h]hThe .BTF.ext section encodes func_info, line_info and CO-RE relocations which needs loader manipulation before loading into the kernel.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj0hhubh)}(hiThe specification for .BTF.ext section is defined at ``tools/lib/bpf/btf.h`` and ``tools/lib/bpf/btf.c``.h](h5The specification for .BTF.ext section is defined at }(hj0hhhNhNubj)}(h``tools/lib/bpf/btf.h``h]htools/lib/bpf/btf.h}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh and }(hj0hhhNhNubj)}(h``tools/lib/bpf/btf.c``h]htools/lib/bpf/btf.c}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0ubh.}(hj0hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hj0hhubh)}(h(The current header of .BTF.ext section::h]h'The current header of .BTF.ext section:}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj0hhubj)}(hXstruct btf_ext_header { __u16 magic; __u8 version; __u8 flags; __u32 hdr_len; /* All offsets are in bytes relative to the end of this header */ __u32 func_info_off; __u32 func_info_len; __u32 line_info_off; __u32 line_info_len; /* optional part of .BTF.ext header */ __u32 core_relo_off; __u32 core_relo_len; };h]hXstruct btf_ext_header { __u16 magic; __u8 version; __u8 flags; __u32 hdr_len; /* All offsets are in bytes relative to the end of this header */ __u32 func_info_off; __u32 func_info_len; __u32 line_info_off; __u32 line_info_len; /* optional part of .BTF.ext header */ __u32 core_relo_off; __u32 core_relo_len; };}hj1sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj0hhubh)}(hIt is very similar to .BTF section. Instead of type/string section, it contains func_info, line_info and core_relo sub-sections. See :ref:`BPF_Prog_Load` for details about func_info and line_info record format.h](hIt is very similar to .BTF section. Instead of type/string section, it contains func_info, line_info and core_relo sub-sections. See }(hj1hhhNhNubh)}(h:ref:`BPF_Prog_Load`h]jq)}(hj1h]h BPF_Prog_Load}(hj1hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphj1ubah}(h]h ]h"]h$]h&]refdocj refdomainj&1reftyperef refexplicitrefwarnj bpf_prog_loaduh1hhhhM hj1ubh9 for details about func_info and line_info record format.}(hj1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hj0hhubh)}(h&The func_info is organized as below.::h]h%The func_info is organized as below.:}(hjB1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hj0hhubj)}(hfunc_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* func_info for section #1 */ btf_ext_info_sec for section #2 /* func_info for section #2 */ ...h]hfunc_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* func_info for section #1 */ btf_ext_info_sec for section #2 /* func_info for section #2 */ ...}hjP1sbah}(h]h ]h"]h$]h&]jjuh1jhhhM'hj0hhubh)}(h``func_info_rec_size`` specifies the size of ``bpf_func_info`` structure when .BTF.ext is generated. ``btf_ext_info_sec``, defined below, is a collection of func_info for each specific ELF section.::h](j)}(h``func_info_rec_size``h]hfunc_info_rec_size}(hjb1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj^1ubh specifies the size of }(hj^1hhhNhNubj)}(h``bpf_func_info``h]h bpf_func_info}(hjt1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj^1ubh' structure when .BTF.ext is generated. }(hj^1hhhNhNubj)}(h``btf_ext_info_sec``h]hbtf_ext_info_sec}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj^1ubhM, defined below, is a collection of func_info for each specific ELF section.:}(hj^1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM,hj0hhubj)}(hstruct btf_ext_info_sec { __u32 sec_name_off; /* offset to section name */ __u32 num_info; /* Followed by num_info * record_size number of bytes */ __u8 data[0]; };h]hstruct btf_ext_info_sec { __u32 sec_name_off; /* offset to section name */ __u32 num_info; /* Followed by num_info * record_size number of bytes */ __u8 data[0]; };}hj1sbah}(h]h ]h"]h$]h&]jjuh1jhhhM0hj0hhubh)}(h&Here, num_info must be greater than 0.h]h&Here, num_info must be greater than 0.}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hj0hhubh)}(h&The line_info is organized as below.::h]h%The line_info is organized as below.:}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hj0hhubj)}(hline_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* line_info for section #1 */ btf_ext_info_sec for section #2 /* line_info for section #2 */ ...h]hline_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* line_info for section #1 */ btf_ext_info_sec for section #2 /* line_info for section #2 */ ...}hj1sbah}(h]h ]h"]h$]h&]jjuh1jhhhM;hj0hhubh)}(hd``line_info_rec_size`` specifies the size of ``bpf_line_info`` structure when .BTF.ext is generated.h](j)}(h``line_info_rec_size``h]hline_info_rec_size}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj1ubh specifies the size of }(hj1hhhNhNubj)}(h``bpf_line_info``h]h bpf_line_info}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj1ubh& structure when .BTF.ext is generated.}(hj1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM@hj0hhubh)}(hXRThe interpretation of ``bpf_func_info->insn_off`` and ``bpf_line_info->insn_off`` is different between kernel API and ELF API. For kernel API, the ``insn_off`` is the instruction offset in the unit of ``struct bpf_insn``. For ELF API, the ``insn_off`` is the byte offset from the beginning of section (``btf_ext_info_sec->sec_name_off``).h](hThe interpretation of }(hj2hhhNhNubj)}(h``bpf_func_info->insn_off``h]hbpf_func_info->insn_off}(hj 2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh and }(hj2hhhNhNubj)}(h``bpf_line_info->insn_off``h]hbpf_line_info->insn_off}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubhB is different between kernel API and ELF API. For kernel API, the }(hj2hhhNhNubj)}(h ``insn_off``h]hinsn_off}(hj02hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh* is the instruction offset in the unit of }(hj2hhhNhNubj)}(h``struct bpf_insn``h]hstruct bpf_insn}(hjB2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh. For ELF API, the }(hj2hhhNhNubj)}(h ``insn_off``h]hinsn_off}(hjT2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh3 is the byte offset from the beginning of section (}(hj2hhhNhNubj)}(h"``btf_ext_info_sec->sec_name_off``h]hbtf_ext_info_sec->sec_name_off}(hjf2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh).}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMChj0hhubh)}(h&The core_relo is organized as below.::h]h%The core_relo is organized as below.:}(hj~2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMIhj0hhubj)}(hcore_relo_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* core_relo for section #1 */ btf_ext_info_sec for section #2 /* core_relo for section #2 */h]hcore_relo_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* core_relo for section #1 */ btf_ext_info_sec for section #2 /* core_relo for section #2 */}hj2sbah}(h]h ]h"]h$]h&]jjuh1jhhhMKhj0hhubh)}(h``core_relo_rec_size`` specifies the size of ``bpf_core_relo`` structure when .BTF.ext is generated. All ``bpf_core_relo`` structures within a single ``btf_ext_info_sec`` describe relocations applied to section named by ``btf_ext_info_sec->sec_name_off``.h](j)}(h``core_relo_rec_size``h]hcore_relo_rec_size}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh specifies the size of }(hj2hhhNhNubj)}(h``bpf_core_relo``h]h bpf_core_relo}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh+ structure when .BTF.ext is generated. All }(hj2hhhNhNubj)}(h``bpf_core_relo``h]h bpf_core_relo}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh structures within a single }(hj2hhhNhNubj)}(h``btf_ext_info_sec``h]hbtf_ext_info_sec}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh2 describe relocations applied to section named by }(hj2hhhNhNubj)}(h"``btf_ext_info_sec->sec_name_off``h]hbtf_ext_info_sec->sec_name_off}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh.}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMOhj0hhubh)}(hnSee :ref:`Documentation/bpf/llvm_reloc.rst ` for more information on CO-RE relocations.h](hSee }(hj2hhhNhNubh)}(h?:ref:`Documentation/bpf/llvm_reloc.rst `h]jq)}(hj3h]h Documentation/bpf/llvm_reloc.rst}(hj 3hhhNhNubah}(h]h ](j|stdstd-refeh"]h$]h&]uh1jphj3ubah}(h]h ]h"]h$]h&]refdocj refdomainj3reftyperef refexplicitrefwarnjbtf-co-re-relocationsuh1hhhhMThj2ubh+ for more information on CO-RE relocations.}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMThj0hhubeh}(h](j0id2eh ]h"](4.2 .btf.ext sectionbtf_ext_sectioneh$]h&]uh1hhj<0hhhhhMj*}j63j0sj*}j0j0subh)}(hhh](h)}(h4.3 .BTF_ids sectionh]h4.3 .BTF_ids section}(hj>3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj;3hhhhhMXubh)}(hKThe .BTF_ids section encodes BTF ID values that are used within the kernel.h]hKThe .BTF_ids section encodes BTF ID values that are used within the kernel.}(hjL3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhj;3hhubh)}(hThis section is created during the kernel compilation with the help of macros defined in ``include/linux/btf_ids.h`` header file. Kernel code can use them to create lists and sets (sorted lists) of BTF ID values.h](hYThis section is created during the kernel compilation with the help of macros defined in }(hjZ3hhhNhNubj)}(h``include/linux/btf_ids.h``h]hinclude/linux/btf_ids.h}(hjb3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjZ3ubh` header file. Kernel code can use them to create lists and sets (sorted lists) of BTF ID values.}(hjZ3hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hj;3hhubh)}(hhThe ``BTF_ID_LIST`` and ``BTF_ID`` macros define unsorted list of BTF ID values, with following syntax::h](hThe }(hjz3hhhNhNubj)}(h``BTF_ID_LIST``h]h BTF_ID_LIST}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjz3ubh and }(hjz3hhhNhNubj)}(h ``BTF_ID``h]hBTF_ID}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjz3ubhE macros define unsorted list of BTF ID values, with following syntax:}(hjz3hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM`hj;3hhubj)}(h;BTF_ID_LIST(list) BTF_ID(type1, name1) BTF_ID(type2, name2)h]h;BTF_ID_LIST(list) BTF_ID(type1, name1) BTF_ID(type2, name2)}hj3sbah}(h]h ]h"]h$]h&]jjuh1jhhhMchj;3hhubh)}(h3resulting in following layout in .BTF_ids section::h]h2resulting in following layout in .BTF_ids section:}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghj;3hhubj)}(hE__BTF_ID__type1__name1__1: .zero 4 __BTF_ID__type2__name2__2: .zero 4h]hE__BTF_ID__type1__name1__1: .zero 4 __BTF_ID__type2__name2__2: .zero 4}hj3sbah}(h]h ]h"]h$]h&]jjuh1jhhhMihj;3hhubh)}(h;The ``u32 list[];`` variable is defined to access the list.h](hThe }(hj3hhhNhNubj)}(h``u32 list[];``h]h u32 list[];}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj3ubh( variable is defined to access the list.}(hj3hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMnhj;3hhubh)}(hvThe ``BTF_ID_UNUSED`` macro defines 4 zero bytes. It's used when we want to define unused entry in BTF_ID_LIST, like::h](hThe }(hj3hhhNhNubj)}(h``BTF_ID_UNUSED``h]h BTF_ID_UNUSED}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj3ubhb macro defines 4 zero bytes. It’s used when we want to define unused entry in BTF_ID_LIST, like:}(hj3hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMphj;3hhubj)}(heBTF_ID_LIST(bpf_skb_output_btf_ids) BTF_ID(struct, sk_buff) BTF_ID_UNUSED BTF_ID(struct, task_struct)h]heBTF_ID_LIST(bpf_skb_output_btf_ids) BTF_ID(struct, sk_buff) BTF_ID_UNUSED BTF_ID(struct, task_struct)}hj4sbah}(h]h ]h"]h$]h&]jjuh1jhhhMshj;3hhubh)}(hsThe ``BTF_SET_START/END`` macros pair defines sorted list of BTF ID values and their count, with following syntax::h](hThe }(hj$4hhhNhNubj)}(h``BTF_SET_START/END``h]hBTF_SET_START/END}(hj,4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$4ubhY macros pair defines sorted list of BTF ID values and their count, with following syntax:}(hj$4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMxhj;3hhubj)}(hMBTF_SET_START(set) BTF_ID(type1, name1) BTF_ID(type2, name2) BTF_SET_END(set)h]hMBTF_SET_START(set) BTF_ID(type1, name1) BTF_ID(type2, name2) BTF_SET_END(set)}hjD4sbah}(h]h ]h"]h$]h&]jjuh1jhhhM{hj;3hhubh)}(h3resulting in following layout in .BTF_ids section::h]h2resulting in following layout in .BTF_ids section:}(hjR4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj;3hhubj)}(ha__BTF_ID__set__set: .zero 4 __BTF_ID__type1__name1__3: .zero 4 __BTF_ID__type2__name2__4: .zero 4h]ha__BTF_ID__set__set: .zero 4 __BTF_ID__type1__name1__3: .zero 4 __BTF_ID__type2__name2__4: .zero 4}hj`4sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj;3hhubh)}(hFThe ``struct btf_id_set set;`` variable is defined to access the list.h](hThe }(hjn4hhhNhNubj)}(h``struct btf_id_set set;``h]hstruct btf_id_set set;}(hjv4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjn4ubh( variable is defined to access the list.}(hjn4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj;3hhubh)}(h,The ``typeX`` name can be one of following::h](hThe }(hj4hhhNhNubj)}(h ``typeX``h]htypeX}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj4ubh name can be one of following:}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj;3hhubj)}(hstruct, union, typedef, funch]hstruct, union, typedef, func}hj4sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj;3hhubh)}(h8and is used as a filter when resolving the BTF ID value.h]h8and is used as a filter when resolving the BTF ID value.}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj;3hhubh)}(hAll the BTF ID lists and sets are compiled in the .BTF_ids section and resolved during the linking phase of kernel build by ``resolve_btfids`` tool.h](h|All the BTF ID lists and sets are compiled in the .BTF_ids section and resolved during the linking phase of kernel build by }(hj4hhhNhNubj)}(h``resolve_btfids``h]hresolve_btfids}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj4ubh tool.}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj;3hhubeh}(h]btf-ids-sectionah ]h"]4.3 .btf_ids sectionah$]h&]uh1hhj<0hhhhhMXubh)}(hhh](h)}(h4.4 .BTF.base sectionh]h4.4 .BTF.base section}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj4hhhhhMubh)}(hXSplit BTF - where the .BTF section only contains types not in the associated base .BTF section - is an extremely efficient way to encode type information for kernel modules, since they generally consist of a few module-specific types along with a large set of shared kernel types. The former are encoded in split BTF, while the latter are encoded in base BTF, resulting in more compact representations. A type in split BTF that refers to a type in base BTF refers to it using its base BTF ID, and split BTF IDs start at last_base_BTF_ID + 1.h]hXSplit BTF - where the .BTF section only contains types not in the associated base .BTF section - is an extremely efficient way to encode type information for kernel modules, since they generally consist of a few module-specific types along with a large set of shared kernel types. The former are encoded in split BTF, while the latter are encoded in base BTF, resulting in more compact representations. A type in split BTF that refers to a type in base BTF refers to it using its base BTF ID, and split BTF IDs start at last_base_BTF_ID + 1.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(hXThe downside of this approach however is that this makes the split BTF somewhat brittle - when the base BTF changes, base BTF ID references are no longer valid and the split BTF itself becomes useless. The role of the .BTF.base section is to make split BTF more resilient for cases where the base BTF may change, as is the case for kernel modules not built every time the kernel is for example. .BTF.base contains named base types; INTs, FLOATs, STRUCTs, UNIONs, ENUM[64]s and FWDs. INTs and FLOATs are fully described in .BTF.base sections, while composite types like structs and unions are not fully defined - the .BTF.base type simply serves as a description of the type the split BTF referred to, so structs/unions have 0 members in the .BTF.base section. ENUM[64]s are similarly recorded with 0 members. Any other types are added to the split BTF. This distillation process then leaves us with a .BTF.base section with such minimal descriptions of base types and .BTF split section which refers to those base types. Later, we can relocate the split BTF using both the information stored in the .BTF.base section and the new .BTF base; the type information in the .BTF.base section allows us to update the split BTF references to point at the corresponding new base BTF IDs.h]hXThe downside of this approach however is that this makes the split BTF somewhat brittle - when the base BTF changes, base BTF ID references are no longer valid and the split BTF itself becomes useless. The role of the .BTF.base section is to make split BTF more resilient for cases where the base BTF may change, as is the case for kernel modules not built every time the kernel is for example. .BTF.base contains named base types; INTs, FLOATs, STRUCTs, UNIONs, ENUM[64]s and FWDs. INTs and FLOATs are fully described in .BTF.base sections, while composite types like structs and unions are not fully defined - the .BTF.base type simply serves as a description of the type the split BTF referred to, so structs/unions have 0 members in the .BTF.base section. ENUM[64]s are similarly recorded with 0 members. Any other types are added to the split BTF. This distillation process then leaves us with a .BTF.base section with such minimal descriptions of base types and .BTF split section which refers to those base types. Later, we can relocate the split BTF using both the information stored in the .BTF.base section and the new .BTF base; the type information in the .BTF.base section allows us to update the split BTF references to point at the corresponding new base BTF IDs.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(hBTF relocation happens on kernel module load when a kernel module has a .BTF.base section, and libbpf also provides a btf__relocate() API to accomplish this.h]hBTF relocation happens on kernel module load when a kernel module has a .BTF.base section, and libbpf also provides a btf__relocate() API to accomplish this.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(h/As an example consider the following base BTF::h]h.As an example consider the following base BTF:}(hj-5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubj)}(h[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [2] STRUCT 'foo' size=8 vlen=2 'f1' type_id=1 bits_offset=0 'f2' type_id=1 bits_offset=32h]h[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [2] STRUCT 'foo' size=8 vlen=2 'f1' type_id=1 bits_offset=0 'f2' type_id=1 bits_offset=32}hj;5sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj4hhubh)}(h...and associated split BTF::h]h...and associated split BTF:}(hjI5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubj)}(h[3] PTR '(anon)' type_id=2h]h[3] PTR '(anon)' type_id=2}hjW5sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj4hhubh)}(hDi.e. split BTF describes a pointer to struct foo { int f1; int f2 };h]hDi.e. split BTF describes a pointer to struct foo { int f1; int f2 };}(hje5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(h.BTF.base will consist of::h]h.BTF.base will consist of:}(hjs5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubj)}(h\[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [2] STRUCT 'foo' size=8 vlen=0h]h\[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [2] STRUCT 'foo' size=8 vlen=0}hj5sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj4hhubh)}(hEIf we relocate the split BTF later using the following new base BTF::h]hDIf we relocate the split BTF later using the following new base BTF:}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubj)}(h[1] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [3] STRUCT 'foo' size=8 vlen=2 'f1' type_id=2 bits_offset=0 'f2' type_id=2 bits_offset=32h]h[1] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [3] STRUCT 'foo' size=8 vlen=2 'f1' type_id=2 bits_offset=0 'f2' type_id=2 bits_offset=32}hj5sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj4hhubh)}(h...we can use our .BTF.base description to know that the split BTF reference is to struct foo, and relocation results in new split BTF::h]h...we can use our .BTF.base description to know that the split BTF reference is to struct foo, and relocation results in new split BTF:}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubj)}(h[4] PTR '(anon)' type_id=3h]h[4] PTR '(anon)' type_id=3}hj5sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj4hhubh)}(hENote that we had to update BTF ID and start BTF ID for the split BTF.h]hENote that we had to update BTF ID and start BTF ID for the split BTF.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(hmSo we see how .BTF.base plays the role of facilitating later relocation, leading to more resilient split BTF.h]hmSo we see how .BTF.base plays the role of facilitating later relocation, leading to more resilient split BTF.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubh)}(hX).BTF.base sections will be generated automatically for out-of-tree kernel module builds - i.e. where KBUILD_EXTMOD is set (as it would be for "make M=path/2/mod" cases). .BTF.base generation requires pahole support for the "distilled_base" BTF feature; this is available in pahole v1.28 and later.h]hX1.BTF.base sections will be generated automatically for out-of-tree kernel module builds - i.e. where KBUILD_EXTMOD is set (as it would be for “make M=path/2/mod” cases). .BTF.base generation requires pahole support for the “distilled_base” BTF feature; this is available in pahole v1.28 and later.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4hhubeh}(h]btf-base-sectionah ]h"]4.4 .btf.base sectionah$]h&]uh1hhj<0hhhhhMubeh}(h]elf-file-format-interfaceah ]h"]4. elf file format interfaceah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h 5. Using BTFh]h 5. Using BTF}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6hhhhhMubh)}(hhh](h)}(h5.1 bpftool map pretty printh]h5.1 bpftool map pretty print}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6hhhhhMubh)}(hWith BTF, the map key/value can be printed based on fields rather than simply raw bytes. This is especially valuable for large structure or if your data structure has bitfields. For example, for the following map,::h]hWith BTF, the map key/value can be printed based on fields rather than simply raw bytes. This is especially valuable for large structure or if your data structure has bitfields. For example, for the following map,:}(hj#6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj6hhubj)}(hXOenum A { A1, A2, A3, A4, A5 }; typedef enum A ___A; struct tmp_t { char a1:4; int a2:4; int :4; __u32 a3:4; int b; ___A b1:4; enum A b2:4; }; struct { __uint(type, BPF_MAP_TYPE_ARRAY); __type(key, int); __type(value, struct tmp_t); __uint(max_entries, 1); } tmpmap SEC(".maps");h]hXOenum A { A1, A2, A3, A4, A5 }; typedef enum A ___A; struct tmp_t { char a1:4; int a2:4; int :4; __u32 a3:4; int b; ___A b1:4; enum A b2:4; }; struct { __uint(type, BPF_MAP_TYPE_ARRAY); __type(key, int); __type(value, struct tmp_t); __uint(max_entries, 1); } tmpmap SEC(".maps");}hj16sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj6hhubh)}(h.bpftool is able to pretty print like below: ::h]h+bpftool is able to pretty print like below:}(hj?6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj6hhubj)}(h[{ "key": 0, "value": { "a1": 0x2, "a2": 0x4, "a3": 0x6, "b": 7, "b1": 0x8, "b2": 0xa } } ]h]h[{ "key": 0, "value": { "a1": 0x2, "a2": 0x4, "a3": 0x6, "b": 7, "b1": 0x8, "b2": 0xa } } ]}hjM6sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj6hhubeh}(h]bpftool-map-pretty-printah ]h"]5.1 bpftool map pretty printah$]h&]uh1hhj6hhhhhMubh)}(hhh](h)}(h5.2 bpftool prog dumph]h5.2 bpftool prog dump}(hjf6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjc6hhhhhM ubh)}(hThe following is an example showing how func_info and line_info can help prog dump with better kernel symbol names, function prototypes and line information.::h]hThe following is an example showing how func_info and line_info can help prog dump with better kernel symbol names, function prototypes and line information.:}(hjt6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjc6hhubj)}(hX$ bpftool prog dump jited pinned /sys/fs/bpf/test_btf_haskv [...] int test_long_fname_2(struct dummy_tracepoint_args * arg): bpf_prog_44a040bf25481309_test_long_fname_2: ; static int test_long_fname_2(struct dummy_tracepoint_args *arg) 0: push %rbp 1: mov %rsp,%rbp 4: sub $0x30,%rsp b: sub $0x28,%rbp f: mov %rbx,0x0(%rbp) 13: mov %r13,0x8(%rbp) 17: mov %r14,0x10(%rbp) 1b: mov %r15,0x18(%rbp) 1f: xor %eax,%eax 21: mov %rax,0x20(%rbp) 25: xor %esi,%esi ; int key = 0; 27: mov %esi,-0x4(%rbp) ; if (!arg->sock) 2a: mov 0x8(%rdi),%rdi ; if (!arg->sock) 2e: cmp $0x0,%rdi 32: je 0x0000000000000070 34: mov %rbp,%rsi ; counts = bpf_map_lookup_elem(&btf_map, &key); [...]h]hX$ bpftool prog dump jited pinned /sys/fs/bpf/test_btf_haskv [...] int test_long_fname_2(struct dummy_tracepoint_args * arg): bpf_prog_44a040bf25481309_test_long_fname_2: ; static int test_long_fname_2(struct dummy_tracepoint_args *arg) 0: push %rbp 1: mov %rsp,%rbp 4: sub $0x30,%rsp b: sub $0x28,%rbp f: mov %rbx,0x0(%rbp) 13: mov %r13,0x8(%rbp) 17: mov %r14,0x10(%rbp) 1b: mov %r15,0x18(%rbp) 1f: xor %eax,%eax 21: mov %rax,0x20(%rbp) 25: xor %esi,%esi ; int key = 0; 27: mov %esi,-0x4(%rbp) ; if (!arg->sock) 2a: mov 0x8(%rdi),%rdi ; if (!arg->sock) 2e: cmp $0x0,%rdi 32: je 0x0000000000000070 34: mov %rbp,%rsi ; counts = bpf_map_lookup_elem(&btf_map, &key); [...]}hj6sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjc6hhubeh}(h]bpftool-prog-dumpah ]h"]5.2 bpftool prog dumpah$]h&]uh1hhj6hhhhhM ubh)}(hhh](h)}(h5.3 Verifier Logh]h5.3 Verifier Log}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6hhhhhM.ubh)}(hWThe following is an example of how line_info can help debugging verification failure.::h]hVThe following is an example of how line_info can help debugging verification failure.:}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM0hj6hhubj)}(hX{ /* The code at tools/testing/selftests/bpf/test_xdp_noinline.c * is modified as below. */ data = (void *)(long)xdp->data; data_end = (void *)(long)xdp->data_end; /* if (data + 4 > data_end) return XDP_DROP; */ *(u32 *)data = dst->dst; $ bpftool prog load ./test_xdp_noinline.o /sys/fs/bpf/test_xdp_noinline type xdp ; data = (void *)(long)xdp->data; 224: (79) r2 = *(u64 *)(r10 -112) 225: (61) r2 = *(u32 *)(r2 +0) ; *(u32 *)data = dst->dst; 226: (63) *(u32 *)(r2 +0) = r1 invalid access to packet, off=0 size=4, R2(id=0,off=0,r=0) R2 offset is outside of the packeth]hX{ /* The code at tools/testing/selftests/bpf/test_xdp_noinline.c * is modified as below. */ data = (void *)(long)xdp->data; data_end = (void *)(long)xdp->data_end; /* if (data + 4 > data_end) return XDP_DROP; */ *(u32 *)data = dst->dst; $ bpftool prog load ./test_xdp_noinline.o /sys/fs/bpf/test_xdp_noinline type xdp ; data = (void *)(long)xdp->data; 224: (79) r2 = *(u64 *)(r10 -112) 225: (61) r2 = *(u32 *)(r2 +0) ; *(u32 *)data = dst->dst; 226: (63) *(u32 *)(r2 +0) = r1 invalid access to packet, off=0 size=4, R2(id=0,off=0,r=0) R2 offset is outside of the packet}hj6sbah}(h]h ]h"]h$]h&]jjuh1jhhhM3hj6hhubeh}(h] verifier-logah ]h"]5.3 verifier logah$]h&]uh1hhj6hhhhhM.ubeh}(h] using-btfah ]h"] 5. using btfah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h6. BTF Generationh]h6. BTF Generation}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6hhhhhMHubh)}(hYou need latest paholeh]hYou need latest pahole}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhj6hhubjq)}(h8https://git.kernel.org/pub/scm/devel/pahole/pahole.git/ h]h)}(h7https://git.kernel.org/pub/scm/devel/pahole/pahole.git/h]h reference)}(hj6h]h7https://git.kernel.org/pub/scm/devel/pahole/pahole.git/}(hj6hhhNhNubah}(h]h ]h"]h$]h&]refurij6uh1j6hj6ubah}(h]h ]h"]h$]h&]uh1hhhhMLhj6ubah}(h]h ]h"]h$]h&]uh1jphhhMLhj6hhubh)}(hor llvm (8.0 or later). The pahole acts as a dwarf2btf converter. It doesn't support .BTF.ext and btf BTF_KIND_FUNC type yet. For example,::h]hor llvm (8.0 or later). The pahole acts as a dwarf2btf converter. It doesn’t support .BTF.ext and btf BTF_KIND_FUNC type yet. For example,:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhj6hhubj)}(hX|-bash-4.4$ cat t.c struct t { int a:2; int b:3; int c:2; } g; -bash-4.4$ gcc -c -O2 -g t.c -bash-4.4$ pahole -JV t.o File t.o: [1] STRUCT t kind_flag=1 size=4 vlen=3 a type_id=2 bitfield_size=2 bits_offset=0 b type_id=2 bitfield_size=3 bits_offset=2 c type_id=2 bitfield_size=2 bits_offset=5 [2] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNEDh]hX|-bash-4.4$ cat t.c struct t { int a:2; int b:3; int c:2; } g; -bash-4.4$ gcc -c -O2 -g t.c -bash-4.4$ pahole -JV t.o File t.o: [1] STRUCT t kind_flag=1 size=4 vlen=3 a type_id=2 bitfield_size=2 bits_offset=0 b type_id=2 bitfield_size=3 bits_offset=2 c type_id=2 bitfield_size=2 bits_offset=5 [2] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED}hj&7sbah}(h]h ]h"]h$]h&]jjuh1jhhhMQhj6hhubh)}(hThe llvm is able to generate .BTF and .BTF.ext directly with -g for bpf target only. The assembly code (-S) is able to show the BTF encoding in assembly format.::h]hThe llvm is able to generate .BTF and .BTF.ext directly with -g for bpf target only. The assembly code (-S) is able to show the BTF encoding in assembly format.:}(hj47hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM`hj6hhubj)}(hX -bash-4.4$ cat t2.c typedef int __int32; struct t2 { int a2; int (*f2)(char q1, __int32 q2, ...); int (*f3)(); } g2; int main() { return 0; } int test() { return 0; } -bash-4.4$ clang -c -g -O2 --target=bpf t2.c -bash-4.4$ readelf -S t2.o ...... [ 8] .BTF PROGBITS 0000000000000000 00000247 000000000000016e 0000000000000000 0 0 1 [ 9] .BTF.ext PROGBITS 0000000000000000 000003b5 0000000000000060 0000000000000000 0 0 1 [10] .rel.BTF.ext REL 0000000000000000 000007e0 0000000000000040 0000000000000010 16 9 8 ...... -bash-4.4$ clang -S -g -O2 --target=bpf t2.c -bash-4.4$ cat t2.s ...... .section .BTF,"",@progbits .short 60319 # 0xeb9f .byte 1 .byte 0 .long 24 .long 0 .long 220 .long 220 .long 122 .long 0 # BTF_KIND_FUNC_PROTO(id = 1) .long 218103808 # 0xd000000 .long 2 .long 83 # BTF_KIND_INT(id = 2) .long 16777216 # 0x1000000 .long 4 .long 16777248 # 0x1000020 ...... .byte 0 # string offset=0 .ascii ".text" # string offset=1 .byte 0 .ascii "/home/yhs/tmp-pahole/t2.c" # string offset=7 .byte 0 .ascii "int main() { return 0; }" # string offset=33 .byte 0 .ascii "int test() { return 0; }" # string offset=58 .byte 0 .ascii "int" # string offset=83 ...... .section .BTF.ext,"",@progbits .short 60319 # 0xeb9f .byte 1 .byte 0 .long 24 .long 0 .long 28 .long 28 .long 44 .long 8 # FuncInfo .long 1 # FuncInfo section string offset=1 .long 2 .long .Lfunc_begin0 .long 3 .long .Lfunc_begin1 .long 5 .long 16 # LineInfo .long 1 # LineInfo section string offset=1 .long 2 .long .Ltmp0 .long 7 .long 33 .long 7182 # Line 7 Col 14 .long .Ltmp3 .long 7 .long 58 .long 8206 # Line 8 Col 14h]hX -bash-4.4$ cat t2.c typedef int __int32; struct t2 { int a2; int (*f2)(char q1, __int32 q2, ...); int (*f3)(); } g2; int main() { return 0; } int test() { return 0; } -bash-4.4$ clang -c -g -O2 --target=bpf t2.c -bash-4.4$ readelf -S t2.o ...... [ 8] .BTF PROGBITS 0000000000000000 00000247 000000000000016e 0000000000000000 0 0 1 [ 9] .BTF.ext PROGBITS 0000000000000000 000003b5 0000000000000060 0000000000000000 0 0 1 [10] .rel.BTF.ext REL 0000000000000000 000007e0 0000000000000040 0000000000000010 16 9 8 ...... -bash-4.4$ clang -S -g -O2 --target=bpf t2.c -bash-4.4$ cat t2.s ...... .section .BTF,"",@progbits .short 60319 # 0xeb9f .byte 1 .byte 0 .long 24 .long 0 .long 220 .long 220 .long 122 .long 0 # BTF_KIND_FUNC_PROTO(id = 1) .long 218103808 # 0xd000000 .long 2 .long 83 # BTF_KIND_INT(id = 2) .long 16777216 # 0x1000000 .long 4 .long 16777248 # 0x1000020 ...... .byte 0 # string offset=0 .ascii ".text" # string offset=1 .byte 0 .ascii "/home/yhs/tmp-pahole/t2.c" # string offset=7 .byte 0 .ascii "int main() { return 0; }" # string offset=33 .byte 0 .ascii "int test() { return 0; }" # string offset=58 .byte 0 .ascii "int" # string offset=83 ...... .section .BTF.ext,"",@progbits .short 60319 # 0xeb9f .byte 1 .byte 0 .long 24 .long 0 .long 28 .long 28 .long 44 .long 8 # FuncInfo .long 1 # FuncInfo section string offset=1 .long 2 .long .Lfunc_begin0 .long 3 .long .Lfunc_begin1 .long 5 .long 16 # LineInfo .long 1 # LineInfo section string offset=1 .long 2 .long .Ltmp0 .long 7 .long 33 .long 7182 # Line 7 Col 14 .long .Ltmp3 .long 7 .long 58 .long 8206 # Line 8 Col 14}hjB7sbah}(h]h ]h"]h$]h&]jjuh1jhhhMdhj6hhubeh}(h]btf-generationah ]h"]6. btf generationah$]h&]uh1hhhhhhhhMHubh)}(hhh](h)}(h 7. Testingh]h 7. Testing}(hj[7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjX7hhhhhMubh)}(hwThe kernel BPF selftest `tools/testing/selftests/bpf/prog_tests/btf.c`_ provides an extensive set of BTF-related tests.h](hThe kernel BPF selftest }(hji7hhhNhNubj6)}(h/`tools/testing/selftests/bpf/prog_tests/btf.c`_h]h,tools/testing/selftests/bpf/prog_tests/btf.c}(hjq7hhhNhNubah}(h]h ]h"]h$]h&]name,tools/testing/selftests/bpf/prog_tests/btf.crefurirhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/tools/testing/selftests/bpf/prog_tests/btf.cuh1j6hji7resolvedKubh0 provides an extensive set of BTF-related tests.}(hji7hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjX7hhubhcomment)}(hLinksh]hLinks}hj7sbah}(h]h ]h"]h$]h&]jjuh1j7hjX7hhhhhMubj)}(h.. _tools/testing/selftests/bpf/prog_tests/btf.c: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/tools/testing/selftests/bpf/prog_tests/btf.ch]h}(h],tools-testing-selftests-bpf-prog-tests-btf-cah ]h"],tools/testing/selftests/bpf/prog_tests/btf.cah$]h&]j7j7uh1jhMhjX7hhhh referencedKubeh}(h]testingah ]h"] 7. testingah$]h&]uh1hhhhhhhhMubeh}(h]bpf-type-format-btfah ]h"]bpf type format (btf)ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksj(footnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj7error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames},tools/testing/selftests/bpf/prog_tests/btf.c]jq7asrefids}(j]jajC(]j9(aj*]j*aj-]j-aj0]j0aunameids}(j7j7jjj+jj+j+j~j{j%(j"(jjjj j j j j j!jj!jjUjRjjjjj#j jijfjbj_jjjjjljij j j2$j/$j%j%j(j(j+j+j*jC(j*j*j+j*j+j+j90j60j"-j-j-j-j.j-j.j.j /j /j3/j0/j/j/j10j.0j5j5j0j0j63j0j53j23j4j4j5j5j6j6j`6j]6j6j6j6j6jU7jR7j7j7j7j7u nametypes}(j7jj+j+j~j%(jjj j j!j!jUjjj#jijbjjjlj j2$j%j(j+j*j*j+j+j90j"-j-j.j.j /j3/j/j10j5j0j63j53j4j5j6j`6j6j6jU7j7j7uh}(j7hjhjjj+jj{jZj"(jjjRj jj jj j jj jj$jRj$jjXjjj jjfj&j_jljjejjjijj joj/$j j%j5$j(j%j+j((jC(jD(j*jD(j*j *j+j *j60j+j-j,j-j%-j-j-j.j-j /j.j0/j/j/j6/j.0j/j5j<0j0jM0j0j0j23j0j4j;3j5j4j6j6j]6j6j6jc6j6j6jR7j6j7jX7j7j7j*jW(j+j1*u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}j7KsRparse_messages](hsystem_message)}(hhh]h)}(hfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.h]hhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.}(hjK8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjH8ubah}(h]h ]h"]h$]h&]levelKtypeINFOlineMdsourcehuh1jF8hj+hhhhhMdubjG8)}(hhh]h)}(hfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.h]hhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.}(hjg8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjd8ubah}(h]h ]h"]h$]h&]levelKtypeja8lineMsourcehuh1jF8hj%-hhhhhMubjG8)}(hhh]h)}(hfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.h]hhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypeja8lineMsourcehuh1jF8hj-hhhhhMubjG8)}(hhh]h)}(hfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.h]hhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypeja8lineMsourcehuh1jF8hj6hhhhhMubetransform_messages](jG8)}(hhh]h)}(hhh]h5Hyperlink target "btf-type-string" is not referenced.}hj8sbah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypeja8sourcehlineKuh1jF8ubjG8)}(hhh]h)}(hhh]hDHyperlink target "btf-function-linkage-constants" is not referenced.}hj8sbah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypeja8sourcehlineM;uh1jF8ubjG8)}(hhh]h)}(hhh]h?Hyperlink target "btf-var-linkage-constants" is not referenced.}hj8sbah}(h]h ]h"]h$]h&]uh1hhj8ubah}(h]h ]h"]h$]h&]levelKtypeja8sourcehlineMJuh1jF8ubjG8)}(hhh]h)}(hhh]h3Hyperlink target "bpf-prog-load" is not referenced.}hj9sbah}(h]h ]h"]h$]h&]uh1hhj9ubah}(h]h ]h"]h$]h&]levelKtypeja8sourcehlineMuh1jF8ubjG8)}(hhh]h)}(hhh]h5Hyperlink target "btf-ext-section" is not referenced.}hj"9sbah}(h]h ]h"]h$]h&]uh1hhj9ubah}(h]h ]h"]h$]h&]levelKtypeja8sourcehlineMuh1jF8ube transformerN include_log] decorationNhhub.