2021-05-21 02:15:52 +08:00
|
|
|
/* Declarations and definitions relating to the BPF Type Format (BTF).
|
2024-01-03 19:19:35 +08:00
|
|
|
Copyright (C) 2021-2024 Free Software Foundation, Inc.
|
2021-05-21 02:15:52 +08:00
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/* This file is derived from the BTF specification described in the
|
|
|
|
Linux kernel source tree (linux/Documentation/bpf/btf.rst). */
|
|
|
|
|
|
|
|
#ifndef _BTF_H_
|
|
|
|
#define _BTF_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* BTF magic number to identify header, endianness. */
|
|
|
|
#define BTF_MAGIC 0xeb9f
|
|
|
|
/* Data format version number. */
|
|
|
|
#define BTF_VERSION 1
|
|
|
|
|
|
|
|
struct btf_header
|
|
|
|
{
|
|
|
|
uint16_t magic; /* Magic number (BTF_MAGIC). */
|
|
|
|
uint8_t version; /* Data format version (BTF_VERSION). */
|
|
|
|
uint8_t flags; /* Flags. Currently unused. */
|
|
|
|
uint32_t hdr_len; /* Length of this header (sizeof (struct btf_header)). */
|
|
|
|
|
|
|
|
/* Following offsets are relative to the end of this header. */
|
|
|
|
uint32_t type_off; /* Offset of type section, in bytes. */
|
|
|
|
uint32_t type_len; /* Length of type section, in bytes. */
|
|
|
|
uint32_t str_off; /* Offset of string section, in bytes. */
|
|
|
|
uint32_t str_len; /* Length of string section, in bytes. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Maximum type identifier. */
|
|
|
|
#define BTF_MAX_TYPE 0x000fffff
|
|
|
|
/* Maximum offset into the string section. */
|
|
|
|
#define BTF_MAX_NAME_OFFSET 0x00ffffff
|
|
|
|
/* Maximum number of struct, union, enum members or func args. */
|
|
|
|
#define BTF_MAX_VLEN 0xffff
|
|
|
|
|
ctf: use pointers instead of IDs internally
This patch replaces all inter-type references in the ctfc internal data
structures with pointers, rather than the references-by-ID which were
used previously.
A couple of small updates in the BPF backend are included to make it
compatible with the change.
This change is only to the in-memory representation of various CTF
structures to make them easier to work with in various cases. It is
outwardly transparent; there is no change in emitted CTF.
gcc/
* btfout.cc (BTF_VOID_TYPEID, BTF_INIT_TYPEID): Move defines to
include/btf.h.
(btf_dvd_emit_preprocess_cb, btf_emit_preprocess)
(btf_dmd_representable_bitfield_p, btf_asm_array, btf_asm_varent)
(btf_asm_sou_member, btf_asm_func_arg, btf_init_postprocess):
Adapt to structural changes in ctf_* structs.
* ctfc.h (struct ctf_dtdef): Add forward declaration.
(ctf_dtdef_t, ctf_dtdef_ref): Move typedefs earlier.
(struct ctf_arinfo, struct ctf_funcinfo, struct ctf_sliceinfo)
(struct ctf_itype, struct ctf_dmdef, struct ctf_func_arg)
(struct ctf_dvdef): Use pointers instead of type IDs for
references to other types and use typedefs where appropriate.
(struct ctf_dtdef): Add ref_type member.
(ctf_type_exists): Use pointer instead of type ID.
(ctf_add_reftype, ctf_add_enum, ctf_add_slice, ctf_add_float)
(ctf_add_integer, ctf_add_unknown, ctf_add_pointer)
(ctf_add_array, ctf_add_forward, ctf_add_typedef)
(ctf_add_function, ctf_add_sou, ctf_add_enumerator)
(ctf_add_variable): Likewise. Return pointer instead of ID.
(ctf_lookup_tree_type): Return pointer to type instead of ID.
* ctfc.cc: Analogous changes.
* ctfout.cc (ctf_asm_type, ctf_asm_slice, ctf_asm_varent)
(ctf_asm_sou_lmember, ctf_asm_sou_member, ctf_asm_func_arg)
(output_ctf_objt_info): Adapt to changes.
* dwarf2ctf.cc (gen_ctf_type, gen_ctf_void_type)
(gen_ctf_unknown_type, gen_ctf_base_type, gen_ctf_pointer_type)
(gen_ctf_subrange_type, gen_ctf_array_type, gen_ctf_typedef)
(gen_ctf_modifier_type, gen_ctf_sou_type, gen_ctf_function_type)
(gen_ctf_enumeration_type, gen_ctf_variable, gen_ctf_function)
(gen_ctf_type, ctf_do_die): Likewise.
* config/bpf/btfext-out.cc (struct btf_ext_core_reloc): Use
pointer instead of type ID.
(bpf_core_reloc_add, bpf_core_get_sou_member_index)
(output_btfext_core_sections): Adapt to above changes.
* config/bpf/core-builtins.cc (process_type): Likewise.
include/
* btf.h (BTF_VOID_TYPEID, BTF_INIT_TYPEID): Move defines here,
from gcc/btfout.cc.
2024-05-31 05:06:27 +08:00
|
|
|
/* Type ID 0 represents the void type. */
|
|
|
|
#define BTF_VOID_TYPEID 0
|
|
|
|
/* Initial type ID for regular types. */
|
|
|
|
#define BTF_INIT_TYPEID 1
|
|
|
|
|
2021-05-21 02:15:52 +08:00
|
|
|
struct btf_type
|
|
|
|
{
|
|
|
|
uint32_t name_off; /* Offset in string section of type name. */
|
|
|
|
uint32_t info; /* Encoded kind, variant length, kind flag:
|
|
|
|
- bits 0-15: vlen
|
|
|
|
- bits 16-23: unused
|
2021-06-02 00:22:59 +08:00
|
|
|
- bits 24-28: kind
|
|
|
|
- bits 29-30: unused
|
2021-05-21 02:15:52 +08:00
|
|
|
- bit 31: kind_flag
|
|
|
|
See accessor macros below. */
|
|
|
|
|
|
|
|
/* SIZE is used by INT, ENUM, STRUCT, UNION, DATASEC kinds.
|
|
|
|
TYPE is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, FUNC,
|
|
|
|
FUNC_PROTO and VAR kinds. */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t size; /* Size of the entire type, in bytes. */
|
|
|
|
uint32_t type; /* A type_id referring to another type. */
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-29 22:42:48 +08:00
|
|
|
/* The following macros access the information encoded in btf_type.info. */
|
2021-05-21 02:15:52 +08:00
|
|
|
/* Type kind. See below. */
|
2021-06-02 00:22:59 +08:00
|
|
|
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
|
2021-05-21 02:15:52 +08:00
|
|
|
/* Number of entries of variable length data following certain type kinds.
|
|
|
|
For example, number of structure members, number of function parameters. */
|
|
|
|
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
|
|
|
|
/* For BTF_KIND_FWD, 1 if forward to union, 0 if forward to struct.
|
|
|
|
For BTF_KIND_STRUCT and BTF_KIND_UNION, 1 if the struct/union contains
|
|
|
|
a bitfield. */
|
|
|
|
#define BTF_INFO_KFLAG(info) ((info) >> 31)
|
|
|
|
|
|
|
|
/* Encoding for struct btf_type.info. */
|
|
|
|
#define BTF_TYPE_INFO(kind, kflag, vlen) \
|
2024-07-29 22:42:48 +08:00
|
|
|
((((kflag) ? 1 : 0 ) << 31) | ((kind & 0x1f) << 24) | ((vlen) & 0xffff))
|
2021-05-21 02:15:52 +08:00
|
|
|
|
|
|
|
#define BTF_KIND_UNKN 0 /* Unknown or invalid. */
|
|
|
|
#define BTF_KIND_INT 1 /* Integer. */
|
|
|
|
#define BTF_KIND_PTR 2 /* Pointer. */
|
|
|
|
#define BTF_KIND_ARRAY 3 /* Array. */
|
|
|
|
#define BTF_KIND_STRUCT 4 /* Struct. */
|
|
|
|
#define BTF_KIND_UNION 5 /* Union. */
|
|
|
|
#define BTF_KIND_ENUM 6 /* Enumeration. */
|
|
|
|
#define BTF_KIND_FWD 7 /* Forward. */
|
|
|
|
#define BTF_KIND_TYPEDEF 8 /* Typedef. */
|
|
|
|
#define BTF_KIND_VOLATILE 9 /* Referenced type is volatile. */
|
|
|
|
#define BTF_KIND_CONST 10 /* Referenced type is const. */
|
|
|
|
#define BTF_KIND_RESTRICT 11 /* Restrict. */
|
|
|
|
#define BTF_KIND_FUNC 12 /* Subprogram. */
|
|
|
|
#define BTF_KIND_FUNC_PROTO 13 /* Function Prototype. */
|
|
|
|
#define BTF_KIND_VAR 14 /* Variable. */
|
|
|
|
#define BTF_KIND_DATASEC 15 /* Section such as .bss or .data. */
|
2021-06-02 00:22:59 +08:00
|
|
|
#define BTF_KIND_FLOAT 16 /* Floating point. */
|
btf: Add support to BTF_KIND_ENUM64 type
BTF supports 64-bits enumerators with following encoding:
struct btf_type:
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
The btf_type is followed by info.vlen number of:
struct btf_enum64
{
uint32_t name_off; /* Offset in string section of enumerator name. */
uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */
uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */
};
So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64
and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish
when CTF enum is a signed or unsigned type, later that information is
used to encode the BTF enum type.
gcc/ChangeLog:
* btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of
enumerator type btf_enum{,64}.
(btf_asm_type): Update btf_kflag according to enumeration type sign
using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}.
(btf_asm_enum_const): New argument to represent the size of
the BTF enum type, writing the enumerator constant value for
32 bits, if it's 64 bits then explicitly writes lower 32-bits
value and higher 32-bits value.
(output_asm_btf_enum_list): Add enumeration size argument.
* ctfc.cc (ctf_add_enum): New argument to represent CTF enum
basic information.
(ctf_add_generic): Use of ei_{name. size, unsigned} to build the
dtd structure containing enumeration information.
(ctf_add_enumerator): Update comment mention support for BTF
enumeration in 64-bits.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness
for enumeration type and use it in ctf_add_enum.
* ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow
use 32/64 bits enumerators.
information.
(ctf_dtdef): New field to describe enum signedness.
include/
* btf.h (btf_enum64): Add new definition and new symbolic
constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct
info.kflags encoding.
* gcc.dg/debug/btf/btf-enum64-1.c: New testcase.
2022-11-01 00:32:50 +08:00
|
|
|
#define BTF_KIND_ENUM64 19 /* Enumeration up to 64 bits. */
|
|
|
|
#define BTF_KIND_MAX BTF_KIND_ENUM64
|
2021-05-21 02:15:52 +08:00
|
|
|
#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
|
|
|
|
|
|
|
|
/* For some BTF_KINDs, struct btf_type is immediately followed by
|
|
|
|
additional data describing the type. */
|
|
|
|
|
|
|
|
/* BTF_KIND_INT is followed by a 32-bit word, with the following
|
|
|
|
bit arrangement. */
|
|
|
|
#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
|
|
|
|
#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
|
|
|
|
#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
|
|
|
|
|
|
|
|
#define BTF_INT_DATA(encoding, offset, bits) \
|
|
|
|
((((encoding) & 0x0f) << 24) | (((offset) & 0xff) << 16) | ((bits) & 0xff))
|
|
|
|
|
|
|
|
/* BTF_INT_ENCODING holds the following attribute flags. */
|
|
|
|
#define BTF_INT_SIGNED (1 << 0)
|
|
|
|
#define BTF_INT_CHAR (1 << 1)
|
|
|
|
#define BTF_INT_BOOL (1 << 2)
|
|
|
|
|
|
|
|
/* BTF_KIND_ENUM is followed by VLEN struct btf_enum entries,
|
btf: Add support to BTF_KIND_ENUM64 type
BTF supports 64-bits enumerators with following encoding:
struct btf_type:
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
The btf_type is followed by info.vlen number of:
struct btf_enum64
{
uint32_t name_off; /* Offset in string section of enumerator name. */
uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */
uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */
};
So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64
and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish
when CTF enum is a signed or unsigned type, later that information is
used to encode the BTF enum type.
gcc/ChangeLog:
* btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of
enumerator type btf_enum{,64}.
(btf_asm_type): Update btf_kflag according to enumeration type sign
using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}.
(btf_asm_enum_const): New argument to represent the size of
the BTF enum type, writing the enumerator constant value for
32 bits, if it's 64 bits then explicitly writes lower 32-bits
value and higher 32-bits value.
(output_asm_btf_enum_list): Add enumeration size argument.
* ctfc.cc (ctf_add_enum): New argument to represent CTF enum
basic information.
(ctf_add_generic): Use of ei_{name. size, unsigned} to build the
dtd structure containing enumeration information.
(ctf_add_enumerator): Update comment mention support for BTF
enumeration in 64-bits.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness
for enumeration type and use it in ctf_add_enum.
* ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow
use 32/64 bits enumerators.
information.
(ctf_dtdef): New field to describe enum signedness.
include/
* btf.h (btf_enum64): Add new definition and new symbolic
constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct
info.kflags encoding.
* gcc.dg/debug/btf/btf-enum64-1.c: New testcase.
2022-11-01 00:32:50 +08:00
|
|
|
which describe the enumerators. */
|
2021-05-21 02:15:52 +08:00
|
|
|
struct btf_enum
|
|
|
|
{
|
|
|
|
uint32_t name_off; /* Offset in string section of enumerator name. */
|
|
|
|
int32_t val; /* Enumerator value. */
|
|
|
|
};
|
|
|
|
|
btf: Add support to BTF_KIND_ENUM64 type
BTF supports 64-bits enumerators with following encoding:
struct btf_type:
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
The btf_type is followed by info.vlen number of:
struct btf_enum64
{
uint32_t name_off; /* Offset in string section of enumerator name. */
uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */
uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */
};
So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64
and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish
when CTF enum is a signed or unsigned type, later that information is
used to encode the BTF enum type.
gcc/ChangeLog:
* btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of
enumerator type btf_enum{,64}.
(btf_asm_type): Update btf_kflag according to enumeration type sign
using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}.
(btf_asm_enum_const): New argument to represent the size of
the BTF enum type, writing the enumerator constant value for
32 bits, if it's 64 bits then explicitly writes lower 32-bits
value and higher 32-bits value.
(output_asm_btf_enum_list): Add enumeration size argument.
* ctfc.cc (ctf_add_enum): New argument to represent CTF enum
basic information.
(ctf_add_generic): Use of ei_{name. size, unsigned} to build the
dtd structure containing enumeration information.
(ctf_add_enumerator): Update comment mention support for BTF
enumeration in 64-bits.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness
for enumeration type and use it in ctf_add_enum.
* ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow
use 32/64 bits enumerators.
information.
(ctf_dtdef): New field to describe enum signedness.
include/
* btf.h (btf_enum64): Add new definition and new symbolic
constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct
info.kflags encoding.
* gcc.dg/debug/btf/btf-enum64-1.c: New testcase.
2022-11-01 00:32:50 +08:00
|
|
|
/* BTF_KF_ENUM_ holds the flags for kflags in BTF_KIND_ENUM{,64}. */
|
|
|
|
#define BTF_KF_ENUM_UNSIGNED (0)
|
|
|
|
#define BTF_KF_ENUM_SIGNED (1 << 0)
|
|
|
|
|
2021-05-21 02:15:52 +08:00
|
|
|
/* BTF_KIND_ARRAY is followed by a single struct btf_array. */
|
|
|
|
struct btf_array
|
|
|
|
{
|
|
|
|
uint32_t type; /* Type of array elements. */
|
|
|
|
uint32_t index_type; /* Type of array index. */
|
|
|
|
uint32_t nelems; /* Number of elements. 0 for unsized/variable length. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* BTF_KIND_STRUCT and BTF_KIND_UNION are followed by VLEN
|
|
|
|
struct btf_member. */
|
|
|
|
struct btf_member
|
|
|
|
{
|
|
|
|
uint32_t name_off; /* Offset in string section of member name. */
|
|
|
|
uint32_t type; /* Type of member. */
|
|
|
|
uint32_t offset; /* If the type info kind_flag is set, this contains
|
|
|
|
both the member bitfield size and bit offset,
|
|
|
|
according to the macros below. If kind_flag is not
|
|
|
|
set, offset contains only the bit offset (from the
|
|
|
|
beginning of the struct). */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* If struct or union type info kind_flag is set, used to access member
|
|
|
|
bitfield size from btf_member.offset. */
|
|
|
|
#define BTF_MEMBER_BITFIELD_SIZE (val) ((val) >> 24)
|
|
|
|
/* If struct or union type info kind_flag is set, used to access member
|
|
|
|
bit offset from btf_member.offset. */
|
|
|
|
#define BTF_MEMBER_BIT_OFFSET (val) ((val) & 0x00ffffff)
|
|
|
|
|
|
|
|
/* BTF_KIND_FUNC_PROTO is followed by VLEN struct btf_param entries, which
|
|
|
|
describe the types of the function parameters. */
|
|
|
|
struct btf_param
|
|
|
|
{
|
|
|
|
uint32_t name_off; /* Offset in string section of parameter name. */
|
|
|
|
uint32_t type; /* Type of parameter. */
|
|
|
|
};
|
|
|
|
|
2022-12-08 03:51:59 +08:00
|
|
|
/* BTF_KIND_FUNC records encode linkage information in the VLEN bits
|
|
|
|
of the type record. These are the supported values. */
|
|
|
|
enum btf_func_linkage
|
|
|
|
{
|
|
|
|
BTF_FUNC_STATIC = 0,
|
|
|
|
BTF_FUNC_GLOBAL = 1,
|
|
|
|
BTF_FUNC_EXTERN = 2,
|
|
|
|
};
|
|
|
|
|
2022-12-08 03:44:28 +08:00
|
|
|
/* BTF_KIND_VAR records encode linkage information in a single
|
|
|
|
trailing struct btf_var. These are the supported values. */
|
|
|
|
enum btf_var_linkage
|
|
|
|
{
|
|
|
|
BTF_VAR_STATIC = 0,
|
|
|
|
BTF_VAR_GLOBAL_ALLOCATED = 1,
|
|
|
|
BTF_VAR_GLOBAL_EXTERN = 2,
|
|
|
|
};
|
|
|
|
|
2021-05-21 02:15:52 +08:00
|
|
|
/* BTF_KIND_VAR is followed by a single struct btf_var, which describes
|
|
|
|
information about the variable. */
|
|
|
|
struct btf_var
|
|
|
|
{
|
2022-12-08 03:44:28 +08:00
|
|
|
uint32_t linkage; /* 0=static, 1=global, 2=extern. */
|
2021-05-21 02:15:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* BTF_KIND_DATASEC is followed by VLEN struct btf_var_secinfo entries,
|
2022-12-08 03:51:59 +08:00
|
|
|
which describe all BTF_KIND_VAR or extern BTF_KIND_FUNC types contained
|
|
|
|
in the section. */
|
2021-05-21 02:15:52 +08:00
|
|
|
struct btf_var_secinfo
|
|
|
|
{
|
2022-12-08 03:51:59 +08:00
|
|
|
uint32_t type; /* Type of BTF_KIND_VAR or BTF_KIND_FUNC item. */
|
|
|
|
uint32_t offset; /* In-section offset (in bytes) of item. */
|
|
|
|
uint32_t size; /* Size (in bytes) of item. */
|
2021-05-21 02:15:52 +08:00
|
|
|
};
|
|
|
|
|
btf: Add support to BTF_KIND_ENUM64 type
BTF supports 64-bits enumerators with following encoding:
struct btf_type:
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
The btf_type is followed by info.vlen number of:
struct btf_enum64
{
uint32_t name_off; /* Offset in string section of enumerator name. */
uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */
uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */
};
So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64
and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish
when CTF enum is a signed or unsigned type, later that information is
used to encode the BTF enum type.
gcc/ChangeLog:
* btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of
enumerator type btf_enum{,64}.
(btf_asm_type): Update btf_kflag according to enumeration type sign
using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}.
(btf_asm_enum_const): New argument to represent the size of
the BTF enum type, writing the enumerator constant value for
32 bits, if it's 64 bits then explicitly writes lower 32-bits
value and higher 32-bits value.
(output_asm_btf_enum_list): Add enumeration size argument.
* ctfc.cc (ctf_add_enum): New argument to represent CTF enum
basic information.
(ctf_add_generic): Use of ei_{name. size, unsigned} to build the
dtd structure containing enumeration information.
(ctf_add_enumerator): Update comment mention support for BTF
enumeration in 64-bits.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness
for enumeration type and use it in ctf_add_enum.
* ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow
use 32/64 bits enumerators.
information.
(ctf_dtdef): New field to describe enum signedness.
include/
* btf.h (btf_enum64): Add new definition and new symbolic
constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct
info.kflags encoding.
* gcc.dg/debug/btf/btf-enum64-1.c: New testcase.
2022-11-01 00:32:50 +08:00
|
|
|
/* BTF_KIND_ENUM64 is followed by VLEN struct btf_enum64 entries,
|
|
|
|
which describe the 64 bits enumerators. */
|
|
|
|
struct btf_enum64
|
|
|
|
{
|
|
|
|
uint32_t name_off; /* Offset in string section of enumerator name. */
|
|
|
|
uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */
|
|
|
|
uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */
|
|
|
|
};
|
|
|
|
|
2021-05-21 02:15:52 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _BTF_H_ */
|