/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018 Facebook */
#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/filter.h>
#include <linux/unistd.h>
#include <bpf/bpf.h>
#include <libelf.h>
#include <gelf.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <bpf/libbpf.h>
#include <bpf/btf.h>
#include "bpf_util.h"
#include "../test_btf.h"
#include "test_progs.h"
#define MAX_INSNS 512
#define MAX_SUBPROGS 16
static int duration = 0;
static bool always_log;
#undef CHECK
#define CHECK(condition, format...) _CHECK(condition, "check" , duration, format)
#define NAME_TBD 0xdeadb33f
#define NAME_NTH(N) (0xfffe0000 | N)
#define IS_NAME_NTH(X) ((X & 0xffff0000) == 0xfffe0000)
#define GET_NAME_NTH_IDX(X) (X & 0x0000ffff)
#define MAX_NR_RAW_U32 1024
#define BTF_LOG_BUF_SIZE 65535
static char btf_log_buf[BTF_LOG_BUF_SIZE];
static struct btf_header hdr_tmpl = {
.magic = BTF_MAGIC,
.version = BTF_VERSION,
.hdr_len = sizeof (struct btf_header),
};
/* several different mapv kinds(types) supported by pprint */
enum pprint_mapv_kind_t {
PPRINT_MAPV_KIND_BASIC = 0,
PPRINT_MAPV_KIND_INT128,
};
struct btf_raw_test {
const char *descr;
const char *str_sec;
const char *map_name;
const char *err_str;
__u32 raw_types[MAX_NR_RAW_U32];
__u32 str_sec_size;
enum bpf_map_type map_type;
__u32 key_size;
__u32 value_size;
__u32 key_type_id;
__u32 value_type_id;
__u32 max_entries;
bool btf_load_err;
bool map_create_err;
bool ordered_map;
bool lossless_map;
bool percpu_map;
int hdr_len_delta;
int type_off_delta;
int str_off_delta;
int str_len_delta;
enum pprint_mapv_kind_t mapv_kind;
};
#define BTF_STR_SEC(str) \
.str_sec = str, .str_sec_size = sizeof (str)
static struct btf_raw_test raw_tests[] = {
/* enum E {
* E0,
* E1,
* };
*
* struct A {
* unsigned long long m;
* int n;
* char o;
* [3 bytes hole]
* int p[8];
* int q[4][8];
* enum E r;
* };
*/
{
.descr = "struct test #1" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 6), 180),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
BTF_MEMBER_ENC(NAME_TBD, 6, 384),/* int q[4][8] */
BTF_MEMBER_ENC(NAME_TBD, 7, 1408), /* enum E r */
/* } */
/* int[4][8] */
BTF_TYPE_ARRAY_ENC(4, 1, 4), /* [6] */
/* enum E */ /* [7] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_ENUM, 0, 2), sizeof (int )),
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_ENUM_ENC(NAME_TBD, 1),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0q\0r\0E\0E0\0E1" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0q\0r\0E\0E0\0E1" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_test1_map" ,
.key_size = sizeof (int ),
.value_size = 180,
.key_type_id = 1,
.value_type_id = 5,
.max_entries = 4,
},
/* typedef struct b Struct_B;
*
* struct A {
* int m;
* struct b n[4];
* const Struct_B o[4];
* };
*
* struct B {
* int m;
* int n;
* };
*/
{
.descr = "struct test #2" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* struct b [4] */ /* [2] */
BTF_TYPE_ARRAY_ENC(4, 1, 4),
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 3), 68),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* struct B n[4] */
BTF_MEMBER_ENC(NAME_TBD, 8, 288),/* const Struct_B o[4];*/
/* } */
/* struct B { */ /* [4] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 8),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 1, 32),/* int n; */
/* } */
/* const int */ /* [5] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 1),
/* typedef struct b Struct_B */ /* [6] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_TYPEDEF, 0, 0), 4),
/* const Struct_B */ /* [7] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 6),
/* const Struct_B [4] */ /* [8] */
BTF_TYPE_ARRAY_ENC(7, 1, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0B\0m\0n\0Struct_B" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0B\0m\0n\0Struct_B" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_test2_map" ,
.key_size = sizeof (int ),
.value_size = 68,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
},
{
.descr = "struct test #3 Invalid member offset" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int64 */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 64, 8),
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 16),
BTF_MEMBER_ENC(NAME_TBD, 1, 64), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* int64 n; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0" ,
.str_sec_size = sizeof ("\0A\0m\0n\0" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_test3_map" ,
.key_size = sizeof (int ),
.value_size = 16,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid member bits_offset" ,
},
/*
* struct A {
* unsigned long long m;
* int n;
* char o;
* [3 bytes hole]
* int p[8];
* };
*/
{
.descr = "global data test #1" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_test1_map" ,
.key_size = sizeof (int ),
.value_size = 48,
.key_type_id = 1,
.value_type_id = 5,
.max_entries = 4,
},
/*
* struct A {
* unsigned long long m;
* int n;
* char o;
* [3 bytes hole]
* int p[8];
* };
* static struct A t; <- in .bss
*/
{
.descr = "global data test #2" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* .bss section */ /* [7] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 48),
BTF_VAR_SECINFO_ENC(6, 0, 48),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 48,
.key_type_id = 0,
.value_type_id = 7,
.max_entries = 1,
},
{
.descr = "global data test #3" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* static int t */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(2, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0t\0.bss" ,
.str_sec_size = sizeof ("\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 3,
.max_entries = 1,
},
{
.descr = "global data test #4, unsupported linkage" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* static int t */
BTF_VAR_ENC(NAME_TBD, 1, 2), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(2, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0t\0.bss" ,
.str_sec_size = sizeof ("\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 3,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Linkage not supported" ,
},
{
.descr = "global data test #5, invalid var type" ,
.raw_types = {
/* static void t */
BTF_VAR_ENC(NAME_TBD, 0, 0), /* [1] */
/* .bss section */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(1, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0t\0.bss" ,
.str_sec_size = sizeof ("\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 2,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #6, invalid var type (fwd type)" ,
.raw_types = {
/* union A */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_FWD, 1, 0), 0), /* [1] */
/* static union A t */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(2, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 2,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type" ,
},
{
.descr = "global data test #7, invalid var type (fwd type)" ,
.raw_types = {
/* union A */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_FWD, 1, 0), 0), /* [1] */
/* static union A t */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(1, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 2,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type" ,
},
{
.descr = "global data test #8, invalid var size" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* .bss section */ /* [7] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 48),
BTF_VAR_SECINFO_ENC(6, 0, 47),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 48,
.key_type_id = 0,
.value_type_id = 7,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid size" ,
},
{
.descr = "global data test #9, invalid var size" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* .bss section */ /* [7] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 46),
BTF_VAR_SECINFO_ENC(6, 0, 48),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 48,
.key_type_id = 0,
.value_type_id = 7,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid size" ,
},
{
.descr = "global data test #10, invalid var size" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* .bss section */ /* [7] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 46),
BTF_VAR_SECINFO_ENC(6, 0, 46),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 48,
.key_type_id = 0,
.value_type_id = 7,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid size" ,
},
{
.descr = "global data test #11, multiple section members" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* static int u */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [7] */
/* .bss section */ /* [8] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2), 62),
BTF_VAR_SECINFO_ENC(6, 10, 48),
BTF_VAR_SECINFO_ENC(7, 58, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0u\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0u\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 62,
.key_type_id = 0,
.value_type_id = 8,
.max_entries = 1,
},
{
.descr = "global data test #12, invalid offset" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* static int u */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [7] */
/* .bss section */ /* [8] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2), 62),
BTF_VAR_SECINFO_ENC(6, 10, 48),
BTF_VAR_SECINFO_ENC(7, 60, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0u\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0u\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 62,
.key_type_id = 0,
.value_type_id = 8,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid offset+size" ,
},
{
.descr = "global data test #13, invalid offset" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* static int u */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [7] */
/* .bss section */ /* [8] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2), 62),
BTF_VAR_SECINFO_ENC(6, 10, 48),
BTF_VAR_SECINFO_ENC(7, 12, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0u\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0u\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 62,
.key_type_id = 0,
.value_type_id = 8,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid offset" ,
},
{
.descr = "global data test #14, invalid offset" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* unsigned long long */
BTF_TYPE_INT_ENC(0, 0, 0, 64, 8), /* [2] */
/* char */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1), /* [3] */
/* int[8] */
BTF_TYPE_ARRAY_ENC(1, 1, 8), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 4), 48),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* unsigned long long m;*/
BTF_MEMBER_ENC(NAME_TBD, 1, 64),/* int n; */
BTF_MEMBER_ENC(NAME_TBD, 3, 96),/* char o; */
BTF_MEMBER_ENC(NAME_TBD, 4, 128),/* int p[8] */
/* } */
/* static struct A t */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
/* static int u */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [7] */
/* .bss section */ /* [8] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2), 62),
BTF_VAR_SECINFO_ENC(7, 58, 4),
BTF_VAR_SECINFO_ENC(6, 10, 48),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n\0o\0p\0t\0u\0.bss" ,
.str_sec_size = sizeof ("\0A\0m\0n\0o\0p\0t\0u\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 62,
.key_type_id = 0,
.value_type_id = 8,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid offset" ,
},
{
.descr = "global data test #15, not var kind" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(1, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0t\0.bss" ,
.str_sec_size = sizeof ("\0A\0t\0.bss" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 3,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Not a VAR kind member" ,
},
{
.descr = "global data test #16, invalid var referencing sec" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [2] */
BTF_VAR_ENC(NAME_TBD, 2, 0), /* [3] */
/* a section */ /* [4] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(3, 0, 4),
/* a section */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(6, 0, 4),
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [6] */
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #17, invalid var referencing var" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [2] */
BTF_VAR_ENC(NAME_TBD, 2, 0), /* [3] */
/* a section */ /* [4] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(3, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #18, invalid var loop" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_VAR_ENC(NAME_TBD, 2, 0), /* [2] */
/* .bss section */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 1), 4),
BTF_VAR_SECINFO_ENC(2, 0, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0t\0aaa" ,
.str_sec_size = sizeof ("\0A\0t\0aaa" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #19, invalid var referencing var" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_VAR_ENC(NAME_TBD, 3, 0), /* [2] */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [3] */
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #20, invalid ptr referencing var" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* PTR type_id=3 */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 3),
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [3] */
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid type_id" ,
},
{
.descr = "global data test #21, var included in struct" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* struct A { */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), sizeof (int ) * 2),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 3, 32),/* VAR type_id=3; */
/* } */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [3] */
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid member" ,
},
{
.descr = "global data test #22, array of var" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ARRAY_ENC(3, 1, 4), /* [2] */
BTF_VAR_ENC(NAME_TBD, 1, 0), /* [3] */
BTF_END_RAW,
},
.str_sec = "\0A\0t\0s\0a\0a" ,
.str_sec_size = sizeof ("\0A\0t\0s\0a\0a" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = 4,
.key_type_id = 0,
.value_type_id = 4,
.max_entries = 1,
.btf_load_err = true ,
.err_str = "Invalid elem" ,
},
{
.descr = "var after datasec, ptr followed by modifier" ,
.raw_types = {
/* .bss section */ /* [1] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2),
sizeof (void *)+4),
BTF_VAR_SECINFO_ENC(4, 0, sizeof (void *)),
BTF_VAR_SECINFO_ENC(6, sizeof (void *), 4),
/* int */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int* */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2),
BTF_VAR_ENC(NAME_TBD, 3, 0), /* [4] */
/* const int */ /* [5] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2),
BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */
BTF_END_RAW,
},
.str_sec = "\0a\0b\0c\0" ,
.str_sec_size = sizeof ("\0a\0b\0c\0" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = ".bss" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *)+4,
.key_type_id = 0,
.value_type_id = 1,
.max_entries = 1,
},
/* Test member exceeds the size of struct.
*
* struct A {
* int m;
* int n;
* };
*/
{
.descr = "size check test #1" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* struct A { */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), sizeof (int ) * 2 - 1),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 1, 32),/* int n; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n" ,
.str_sec_size = sizeof ("\0A\0m\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "size_check1_map" ,
.key_size = sizeof (int ),
.value_size = 1,
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Member exceeds struct_size" ,
},
/* Test member exceeds the size of struct
*
* struct A {
* int m;
* int n[2];
* };
*/
{
.descr = "size check test #2" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, sizeof (int )),
/* int[2] */ /* [2] */
BTF_TYPE_ARRAY_ENC(1, 1, 2),
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), sizeof (int ) * 3 - 1),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* int n[2]; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n" ,
.str_sec_size = sizeof ("\0A\0m\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "size_check2_map" ,
.key_size = sizeof (int ),
.value_size = 1,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Member exceeds struct_size" ,
},
/* Test member exceeds the size of struct
*
* struct A {
* int m;
* void *n;
* };
*/
{
.descr = "size check test #3" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, sizeof (int )),
/* void* */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 0),
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), sizeof (int ) + sizeof (void *) - 1),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* void *n; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m\0n" ,
.str_sec_size = sizeof ("\0A\0m\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "size_check3_map" ,
.key_size = sizeof (int ),
.value_size = 1,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Member exceeds struct_size" ,
},
/* Test member exceeds the size of struct
*
* enum E {
* E0,
* E1,
* };
*
* struct A {
* int m;
* enum E n;
* };
*/
{
.descr = "size check test #4" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, sizeof (int )),
/* enum E { */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_ENUM, 0, 2), sizeof (int )),
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_ENUM_ENC(NAME_TBD, 1),
/* } */
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), sizeof (int ) * 2 - 1),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* enum E n; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0E\0E0\0E1\0A\0m\0n" ,
.str_sec_size = sizeof ("\0E\0E0\0E1\0A\0m\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "size_check4_map" ,
.key_size = sizeof (int ),
.value_size = 1,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Member exceeds struct_size" ,
},
/* Test member unexceeds the size of struct
*
* enum E {
* E0,
* E1,
* };
*
* struct A {
* char m;
* enum E __attribute__((packed)) n;
* };
*/
{
.descr = "size check test #5" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, sizeof (int )),
/* char */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 8, 1),
/* enum E { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_ENUM, 0, 2), 1),
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_ENUM_ENC(NAME_TBD, 1),
/* } */
/* struct A { */ /* [4] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 2),
BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* char m; */
BTF_MEMBER_ENC(NAME_TBD, 3, 8),/* enum E __attribute__((packed)) n; */
/* } */
BTF_END_RAW,
},
.str_sec = "\0E\0E0\0E1\0A\0m\0n" ,
.str_sec_size = sizeof ("\0E\0E0\0E1\0A\0m\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "size_check5_map" ,
.key_size = sizeof (int ),
.value_size = 2,
.key_type_id = 1,
.value_type_id = 4,
.max_entries = 4,
},
/* typedef const void * const_void_ptr;
* struct A {
* const_void_ptr m;
* };
*/
{
.descr = "void test #1" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
/* const void* */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2),
/* typedef const void * const_void_ptr */
BTF_TYPEDEF_ENC(NAME_TBD, 3), /* [4] */
/* struct A { */ /* [5] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), sizeof (void *)),
/* const_void_ptr m; */
BTF_MEMBER_ENC(NAME_TBD, 4, 0),
/* } */
BTF_END_RAW,
},
.str_sec = "\0const_void_ptr\0A\0m" ,
.str_sec_size = sizeof ("\0const_void_ptr\0A\0m" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "void_test1_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *),
.key_type_id = 1,
.value_type_id = 4,
.max_entries = 4,
},
/* struct A {
* const void m;
* };
*/
{
.descr = "void test #2" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
/* struct A { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 8),
/* const void m; */
BTF_MEMBER_ENC(NAME_TBD, 2, 0),
/* } */
BTF_END_RAW,
},
.str_sec = "\0A\0m" ,
.str_sec_size = sizeof ("\0A\0m" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "void_test2_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *),
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid member" ,
},
/* typedef const void * const_void_ptr;
* const_void_ptr[4]
*/
{
.descr = "void test #3" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
/* const void* */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2),
/* typedef const void * const_void_ptr */
BTF_TYPEDEF_ENC(NAME_TBD, 3), /* [4] */
/* const_void_ptr[4] */
BTF_TYPE_ARRAY_ENC(4, 1, 4), /* [5] */
BTF_END_RAW,
},
.str_sec = "\0const_void_ptr" ,
.str_sec_size = sizeof ("\0const_void_ptr" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "void_test3_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *) * 4,
.key_type_id = 1,
.value_type_id = 5,
.max_entries = 4,
},
/* const void[4] */
{
.descr = "void test #4" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
/* const void[4] */ /* [3] */
BTF_TYPE_ARRAY_ENC(2, 1, 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m" ,
.str_sec_size = sizeof ("\0A\0m" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "void_test4_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *) * 4,
.key_type_id = 1,
.value_type_id = 3,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid elem" ,
},
/* Array_A <------------------+
* elem_type == Array_B |
* | |
* | |
* Array_B <-------- + |
* elem_type == Array A --+
*/
{
.descr = "loop test #1" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* Array_A */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 1, 8),
/* Array_B */ /* [3] */
BTF_TYPE_ARRAY_ENC(2, 1, 8),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test1_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (sizeof (int ) * 8),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
/* typedef is _before_ the BTF type of Array_A and Array_B
*
* typedef Array_B int_array;
*
* Array_A <------------------+
* elem_type == int_array |
* | |
* | |
* Array_B <-------- + |
* elem_type == Array_A --+
*/
{
.descr = "loop test #2" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* typedef Array_B int_array */
BTF_TYPEDEF_ENC(1, 4), /* [2] */
/* Array_A */
BTF_TYPE_ARRAY_ENC(2, 1, 8), /* [3] */
/* Array_B */
BTF_TYPE_ARRAY_ENC(3, 1, 8), /* [4] */
BTF_END_RAW,
},
.str_sec = "\0int_array\0" ,
.str_sec_size = sizeof ("\0int_array" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test2_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (sizeof (int ) * 8),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
/* Array_A <------------------+
* elem_type == Array_B |
* | |
* | |
* Array_B <-------- + |
* elem_type == Array_A --+
*/
{
.descr = "loop test #3" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* Array_A */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 1, 8),
/* Array_B */ /* [3] */
BTF_TYPE_ARRAY_ENC(2, 1, 8),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test3_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (sizeof (int ) * 8),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
/* typedef is _between_ the BTF type of Array_A and Array_B
*
* typedef Array_B int_array;
*
* Array_A <------------------+
* elem_type == int_array |
* | |
* | |
* Array_B <-------- + |
* elem_type == Array_A --+
*/
{
.descr = "loop test #4" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* Array_A */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 1, 8),
/* typedef Array_B int_array */ /* [3] */
BTF_TYPEDEF_ENC(NAME_TBD, 4),
/* Array_B */ /* [4] */
BTF_TYPE_ARRAY_ENC(2, 1, 8),
BTF_END_RAW,
},
.str_sec = "\0int_array\0" ,
.str_sec_size = sizeof ("\0int_array" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test4_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (sizeof (int ) * 8),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
/* typedef struct B Struct_B
*
* struct A {
* int x;
* Struct_B y;
* };
*
* struct B {
* int x;
* struct A y;
* };
*/
{
.descr = "loop test #5" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* struct A */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 8),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int x; */
BTF_MEMBER_ENC(NAME_TBD, 3, 32),/* Struct_B y; */
/* typedef struct B Struct_B */
BTF_TYPEDEF_ENC(NAME_TBD, 4), /* [3] */
/* struct B */ /* [4] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 8),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int x; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* struct A y; */
BTF_END_RAW,
},
.str_sec = "\0A\0x\0y\0Struct_B\0B\0x\0y" ,
.str_sec_size = sizeof ("\0A\0x\0y\0Struct_B\0B\0x\0y" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test5_map" ,
.key_size = sizeof (int ),
.value_size = 8,
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
/* struct A {
* int x;
* struct A array_a[4];
* };
*/
{
.descr = "loop test #6" ,
.raw_types = {
/* int */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ARRAY_ENC(3, 1, 4), /* [2] */
/* struct A */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 8),
BTF_MEMBER_ENC(NAME_TBD, 1, 0), /* int x; */
BTF_MEMBER_ENC(NAME_TBD, 2, 32),/* struct A array_a[4]; */
BTF_END_RAW,
},
.str_sec = "\0A\0x\0y" ,
.str_sec_size = sizeof ("\0A\0x\0y" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test6_map" ,
.key_size = sizeof (int ),
.value_size = 8,
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
{
.descr = "loop test #7" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* struct A { */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), sizeof (void *)),
/* const void *m; */
BTF_MEMBER_ENC(NAME_TBD, 3, 0),
/* CONST type_id=3 */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 4),
/* PTR type_id=2 */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 3),
BTF_END_RAW,
},
.str_sec = "\0A\0m" ,
.str_sec_size = sizeof ("\0A\0m" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test7_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
{
.descr = "loop test #8" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* struct A { */ /* [2] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), sizeof (void *)),
/* const void *m; */
BTF_MEMBER_ENC(NAME_TBD, 4, 0),
/* struct B { */ /* [3] */
BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), sizeof (void *)),
/* const void *n; */
BTF_MEMBER_ENC(NAME_TBD, 6, 0),
/* CONST type_id=5 */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 5),
/* PTR type_id=6 */ /* [5] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 6),
/* CONST type_id=7 */ /* [6] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 7),
/* PTR type_id=4 */ /* [7] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 4),
BTF_END_RAW,
},
.str_sec = "\0A\0m\0B\0n" ,
.str_sec_size = sizeof ("\0A\0m\0B\0n" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "loop_test8_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (void *),
.key_type_id = 1,
.value_type_id = 2,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Loop detected" ,
},
{
.descr = "string section does not end with null" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ) - 1,
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid string section" ,
},
{
.descr = "empty string section" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = 0,
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid string section" ,
},
{
.descr = "empty type section" ,
.raw_types = {
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "No type found" ,
},
{
.descr = "btf_header test. Longer hdr_len" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.hdr_len_delta = 4,
.err_str = "Unsupported btf_header" ,
},
{
.descr = "btf_header test. Gap between hdr and type" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.type_off_delta = 4,
.err_str = "Unsupported section found" ,
},
{
.descr = "btf_header test. Gap between type and str" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.str_off_delta = 4,
.err_str = "Unsupported section found" ,
},
{
.descr = "btf_header test. Overlap between type and str" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.str_off_delta = -4,
.err_str = "Section overlap found" ,
},
{
.descr = "btf_header test. Larger BTF size" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.str_len_delta = -4,
.err_str = "Unsupported section found" ,
},
{
.descr = "btf_header test. Smaller BTF size" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(NAME_TBD, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "\0int" ,
.str_sec_size = sizeof ("\0int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "hdr_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.str_len_delta = 4,
.err_str = "Total section length too long" ,
},
{
.descr = "array test. index_type/elem_type \" int \"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(1, 1, 16),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "array test. index_type/elem_type \" const int \"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 3, 16),
/* CONST type_id=1 */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 1),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "array test. index_type \" const int :31\"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int:31 */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 31, 4),
/* int[16] */ /* [3] */
BTF_TYPE_ARRAY_ENC(1, 4, 16),
/* CONST type_id=2 */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid index" ,
},
{
.descr = "array test. elem_type \" const int :31\"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int:31 */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 31, 4),
/* int[16] */ /* [3] */
BTF_TYPE_ARRAY_ENC(4, 1, 16),
/* CONST type_id=2 */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid array of int" ,
},
{
.descr = "array test. index_type \" void \"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(1, 0, 16),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid index" ,
},
{
.descr = "array test. index_type \" const void \"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(1, 3, 16),
/* CONST type_id=0 (void) */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid index" ,
},
{
.descr = "array test. elem_type \" const void \"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 1, 16),
/* CONST type_id=0 (void) */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid elem" ,
},
{
.descr = "array test. elem_type \" const void *\"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void *[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 1, 16),
/* CONST type_id=4 */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 4),
/* void* */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "array test. index_type \" const void *\"" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* const void *[16] */ /* [2] */
BTF_TYPE_ARRAY_ENC(3, 3, 16),
/* CONST type_id=4 */ /* [3] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 4),
/* void* */ /* [4] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid index" ,
},
{
.descr = "array test. t->size != 0\" ",
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* int[16] */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_ARRAY, 0, 0), 1),
BTF_ARRAY_ENC(1, 1, 16),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "size != 0" ,
},
{
.descr = "int test. invalid int_data" ,
.raw_types = {
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_INT, 0, 0), 4),
0x10000000,
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid int_data" ,
},
{
.descr = "invalid BTF_INFO" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
BTF_TYPE_ENC(0, 0x20000000, 4),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid btf_info" ,
},
{
.descr = "fwd test. t->type != 0\" ",
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* fwd type */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FWD, 0, 0), 1),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "fwd_test_map" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "type != 0" ,
},
{
.descr = "typedef (invalid name, name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPEDEF_ENC(0, 1), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__int" ,
.str_sec_size = sizeof ("\0__int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "typedef_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "typedef (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPEDEF_ENC(NAME_TBD, 1), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__!int" ,
.str_sec_size = sizeof ("\0__!int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "typedef_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "ptr type (invalid name, name_off <> 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 1), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__int" ,
.str_sec_size = sizeof ("\0__int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "ptr_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "volatile type (invalid name, name_off <> 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_VOLATILE, 0, 0), 1), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__int" ,
.str_sec_size = sizeof ("\0__int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "volatile_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "const type (invalid name, name_off <> 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 1), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__int" ,
.str_sec_size = sizeof ("\0__int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "const_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "restrict type (invalid name, name_off <> 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 1), /* [2] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_RESTRICT, 0, 0), 2), /* [3] */
BTF_END_RAW,
},
.str_sec = "\0__int" ,
.str_sec_size = sizeof ("\0__int" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "restrict_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "fwd type (invalid name, name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FWD, 0, 0), 0), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__skb" ,
.str_sec_size = sizeof ("\0__skb" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "fwd_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "fwd type (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_FWD, 0, 0), 0), /* [2] */
BTF_END_RAW,
},
.str_sec = "\0__!skb" ,
.str_sec_size = sizeof ("\0__!skb" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "fwd_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "array type (invalid name, name_off <> 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_ARRAY, 0, 0), 0), /* [2] */
BTF_ARRAY_ENC(1, 1, 4),
BTF_END_RAW,
},
.str_sec = "\0__skb" ,
.str_sec_size = sizeof ("\0__skb" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "struct type (name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0,
BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 4), /* [2] */
BTF_MEMBER_ENC(NAME_TBD, 1, 0),
BTF_END_RAW,
},
.str_sec = "\0A" ,
.str_sec_size = sizeof ("\0A" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "struct type (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 4), /* [2] */
BTF_MEMBER_ENC(NAME_TBD, 1, 0),
BTF_END_RAW,
},
.str_sec = "\0A!\0B" ,
.str_sec_size = sizeof ("\0A!\0B" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "struct member (name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0,
BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 4), /* [2] */
BTF_MEMBER_ENC(NAME_TBD, 1, 0),
BTF_END_RAW,
},
.str_sec = "\0A" ,
.str_sec_size = sizeof ("\0A" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "struct member (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 1), 4), /* [2] */
BTF_MEMBER_ENC(NAME_TBD, 1, 0),
BTF_END_RAW,
},
.str_sec = "\0A\0B*" ,
.str_sec_size = sizeof ("\0A\0B*" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "struct_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "enum type (name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0,
BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1),
sizeof (int )), /* [2] */
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_END_RAW,
},
.str_sec = "\0A\0B" ,
.str_sec_size = sizeof ("\0A\0B" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "enum_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "enum type (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(NAME_TBD,
BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1),
sizeof (int )), /* [2] */
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_END_RAW,
},
.str_sec = "\0A!\0B" ,
.str_sec_size = sizeof ("\0A!\0B" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "enum_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "enum member (invalid name, name_off = 0)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0,
BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1),
sizeof (int )), /* [2] */
BTF_ENUM_ENC(0, 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "enum_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "enum member (invalid name, invalid identifier)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_ENC(0,
BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1),
sizeof (int )), /* [2] */
BTF_ENUM_ENC(NAME_TBD, 0),
BTF_END_RAW,
},
.str_sec = "\0A!" ,
.str_sec_size = sizeof ("\0A!" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "enum_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid name" ,
},
{
.descr = "arraymap invalid btf key (a bit field)" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* 32 bit int with 32 bit offset */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 32, 32, 8),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_map_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 2,
.value_type_id = 1,
.max_entries = 4,
.map_create_err = true ,
},
{
.descr = "arraymap invalid btf key (!= 32 bits)" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
/* 16 bit int with 0 bit offset */ /* [2] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 16, 2),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_map_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 2,
.value_type_id = 1,
.max_entries = 4,
.map_create_err = true ,
},
{
.descr = "arraymap invalid btf value (too small)" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_map_check_btf" ,
.key_size = sizeof (int ),
/* btf_value_size < map->value_size */
.value_size = sizeof (__u64),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.map_create_err = true ,
},
{
.descr = "arraymap invalid btf value (too big)" ,
.raw_types = {
/* int */ /* [1] */
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "array_map_check_btf" ,
.key_size = sizeof (int ),
/* btf_value_size > map->value_size */
.value_size = sizeof (__u16),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.map_create_err = true ,
},
{
.descr = "func proto (int (*)(int, unsigned int))" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */
/* int (*)(int, unsigned int) */
BTF_FUNC_PROTO_ENC(1, 2), /* [3] */
BTF_FUNC_PROTO_ARG_ENC(0, 1),
BTF_FUNC_PROTO_ARG_ENC(0, 2),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "func_proto_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "func proto (vararg)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */
/* void (*)(int, unsigned int, ...) */
BTF_FUNC_PROTO_ENC(0, 3), /* [3] */
BTF_FUNC_PROTO_ARG_ENC(0, 1),
BTF_FUNC_PROTO_ARG_ENC(0, 2),
BTF_FUNC_PROTO_ARG_ENC(0, 0),
BTF_END_RAW,
},
.str_sec = "" ,
.str_sec_size = sizeof ("" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "func_proto_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
},
{
.descr = "func proto (vararg with name)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */
/* void (*)(int a, unsigned int b, ... c) */
BTF_FUNC_PROTO_ENC(0, 3), /* [3] */
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 2),
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 0),
BTF_END_RAW,
},
.str_sec = "\0a\0b\0c" ,
.str_sec_size = sizeof ("\0a\0b\0c" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "func_proto_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid arg#3" ,
},
{
.descr = "func proto (arg after vararg)" ,
.raw_types = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */
/* void (*)(int a, ..., unsigned int b) */
BTF_FUNC_PROTO_ENC(0, 3), /* [3] */
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
BTF_FUNC_PROTO_ARG_ENC(0, 0),
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 2),
BTF_END_RAW,
},
.str_sec = "\0a\0b" ,
.str_sec_size = sizeof ("\0a\0b" ),
.map_type = BPF_MAP_TYPE_ARRAY,
.map_name = "func_proto_type_check_btf" ,
.key_size = sizeof (int ),
.value_size = sizeof (int ),
.key_type_id = 1,
.value_type_id = 1,
.max_entries = 4,
.btf_load_err = true ,
.err_str = "Invalid arg#2" ,
},
{
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5 C=90 H=96 G=93
¤ Dauer der Verarbeitung: 0.33 Sekunden
(vorverarbeitet)
¤
*© Formatika GbR, Deutschland