{
__u32 l_cnt = btf->hdr.layout_len / sizeof(struct btf_layout);
struct btf_layout *l = btf->layout;
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
__u32 kind = btf_kind(t);
/* Fall back to base BTF if needed as they share layout information */
static int btf_type_size(const struct btf *btf, const struct btf_type *t)
{
const int base_size = sizeof(struct btf_type);
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
switch (btf_kind(t)) {
case BTF_KIND_FWD:
struct btf_array *a;
struct btf_param *p;
struct btf_enum *e;
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
int i;
switch (btf_kind(t)) {
case BTF_KIND_STRUCT:
case BTF_KIND_UNION: {
const struct btf_member *m = btf_members(t);
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
int i, max_align = 1, align;
for (i = 0; i < vlen; i++, m++) {
btf->hdr.type_len, UINT_MAX, add_sz);
}
-static void btf_type_inc_vlen(struct btf_type *t)
+static int btf_type_inc_vlen(struct btf_type *t)
{
+ if (btf_vlen(t) == BTF_MAX_VLEN)
+ return -ENOSPC;
t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, btf_kflag(t));
+ return 0;
}
static void btf_hdr_update_type_len(struct btf *btf, int new_len)
t = btf_last_type(btf);
if (!btf_is_composite(t))
return libbpf_err(-EINVAL);
+ if (btf_vlen(t) == BTF_MAX_VLEN)
+ return libbpf_err(-ENOSPC);
if (validate_type_id(type_id))
return libbpf_err(-EINVAL);
/* btf_add_type_mem can invalidate t pointer */
t = btf_last_type(btf);
+
/* update parent type's vlen and kflag */
t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, is_bitfield || btf_kflag(t));
/* update parent type's vlen */
t = btf_last_type(btf);
- btf_type_inc_vlen(t);
+ err = btf_type_inc_vlen(t);
+ if (err)
+ return libbpf_err(err);
/* if negative value, set signedness to signed */
if (value < 0)
/* update parent type's vlen */
t = btf_last_type(btf);
- btf_type_inc_vlen(t);
+ err = btf_type_inc_vlen(t);
+ if (err)
+ return libbpf_err(err);
btf_hdr_update_type_len(btf, btf->hdr.type_len + sz);
return 0;
/* update parent type's vlen */
t = btf_last_type(btf);
- btf_type_inc_vlen(t);
+ err = btf_type_inc_vlen(t);
+ if (err)
+ return libbpf_err(err);
btf_hdr_update_type_len(btf, btf->hdr.type_len + sz);
return 0;
/* update parent type's vlen */
t = btf_last_type(btf);
- btf_type_inc_vlen(t);
+ err = btf_type_inc_vlen(t);
+ if (err)
+ return libbpf_err(err);
btf_hdr_update_type_len(btf, btf->hdr.type_len + sz);
return 0;
static bool btf_equal_enum_members(struct btf_type *t1, struct btf_type *t2)
{
const struct btf_enum *m1, *m2;
- __u16 vlen;
+ __u32 vlen;
int i;
vlen = btf_vlen(t1);
static bool btf_equal_enum64_members(struct btf_type *t1, struct btf_type *t2)
{
const struct btf_enum64 *m1, *m2;
- __u16 vlen;
+ __u32 vlen;
int i;
vlen = btf_vlen(t1);
static bool btf_shallow_equal_struct(struct btf_type *t1, struct btf_type *t2)
{
const struct btf_member *m1, *m2;
- __u16 vlen;
+ __u32 vlen;
int i;
if (!btf_equal_common(t1, t2))
static long btf_hash_fnproto(struct btf_type *t)
{
const struct btf_param *member = btf_params(t);
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
long h = btf_hash_common(t);
int i;
static bool btf_equal_fnproto(struct btf_type *t1, struct btf_type *t2)
{
const struct btf_param *m1, *m2;
- __u16 vlen;
+ __u32 vlen;
int i;
if (!btf_equal_common(t1, t2))
static bool btf_compat_fnproto(struct btf_type *t1, struct btf_type *t2)
{
const struct btf_param *m1, *m2;
- __u16 vlen;
+ __u32 vlen;
int i;
/* skip return type ID */
case BTF_KIND_STRUCT:
case BTF_KIND_UNION: {
const struct btf_member *cand_m, *canon_m;
- __u16 vlen;
+ __u32 vlen;
if (!btf_shallow_equal_struct(cand_type, canon_type))
return 0;
case BTF_KIND_FUNC_PROTO: {
const struct btf_param *cand_p, *canon_p;
- __u16 vlen;
+ __u32 vlen;
if (!btf_compat_fnproto(cand_type, canon_type))
return 0;
case BTF_KIND_FUNC_PROTO: {
struct btf_param *param;
- __u16 vlen;
+ __u32 vlen;
int i;
ref_type_id = btf_dedup_ref_type(d, t->type);
{
int i, j, n = btf__type_cnt(d->btf);
const struct btf_type *t;
- __u16 vlen;
+ __u32 vlen;
for (i = d->last_id + 1; i < n; i++) {
t = btf__type_by_id(d->btf, i);
*/
struct btf_dump_type_aux_state *tstate = &d->type_states[id];
const struct btf_type *t;
- __u16 vlen;
+ __u32 vlen;
int err, i;
/* return true, letting typedefs know that it's ok to be emitted */
*/
if (top_level_def || t->name_off == 0) {
const struct btf_member *m = btf_members(t);
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
int i, new_cont_id;
new_cont_id = t->name_off == 0 ? cont_id : id;
break;
case BTF_KIND_FUNC_PROTO: {
const struct btf_param *p = btf_params(t);
- __u16 n = btf_vlen(t);
+ __u32 n = btf_vlen(t);
int i;
btf_dump_emit_type(d, t->type, cont_id);
{
const struct btf_member *m;
int max_align = 1, align, i, bit_sz;
- __u16 vlen;
+ __u32 vlen;
m = btf_members(t);
vlen = btf_vlen(t);
bool is_struct = btf_is_struct(t);
bool packed, prev_bitfield = false;
int align, i, off = 0;
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
align = btf__align_of(d->btf, id);
packed = is_struct ? btf_is_struct_packed(d->btf, id, t) : 0;
static void btf_dump_emit_enum32_val(struct btf_dump *d,
const struct btf_type *t,
- int lvl, __u16 vlen)
+ int lvl, __u32 vlen)
{
const struct btf_enum *v = btf_enum(t);
bool is_signed = btf_kflag(t);
static void btf_dump_emit_enum64_val(struct btf_dump *d,
const struct btf_type *t,
- int lvl, __u16 vlen)
+ int lvl, __u32 vlen)
{
const struct btf_enum64 *v = btf_enum64(t);
bool is_signed = btf_kflag(t);
const struct btf_type *t,
int lvl)
{
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
btf_dump_printf(d, "enum%s%s",
t->name_off ? " " : "",
}
case BTF_KIND_FUNC_PROTO: {
const struct btf_param *p = btf_params(t);
- __u16 vlen = btf_vlen(t);
+ __u32 vlen = btf_vlen(t);
int i;
/*
const void *data)
{
const struct btf_member *m = btf_members(t);
- __u16 n = btf_vlen(t);
+ __u32 n = btf_vlen(t);
int i, err = 0;
/* note that we increment depth before calling btf_dump_print() below;
case BTF_KIND_STRUCT:
case BTF_KIND_UNION: {
const struct btf_member *m = btf_members(t);
- __u16 n = btf_vlen(t);
+ __u32 n = btf_vlen(t);
/* if any struct/union member is non-zero, the struct/union
* is considered non-zero and dumped.
case BTF_KIND_FUNC_PROTO: {
struct btf_param *local_p = btf_params(local_type);
struct btf_param *targ_p = btf_params(targ_type);
- __u16 local_vlen = btf_vlen(local_type);
- __u16 targ_vlen = btf_vlen(targ_type);
+ __u32 local_vlen = btf_vlen(local_type);
+ __u32 targ_vlen = btf_vlen(targ_type);
int i, err;
if (local_vlen != targ_vlen)
static int bpf_core_enums_match(const struct btf *local_btf, const struct btf_type *local_t,
const struct btf *targ_btf, const struct btf_type *targ_t)
{
- __u16 local_vlen = btf_vlen(local_t);
- __u16 targ_vlen = btf_vlen(targ_t);
+ __u32 local_vlen = btf_vlen(local_t);
+ __u32 targ_vlen = btf_vlen(targ_t);
int i, j;
if (local_t->size != targ_t->size)
bool behind_ptr, int level)
{
const struct btf_member *local_m = btf_members(local_t);
- __u16 local_vlen = btf_vlen(local_t);
- __u16 targ_vlen = btf_vlen(targ_t);
+ __u32 local_vlen = btf_vlen(local_t);
+ __u32 targ_vlen = btf_vlen(targ_t);
int i, j, err;
if (local_vlen > targ_vlen)
case BTF_KIND_FUNC_PROTO: {
struct btf_param *local_p = btf_params(local_t);
struct btf_param *targ_p = btf_params(targ_t);
- __u16 local_vlen = btf_vlen(local_t);
- __u16 targ_vlen = btf_vlen(targ_t);
+ __u32 local_vlen = btf_vlen(local_t);
+ __u32 targ_vlen = btf_vlen(targ_t);
int i, err;
if (local_k != targ_k)