GCC Middle and Back End API Reference
btfout.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "memmodel.h"
#include "tm_p.h"
#include "output.h"
#include "dwarf2asm.h"
#include "debug.h"
#include "ctfc.h"
#include "diagnostic-core.h"
#include "cgraph.h"
#include "varasm.h"
#include "stringpool.h"
#include "attribs.h"
#include "dwarf2out.h"
#include "gt-btfout.h"
Include dependency graph for btfout.cc:

Data Structures

struct  btf_datasec_entry
 
struct  btf_datasec
 
struct  btf_fixup
 

Macros

#define BTF_INFO_SECTION_NAME   ".BTF"
 
#define BTF_INFO_SECTION_FLAGS   (SECTION_DEBUG)
 
#define MAX_BTF_LABEL_BYTES   40
 
#define BTF_INFO_SECTION_LABEL   "Lbtf"
 
#define BTF_INVALID_TYPEID   0xFFFFFFFF
 

Typedefs

typedef struct btf_datasec btf_datasec_t
 

Functions

static const char * btf_kind_name (uint32_t btf_kind)
 
static uint32_t get_btf_kind (uint32_t ctf_kind)
 
static uint32_t btf_dtd_kind (ctf_dtdef_ref dtd)
 
static const char * get_btf_type_name (ctf_dtdef_ref dtd)
 
static bool btf_emit_type_p (ctf_dtdef_ref dtd)
 
static bool btf_fwd_to_enum_p (ctf_dtdef_ref dtd)
 
static uint64_t btf_calc_num_vbytes (ctf_dtdef_ref dtd)
 
void init_btf_sections (void)
 
static const char * get_section_name (symtab_node *node)
 
static bool btf_dmd_representable_bitfield_p (ctf_dmdef_t *dmd)
 
static void btf_asm_type_ref (const char *prefix, ctf_dtdef_ref dtd)
 
static void btf_asm_type (ctf_dtdef_ref dtd)
 
static void btf_asm_array (ctf_arinfo_t arr)
 
static void btf_asm_varent (ctf_dvdef_ref var)
 
static void btf_asm_sou_member (ctf_dmdef_t *dmd, unsigned int idx)
 
static void btf_asm_enum_const (unsigned int size, ctf_dmdef_t *dmd, unsigned int idx)
 
static void btf_asm_func_arg (ctf_func_arg_t *farg, size_t stroffset)
 
static void btf_asm_func_type (ctf_dtdef_ref dtd)
 
static void btf_asm_datasec_entry (struct btf_datasec_entry entry)
 
static void btf_asm_datasec_type (btf_datasec_t ds)
 
static void output_btf_header (ctf_container_ref ctfc)
 
static void output_btf_vars (ctf_container_ref ctfc)
 
static void output_btf_strs (ctf_container_ref ctfc)
 
static void output_asm_btf_sou_fields (ctf_dtdef_ref dtd)
 
static void output_asm_btf_enum_list (ctf_dtdef_ref dtd)
 
static void output_asm_btf_func_args_list (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
 
static void output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
 
static void output_asm_btf_type (ctf_container_ref ctfc, ctf_dtdef_ref type)
 
static void output_btf_types (ctf_container_ref ctfc)
 
static void output_btf_func_types (void)
 
static void output_btf_datasec_types (void)
 
void btf_output (ctf_container_ref ctfc)
 
static void btf_add_const_void (ctf_container_ref ctfc)
 
static void btf_add_func_records (ctf_container_ref ctfc)
 
static ctf_dtdef_ref btf_add_used_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, bool check_ptr, bool seen_ptr, bool create_fixups)
 
void btf_early_finish (void)
 
static void btf_datasec_push_entry (ctf_container_ref ctfc, const char *secname, struct btf_datasec_entry entry)
 
static void btf_datasec_add_func (ctf_container_ref ctfc, cgraph_node *func, ctf_dtdef_ref func_dtd)
 
static void btf_datasec_add_var (ctf_container_ref ctfc, varpool_node *var, ctf_dvdef_ref dvd)
 
static void btf_add_func_datasec_entries (ctf_container_ref ctfc)
 
static bool btf_emit_variable_p (ctf_container_ref ctfc, varpool_node *var, ctf_dvdef_ref *pdvd)
 
static void btf_add_vars (ctf_container_ref ctfc)
 
static int btf_type_list_cb (ctf_dtdef_ref *slot, ctf_container_ref ctfc)
 
static void btf_collect_translated_types (ctf_container_ref ctfc)
 
static void btf_assign_func_ids (ctf_container_ref ctfc)
 
static void btf_assign_var_ids (ctf_container_ref ctfc)
 
static void btf_assign_datasec_ids (ctf_container_ref ctfc)
 
void btf_mark_type_used (tree t)
 
static bool btf_used_type_list_cb (const ctf_dtdef_ref &dtd, ctf_container_ref ctfc)
 
static void btf_collect_pruned_types (ctf_container_ref ctfc)
 
void btf_finish (void)
 
void btf_finalize (void)
 
bool traverse_btf_func_types (funcs_traverse_callback callback, void *data)
 

Variables

static int btf_label_num
 
static sectionbtf_info_section
 
static char btf_info_section_label [MAX_BTF_LABEL_BYTES]
 
static vec< btf_datasec_tdatasecs
 
static vec< ctf_dtdef_ref, va_gc > * funcs
 
static hash_map< ctf_dtdef_ref, ctf_dtdef_ref > * func_map
 
static ctf_id_t max_translated_id = 0
 
static const char *const btf_kind_names []
 
static hash_set< ctf_dtdef_ref > * btf_used_types
 
static vec< struct btf_fixupfixups
 
static vec< ctf_dtdef_ref, va_gc > * forwards
 

Macro Definition Documentation

◆ BTF_INFO_SECTION_FLAGS

#define BTF_INFO_SECTION_FLAGS   (SECTION_DEBUG)

Referenced by init_btf_sections().

◆ BTF_INFO_SECTION_LABEL

#define BTF_INFO_SECTION_LABEL   "Lbtf"

Referenced by init_btf_sections().

◆ BTF_INFO_SECTION_NAME

#define BTF_INFO_SECTION_NAME   ".BTF"
BTF debug info section.   

Referenced by init_btf_sections().

◆ BTF_INVALID_TYPEID

#define BTF_INVALID_TYPEID   0xFFFFFFFF

◆ MAX_BTF_LABEL_BYTES

#define MAX_BTF_LABEL_BYTES   40
Maximum size (in bytes) for an artifically generated BTF label.   

Typedef Documentation

◆ btf_datasec_t

typedef struct btf_datasec btf_datasec_t
Internal representation of a BTF_KIND_DATASEC record.   

Function Documentation

◆ btf_add_const_void()

static void btf_add_const_void ( ctf_container_ref ctfc)
static
Workaround for 'const void' variables.  These variables are sometimes used
in eBPF programs to address kernel symbols.  DWARF does not generate const
qualifier on void type, so we would incorrectly emit these variables
without the const qualifier.  Find any such variables, and update them to
refer to a new 'const' modifier type for void.   

References ctf_add_reftype(), CTF_ADD_ROOT, ctf_dvd_lookup(), symtab_node::decl, ctf_dvdef::dvd_type, FOR_EACH_VARIABLE, lookup_decl_die(), NULL, TREE_TYPE, TYPE_READONLY, and VOID_TYPE_P.

Referenced by btf_early_finish().

◆ btf_add_func_datasec_entries()

static void btf_add_func_datasec_entries ( ctf_container_ref ctfc)
static

◆ btf_add_func_records()

static void btf_add_func_records ( ctf_container_ref ctfc)
static
Functions actually get two type records: a BTF_KIND_FUNC_PROTO, and also a
BTF_KIND_FUNC.  But the CTF container only allocates one type per function,
which matches closely with BTF_KIND_FUNC_PROTO.  For each such function,
construct a BTF_KIND_FUNC entry.  This is done early, because we want FUNC
records even for functions which are later inlined by optimizations.   

References ctf_dtd_lookup(), ctf_itype::ctti_name, symtab_node::decl, DECL_ATTRIBUTES, DECL_EXTERNAL, ctf_dtdef::dtd_data, ctf_dtdef::dtd_name, ctf_dtdef::dtd_type, FOR_EACH_FUNCTION, func_map, funcs, ggc_cleared_alloc(), ctf_dtdef::linkage, lookup_attribute(), lookup_decl_die(), NULL, NULL_TREE, ctf_dtdef::ref_type, and vec_safe_push().

Referenced by btf_early_finish().

◆ btf_add_used_type()

static ctf_dtdef_ref btf_add_used_type ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd,
bool check_ptr,
bool seen_ptr,
bool create_fixups )
static
Recursively add type DTD and any types it references to the used set.
Return a type that should be used for references to DTD - usually DTD itself,
but may be NULL if DTD corresponds to a type which will not be emitted.
CHECK_PTR is true if one of the predecessors in recursive calls is a struct
or union member.  SEEN_PTR is true if CHECK_PTR is true AND one of the
predecessors was a pointer type.  These two flags are used to avoid chasing
pointers to struct/union only used from pointer members.  For such types, we
will emit a forward instead of the full type information, unless
CREATE_FIXUPS is false.   

References btf_add_used_type(), btf_calc_num_vbytes(), btf_dtd_kind(), btf_used_types, ctf_add_string(), ctf_dmd_list_next, ctf_farg_list_next, CTF_STRTAB, ctf_arinfo::ctr_contents, ctf_arinfo::ctr_index, ctf_dmdef::dmd_name, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_type, ctf_func_arg::farg_type, fixups, gcc_assert, gcc_unreachable, get_btf_kind(), i, NULL, and ctf_dtdef::ref_type.

Referenced by btf_add_used_type(), btf_add_vars(), btf_collect_pruned_types(), and btf_mark_type_used().

◆ btf_add_vars()

◆ btf_asm_array()

static void btf_asm_array ( ctf_arinfo_t arr)
static
Asm'out the variable information following a BTF_KIND_ARRAY.   

References btf_asm_type_ref(), ctf_arinfo::ctr_contents, ctf_arinfo::ctr_index, ctf_arinfo::ctr_nelems, and dw2_asm_output_data().

Referenced by output_asm_btf_vlen_bytes().

◆ btf_asm_datasec_entry()

◆ btf_asm_datasec_type()

static void btf_asm_datasec_type ( btf_datasec_t ds)
static
Asm'out a whole BTF_KIND_DATASEC, including its variable entries.   

References btf_asm_datasec_entry(), dw2_asm_output_data(), btf_datasec::entries, i, btf_datasec::id, btf_datasec::name, btf_datasec::name_offset, and PRIu64.

Referenced by output_btf_datasec_types().

◆ btf_asm_enum_const()

static void btf_asm_enum_const ( unsigned int size,
ctf_dmdef_t * dmd,
unsigned int idx )
static
Asm'out an enum constant following a BTF_KIND_ENUM{,64}.   

References ctf_dmdef::dmd_name, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_value, and dw2_asm_output_data().

Referenced by output_asm_btf_enum_list().

◆ btf_asm_func_arg()

static void btf_asm_func_arg ( ctf_func_arg_t * farg,
size_t stroffset )
static
Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO.   

References btf_asm_type_ref(), dw2_asm_output_data(), ctf_func_arg::farg_name, ctf_func_arg::farg_name_offset, ctf_func_arg::farg_type, and NULL.

Referenced by output_asm_btf_func_args_list().

◆ btf_asm_func_type()

◆ btf_asm_sou_member()

◆ btf_asm_type()

◆ btf_asm_type_ref()

static void btf_asm_type_ref ( const char * prefix,
ctf_dtdef_ref dtd )
static

◆ btf_asm_varent()

◆ btf_assign_datasec_ids()

static void btf_assign_datasec_ids ( ctf_container_ref ctfc)
static
Assign BTF IDs for datasec records and account for their size.   

References CTF_STRTAB, ctfc_get_strtab_len(), ctf_container::ctfc_nextid, ctf_container::ctfc_num_types, ctf_container::ctfc_num_vlen_bytes, datasecs, and i.

Referenced by btf_finish().

◆ btf_assign_func_ids()

static void btf_assign_func_ids ( ctf_container_ref ctfc)
static
Assign BTF IDs for FUNC records and account for their size.   

References ctf_container::ctfc_nextid, ctf_container::ctfc_num_types, btf_datasec_entry::dtd, ctf_dtdef::dtd_type, FOR_EACH_VEC_ELT, funcs, and i.

Referenced by btf_finish().

◆ btf_assign_var_ids()

◆ btf_calc_num_vbytes()

static uint64_t btf_calc_num_vbytes ( ctf_dtdef_ref dtd)
static
Each BTF type can be followed additional, variable-length information
completing the description of the type. Calculate the number of bytes
of variable information required to encode a given type.   

References btf_dtd_kind(), ctf_itype::ctti_info, and ctf_dtdef::dtd_data.

Referenced by btf_add_used_type(), btf_collect_pruned_types(), and btf_collect_translated_types().

◆ btf_collect_pruned_types()

◆ btf_collect_translated_types()

◆ btf_datasec_add_func()

static void btf_datasec_add_func ( ctf_container_ref ctfc,
cgraph_node * func,
ctf_dtdef_ref func_dtd )
static
Create a datasec entry for a function, and insert it into the datasec
record for the appropriate section.  Create the record if it does not
yet exist.   

References btf_datasec_push_entry(), btf_datasec_entry::dtd, gcc_assert, get_section_name(), btf_datasec_entry::is_var, NULL, and btf_datasec_entry::size.

Referenced by btf_add_func_datasec_entries().

◆ btf_datasec_add_var()

static void btf_datasec_add_var ( ctf_container_ref ctfc,
varpool_node * var,
ctf_dvdef_ref dvd )
static
Create a datasec entry for a variable, and insert it into the datasec
record for the appropriate section.  Create the record if it does not
yet exist.   

References btf_datasec_push_entry(), symtab_node::decl, DECL_EXTERNAL, DECL_SIZE_UNIT, btf_datasec_entry::dvd, gcc_assert, symtab_node::get_section(), get_section_name(), btf_datasec_entry::is_var, NULL, btf_datasec_entry::size, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, and VOID_TYPE_P.

Referenced by btf_add_vars().

◆ btf_datasec_push_entry()

static void btf_datasec_push_entry ( ctf_container_ref ctfc,
const char * secname,
struct btf_datasec_entry entry )
static
Push a BTF datasec entry ENTRY into the datasec named SECNAME,
creating the datasec record if it does not already exist.   

References ctf_add_string(), CTF_AUX_STRTAB, ctf_container::ctfc_aux_strlen, datasecs, btf_datasec::entries, i, btf_datasec::name, btf_datasec::name_offset, and NULL.

Referenced by btf_datasec_add_func(), and btf_datasec_add_var().

◆ btf_dmd_representable_bitfield_p()

static bool btf_dmd_representable_bitfield_p ( ctf_dmdef_t * dmd)
static
Return true iff DMD is a member description of a bit-field which can be
validly represented in BTF.   

References ctf_sliceinfo::cts_bits, ctf_sliceinfo::cts_offset, ctf_itype::ctti_info, ctf_dmdef::dmd_offset, ctf_dmdef::dmd_type, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, and ctf_dtdef::dtu_slice.

Referenced by btf_asm_sou_member(), and btf_asm_type().

◆ btf_dtd_kind()

static uint32_t btf_dtd_kind ( ctf_dtdef_ref dtd)
static

◆ btf_early_finish()

◆ btf_emit_type_p()

◆ btf_emit_variable_p()

static bool btf_emit_variable_p ( ctf_container_ref ctfc,
varpool_node * var,
ctf_dvdef_ref * pdvd )
static
Helper function used to determine whether or not a BTF_KIND_VAR record
for the variable VAR shall be emitted.   

References btf_emit_type_p(), ctf_dvd_ignore_lookup(), ctf_dvd_lookup(), symtab_node::decl, btf_datasec_entry::dvd, ctf_dvdef::dvd_key, ctf_dvdef::dvd_type, lookup_decl_die(), and NULL.

Referenced by btf_add_vars().

◆ btf_finalize()

void btf_finalize ( void )
Reset all state for BTF generation so that we can rerun the compiler within
the same process.   

References btf_info_section, btf_used_types, ctf_get_tu_ctfc(), ctfc_delete_container(), datasecs, fixups, forwards, func_map, funcs, i, max_translated_id, NULL, and tu_ctfc.

Referenced by btf_finish().

◆ btf_finish()

◆ btf_fwd_to_enum_p()

static bool btf_fwd_to_enum_p ( ctf_dtdef_ref dtd)
static
Return true if DTD is a forward-declared enum.  The BTF representation
of forward declared enums is not formally defined.   

References btf_dtd_kind(), and ctf_dtdef::dtd_data.

Referenced by btf_asm_type_ref().

◆ btf_kind_name()

static const char * btf_kind_name ( uint32_t btf_kind)
static
Return a name string for the given BTF_KIND.   

References btf_kind_names.

Referenced by btf_asm_type(), and btf_asm_type_ref().

◆ btf_mark_type_used()

void btf_mark_type_used ( tree t)
Manually mark that type T is used to ensure it will not be pruned.
Used by the BPF backend when generating BPF CO-RE to mark types used
in CO-RE relocations.   

References btf_add_used_type(), ctf_get_tu_ctfc(), ctf_lookup_tree_type(), gcc_assert, and TYPE_P.

◆ btf_output()

◆ btf_type_list_cb()

static int btf_type_list_cb ( ctf_dtdef_ref * slot,
ctf_container_ref ctfc )
static
Callback used by btf_assign_type_ids to insert types into their initial
positions in the type list.   

References ctf_container::ctfc_types_list, btf_datasec_entry::dtd, and ctf_dtdef::dtd_type.

Referenced by btf_collect_translated_types().

◆ btf_used_type_list_cb()

static bool btf_used_type_list_cb ( const ctf_dtdef_ref & dtd,
ctf_container_ref ctfc )
static
Callback used for assembling the only-used-types list.  Note that this is
the same as btf_type_list_cb above, but the hash_set traverse requires a
different function signature.   

References ctf_container::ctfc_types_list, and ctf_dtdef::dtd_type.

Referenced by btf_collect_pruned_types().

◆ get_btf_kind()

static uint32_t get_btf_kind ( uint32_t ctf_kind)
static
Map a CTF type kind to the corresponding BTF type kind.   

Referenced by btf_add_used_type(), and btf_dtd_kind().

◆ get_btf_type_name()

static const char * get_btf_type_name ( ctf_dtdef_ref dtd)
static
Some BTF types, like BTF_KIND_FUNC_PROTO, are anonymous.  The machinery
in btfout to emit BTF, may reset dtd_data->ctti_name, but does not update
the name in the ctf_dtdef_ref type object (deliberate choice).  This
interface helps abstract out that state of affairs, while giving access to
the name of the type as intended.   

References ctf_itype::ctti_name, ctf_dtdef::dtd_data, and ctf_dtdef::dtd_name.

Referenced by btf_asm_func_type(), btf_asm_type(), and btf_asm_type_ref().

◆ get_section_name()

static const char * get_section_name ( symtab_node * node)
static
Return the section name, as of interest to btf_collect_datasec, for the
given symtab node.  Note that this deliberately returns NULL for objects
which do not go in a section btf_collect_datasec cares about.   

References categorize_decl_for_section(), symtab_node::decl, symtab_node::get_section(), NULL, SECCAT_BSS, SECCAT_DATA, and SECCAT_RODATA.

Referenced by btf_datasec_add_func(), and btf_datasec_add_var().

◆ init_btf_sections()

void init_btf_sections ( void )

◆ output_asm_btf_enum_list()

static void output_asm_btf_enum_list ( ctf_dtdef_ref dtd)
static
Output all enumerator constants following a BTF_KIND_ENUM{,64}.   

References btf_asm_enum_const(), ctf_dmd_list_next, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_members, and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_func_args_list()

static void output_asm_btf_func_args_list ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
static
Output all function arguments following a BTF_KIND_FUNC_PROTO.   

References btf_asm_func_arg(), ctf_farg_list_next, CTF_STRTAB, ctfc_get_strtab_len(), ctf_dtdef::dtd_u, ctf_dtdef::dtu_argv, and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_sou_fields()

static void output_asm_btf_sou_fields ( ctf_dtdef_ref dtd)
static
Output all (representable) members of a BTF_KIND_STRUCT or
BTF_KIND_UNION type.   

References btf_asm_sou_member(), ctf_dmd_list_next, ctf_dtdef::dtd_u, ctf_dtdef::dtu_members, and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_type()

static void output_asm_btf_type ( ctf_container_ref ctfc,
ctf_dtdef_ref type )
static
Output a whole BTF type record for TYPE, including the fixed and variable
data portions.   

References btf_asm_type(), btf_emit_type_p(), and output_asm_btf_vlen_bytes().

Referenced by output_btf_types().

◆ output_asm_btf_vlen_bytes()

◆ output_btf_datasec_types()

static void output_btf_datasec_types ( void )
static
Output all BTF_KIND_DATASEC records.   

References btf_asm_datasec_type(), datasecs, and i.

Referenced by btf_output().

◆ output_btf_func_types()

static void output_btf_func_types ( void )
static
Output all BTF_KIND_FUNC type records.   

References btf_asm_func_type(), FOR_EACH_VEC_ELT, funcs, and i.

Referenced by btf_output().

◆ output_btf_header()

static void output_btf_header ( ctf_container_ref ctfc)
static

◆ output_btf_strs()

static void output_btf_strs ( ctf_container_ref ctfc)
static
Output BTF string records. The BTF strings section is a concatenation
of the standard and auxilliary string tables in the ctf container.   

References ctf_container::ctfc_aux_strtable, ctf_container::ctfc_strtable, ctf_string::cts_next, ctf_string::cts_str, ctf_strtable::ctstab_head, and dw2_asm_output_nstring().

Referenced by btf_output().

◆ output_btf_types()

static void output_btf_types ( ctf_container_ref ctfc)
static
Output all BTF types in the container. This does not include synthesized
types: BTF_KIND_VAR, BTF_KIND_FUNC, nor BTF_KIND_DATASEC.   

References ctf_container::ctfc_types, ctf_container::ctfc_types_list, hash_table< Descriptor, Lazy, Allocator >::elements(), i, max_translated_id, and output_asm_btf_type().

Referenced by btf_output().

◆ output_btf_vars()

static void output_btf_vars ( ctf_container_ref ctfc)
static
Output all BTF_KIND_VARs in CTFC.   

References btf_asm_varent(), ctf_container::ctfc_vars_list, ctf_container::ctfc_vars_list_count, and i.

Referenced by btf_output().

◆ traverse_btf_func_types()

bool traverse_btf_func_types ( funcs_traverse_callback callback,
void * data )
Traversal function for all BTF_KIND_FUNC type records.   

References FOR_EACH_VEC_ELT, funcs, and i.

Variable Documentation

◆ btf_info_section

section* btf_info_section
static

◆ btf_info_section_label

char btf_info_section_label[MAX_BTF_LABEL_BYTES]
static

◆ btf_kind_names

const char* const btf_kind_names[]
static
Initial value:
=
{
"UNKN", "INT", "PTR", "ARRAY", "STRUCT", "UNION", "ENUM", "FWD",
"TYPEDEF", "VOLATILE", "CONST", "RESTRICT", "FUNC", "FUNC_PROTO",
"VAR", "DATASEC", "FLOAT", "DECL_TAG", "TYPE_TAG", "ENUM64"
}
Name strings for BTF kinds.
Note: the indices here must match the type defines in btf.h.   

Referenced by btf_kind_name().

◆ btf_label_num

int btf_label_num
static
Output BTF format from GCC.
   Copyright (C) 2021-2024 Free Software Foundation, Inc.

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 contains routines to output the BPF Type Format (BTF). The BTF
debug format is very similar to CTF; as a result, the structure of this file
closely resembles that of ctfout.cc, and the same CTF container objects are
used.   

Referenced by init_btf_sections().

◆ btf_used_types

hash_set<ctf_dtdef_ref>* btf_used_types
static
The set of types used directly in the source program, and any types manually
marked as used.  This is the set of types which will be emitted when
flag_prune_btf is set.   

Referenced by btf_add_used_type(), btf_collect_pruned_types(), btf_early_finish(), and btf_finalize().

◆ datasecs

vec<btf_datasec_t> datasecs
static
One BTF_KIND_DATASEC record is created for each output data section which
will hold at least one variable.   

Referenced by btf_assign_datasec_ids(), btf_datasec_push_entry(), btf_finalize(), btf_finish(), and output_btf_datasec_types().

◆ fixups

vec<struct btf_fixup> fixups
static
Stores fixups while processing types.   

Referenced by btf_add_used_type(), btf_collect_pruned_types(), btf_early_finish(), and btf_finalize().

◆ forwards

vec<ctf_dtdef_ref, va_gc>* forwards
static
For fixups where the underlying type is not used in the end, a BTF_KIND_FWD
is created and emitted.  This vector stores them.   

Referenced by btf_collect_pruned_types(), and btf_finalize().

◆ func_map

hash_map<ctf_dtdef_ref, ctf_dtdef_ref>* func_map
static
Maps BTF_KIND_FUNC_PROTO to the BTF_KIND_FUNC record for it.  Used when
creating DATASEC entries.   

Referenced by btf_add_func_datasec_entries(), btf_add_func_records(), btf_early_finish(), and btf_finalize().

◆ funcs

vec<ctf_dtdef_ref, va_gc>* funcs
static
Functions in BTF have two separate type records - one for the prototype
(BTF_KIND_FUNC_PROTO), as well as a BTF_KIND_FUNC. CTF_K_FUNCTION types
map closely to BTF_KIND_FUNC_PROTO, but the BTF_KIND_FUNC records must be
created. This vector holds them.   

Referenced by btf_add_func_records(), btf_assign_func_ids(), btf_collect_pruned_types(), btf_early_finish(), btf_finalize(), output_btf_func_types(), and traverse_btf_func_types().

◆ max_translated_id

ctf_id_t max_translated_id = 0
static
Highest BTF ID assigned to any regular type translated from CTF.
Does not include BTF_KIND_{VAR,FUNC,DATASEC} types.   

Referenced by btf_asm_type_ref(), btf_collect_pruned_types(), btf_collect_translated_types(), btf_finalize(), and output_btf_types().