@@ -12,42 +12,29 @@ struct btf_header {
1212 __u16 magic ;
1313 __u8 version ;
1414 __u8 flags ;
15-
16- __u32 parent_label ;
17- __u32 parent_name ;
15+ __u32 hdr_len ;
1816
1917 /* All offsets are in bytes relative to the end of this header */
20- __u32 label_off ; /* offset of label section */
21- __u32 object_off ; /* offset of data object section*/
22- __u32 func_off ; /* offset of function section */
2318 __u32 type_off ; /* offset of type section */
19+ __u32 type_len ; /* length of type section */
2420 __u32 str_off ; /* offset of string section */
2521 __u32 str_len ; /* length of string section */
2622};
2723
2824/* Max # of type identifier */
29- #define BTF_MAX_TYPE 0x7fffffff
25+ #define BTF_MAX_TYPE 0x0000ffff
3026/* Max offset into the string section */
31- #define BTF_MAX_NAME_OFFSET 0x7fffffff
27+ #define BTF_MAX_NAME_OFFSET 0x0000ffff
3228/* Max # of struct/union/enum members or func args */
3329#define BTF_MAX_VLEN 0xffff
3430
35- /* The type id is referring to a parent BTF */
36- #define BTF_TYPE_PARENT (id ) (((id) >> 31) & 0x1)
37- #define BTF_TYPE_ID (id ) ((id) & BTF_MAX_TYPE)
38-
39- /* String is in the ELF string section */
40- #define BTF_STR_TBL_ELF_ID (ref ) (((ref) >> 31) & 0x1)
41- #define BTF_STR_OFFSET (ref ) ((ref) & BTF_MAX_NAME_OFFSET)
42-
4331struct btf_type {
4432 __u32 name_off ;
4533 /* "info" bits arrangement
4634 * bits 0-15: vlen (e.g. # of struct's members)
4735 * bits 16-23: unused
48- * bits 24-28: kind (e.g. int, ptr, array...etc)
49- * bits 29-30: unused
50- * bits 31: root
36+ * bits 24-27: kind (e.g. int, ptr, array...etc)
37+ * bits 28-31: unused
5138 */
5239 __u32 info ;
5340 /* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -62,8 +49,7 @@ struct btf_type {
6249 };
6350};
6451
65- #define BTF_INFO_KIND (info ) (((info) >> 24) & 0x1f)
66- #define BTF_INFO_ISROOT (info ) (!!(((info) >> 24) & 0x80))
52+ #define BTF_INFO_KIND (info ) (((info) >> 24) & 0x0f)
6753#define BTF_INFO_VLEN (info ) ((info) & 0xffff)
6854
6955#define BTF_KIND_UNKN 0 /* Unknown */
@@ -88,15 +74,14 @@ struct btf_type {
8874/* BTF_KIND_INT is followed by a u32 and the following
8975 * is the 32 bits arrangement:
9076 */
91- #define BTF_INT_ENCODING (VAL ) (((VAL) & 0xff000000 ) >> 24)
77+ #define BTF_INT_ENCODING (VAL ) (((VAL) & 0x0f000000 ) >> 24)
9278#define BTF_INT_OFFSET (VAL ) (((VAL & 0x00ff0000)) >> 16)
9379#define BTF_INT_BITS (VAL ) ((VAL) & 0x0000ffff)
9480
9581/* Attributes stored in the BTF_INT_ENCODING */
96- #define BTF_INT_SIGNED 0x1
97- #define BTF_INT_CHAR 0x2
98- #define BTF_INT_BOOL 0x4
99- #define BTF_INT_VARARGS 0x8
82+ #define BTF_INT_SIGNED (1 << 0)
83+ #define BTF_INT_CHAR (1 << 1)
84+ #define BTF_INT_BOOL (1 << 2)
10085
10186/* BTF_KIND_ENUM is followed by multiple "struct btf_enum".
10287 * The exact number of btf_enum is stored in the vlen (of the
0 commit comments