| 1 |
/* btfext-out.h - Declarations and definitions related to |
| 2 |
BPF Compile Once - Run Everywhere (CO-RE) support. |
| 3 |
Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it |
| 8 |
under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3, or (at your option) |
| 10 |
any later version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but |
| 13 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with GCC; see the file COPYING3. If not see |
| 19 |
<http://www.gnu.org/licenses/>. */ |
| 20 |
|
| 21 |
|
| 22 |
#ifndef __COREOUT_H |
| 23 |
#define __COREOUT_H |
| 24 |
|
| 25 |
#include <stdint.h> |
| 26 |
#include "ctfc.h" |
| 27 |
|
| 28 |
#ifdef __cplusplus |
| 29 |
extern "C" |
| 30 |
{ |
| 31 |
#endif |
| 32 |
|
| 33 |
/* .BTF.ext information. */ |
| 34 |
|
| 35 |
struct btf_ext_section_header |
| 36 |
{ |
| 37 |
uint32_t sec_name_off; |
| 38 |
uint32_t num_records; |
| 39 |
}; |
| 40 |
|
| 41 |
enum btf_core_reloc_kind |
| 42 |
{ |
| 43 |
BPF_RELO_INVALID = -1, |
| 44 |
BPF_RELO_FIELD_BYTE_OFFSET = 0, |
| 45 |
BPF_RELO_FIELD_BYTE_SIZE = 1, |
| 46 |
BPF_RELO_FIELD_EXISTS = 2, |
| 47 |
BPF_RELO_FIELD_SIGNED = 3, |
| 48 |
BPF_RELO_FIELD_LSHIFT_U64 = 4, |
| 49 |
BPF_RELO_FIELD_RSHIFT_U64 = 5, |
| 50 |
BPF_RELO_TYPE_ID_LOCAL = 6, |
| 51 |
BPF_RELO_TYPE_ID_TARGET = 7, |
| 52 |
BPF_RELO_TYPE_EXISTS = 8, |
| 53 |
BPF_RELO_TYPE_SIZE = 9, |
| 54 |
BPF_RELO_ENUMVAL_EXISTS = 10, |
| 55 |
BPF_RELO_ENUMVAL_VALUE = 11, |
| 56 |
BPF_RELO_TYPE_MATCHES = 12 |
| 57 |
}; |
| 58 |
|
| 59 |
struct btf_ext_reloc |
| 60 |
{ |
| 61 |
uint32_t insn_off; /* Offset of instruction to be patched. A |
| 62 |
section-relative label at compile time. */ |
| 63 |
uint32_t type_id; /* Type ID of the outermost containing entity, e.g. |
| 64 |
the containing structure. */ |
| 65 |
uint32_t access_str_off; /* Offset of CO-RE accessor string in .BTF strings |
| 66 |
section. */ |
| 67 |
uint32_t kind; /* An enum btf_core_reloc_kind. Note that it always |
| 68 |
takes 32 bits. */ |
| 69 |
}; |
| 70 |
|
| 71 |
struct btf_ext_header |
| 72 |
{ |
| 73 |
uint16_t magic; /* Magic number (BTF_MAGIC). */ |
| 74 |
uint8_t version; /* Data format version (BTF_VERSION). */ |
| 75 |
uint8_t flags; /* Flags. Currently unused. */ |
| 76 |
uint32_t hdr_len; /* Length of this header in bytes. */ |
| 77 |
|
| 78 |
/* Following offsets are relative to the end of this header, in bytes. |
| 79 |
Following lengths are in bytes. */ |
| 80 |
uint32_t func_info_off; /* Offset of funcinfo section. */ |
| 81 |
uint32_t func_info_len; /* Length of funcinfo section. */ |
| 82 |
uint32_t line_info_off; /* Offset of lineinfo section. */ |
| 83 |
uint32_t line_info_len; /* Length of lineinfo section. */ |
| 84 |
|
| 85 |
uint32_t core_relo_off; /* Offset of CO-RE relocation section. */ |
| 86 |
uint32_t core_relo_len; /* Length of CO-RE relocation section. */ |
| 87 |
}; |
| 88 |
|
| 89 |
extern void btf_ext_init (void); |
| 90 |
extern void btf_ext_output (void); |
| 91 |
|
| 92 |
void |
| 93 |
bpf_core_reloc_add (const tree type, const char * section_name, |
| 94 |
const char *accessor, |
| 95 |
rtx_code_label *label, |
| 96 |
enum btf_core_reloc_kind kind); |
| 97 |
|
| 98 |
extern int bpf_core_get_sou_member_index (ctf_container_ref, const tree); |
| 99 |
|
| 100 |
struct btf_ext_funcinfo *btf_add_func_info_for (tree decl, |
| 101 |
const char *label); |
| 102 |
unsigned int btf_ext_add_string (const char *str); |
| 103 |
|
| 104 |
#ifdef __cplusplus |
| 105 |
} |
| 106 |
#endif |
| 107 |
|
| 108 |
#endif /* __COREOUT_H */ |