18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci/* 48c2ecf20Sopenharmony_ci * Internal libbpf helpers. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (c) 2019 Facebook 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __LIBBPF_LIBBPF_INTERNAL_H 108c2ecf20Sopenharmony_ci#define __LIBBPF_LIBBPF_INTERNAL_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <stdlib.h> 138c2ecf20Sopenharmony_ci#include <limits.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* make sure libbpf doesn't use kernel-only integer typedefs */ 168c2ecf20Sopenharmony_ci#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* prevent accidental re-addition of reallocarray() */ 198c2ecf20Sopenharmony_ci#pragma GCC poison reallocarray 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "libbpf.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define BTF_INFO_ENC(kind, kind_flag, vlen) \ 248c2ecf20Sopenharmony_ci ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN)) 258c2ecf20Sopenharmony_ci#define BTF_TYPE_ENC(name, info, size_or_type) (name), (info), (size_or_type) 268c2ecf20Sopenharmony_ci#define BTF_INT_ENC(encoding, bits_offset, nr_bits) \ 278c2ecf20Sopenharmony_ci ((encoding) << 24 | (bits_offset) << 16 | (nr_bits)) 288c2ecf20Sopenharmony_ci#define BTF_TYPE_INT_ENC(name, encoding, bits_offset, bits, sz) \ 298c2ecf20Sopenharmony_ci BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_INT, 0, 0), sz), \ 308c2ecf20Sopenharmony_ci BTF_INT_ENC(encoding, bits_offset, bits) 318c2ecf20Sopenharmony_ci#define BTF_MEMBER_ENC(name, type, bits_offset) (name), (type), (bits_offset) 328c2ecf20Sopenharmony_ci#define BTF_PARAM_ENC(name, type) (name), (type) 338c2ecf20Sopenharmony_ci#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifndef likely 368c2ecf20Sopenharmony_ci#define likely(x) __builtin_expect(!!(x), 1) 378c2ecf20Sopenharmony_ci#endif 388c2ecf20Sopenharmony_ci#ifndef unlikely 398c2ecf20Sopenharmony_ci#define unlikely(x) __builtin_expect(!!(x), 0) 408c2ecf20Sopenharmony_ci#endif 418c2ecf20Sopenharmony_ci#ifndef min 428c2ecf20Sopenharmony_ci# define min(x, y) ((x) < (y) ? (x) : (y)) 438c2ecf20Sopenharmony_ci#endif 448c2ecf20Sopenharmony_ci#ifndef max 458c2ecf20Sopenharmony_ci# define max(x, y) ((x) < (y) ? (y) : (x)) 468c2ecf20Sopenharmony_ci#endif 478c2ecf20Sopenharmony_ci#ifndef offsetofend 488c2ecf20Sopenharmony_ci# define offsetofend(TYPE, FIELD) \ 498c2ecf20Sopenharmony_ci (offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD)) 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* Symbol versioning is different between static and shared library. 538c2ecf20Sopenharmony_ci * Properly versioned symbols are needed for shared library, but 548c2ecf20Sopenharmony_ci * only the symbol of the new version is needed for static library. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#ifdef SHARED 578c2ecf20Sopenharmony_ci# define COMPAT_VERSION(internal_name, api_name, version) \ 588c2ecf20Sopenharmony_ci asm(".symver " #internal_name "," #api_name "@" #version); 598c2ecf20Sopenharmony_ci# define DEFAULT_VERSION(internal_name, api_name, version) \ 608c2ecf20Sopenharmony_ci asm(".symver " #internal_name "," #api_name "@@" #version); 618c2ecf20Sopenharmony_ci#else 628c2ecf20Sopenharmony_ci# define COMPAT_VERSION(internal_name, api_name, version) 638c2ecf20Sopenharmony_ci# define DEFAULT_VERSION(internal_name, api_name, version) \ 648c2ecf20Sopenharmony_ci extern typeof(internal_name) api_name \ 658c2ecf20Sopenharmony_ci __attribute__((alias(#internal_name))); 668c2ecf20Sopenharmony_ci#endif 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciextern void libbpf_print(enum libbpf_print_level level, 698c2ecf20Sopenharmony_ci const char *format, ...) 708c2ecf20Sopenharmony_ci __attribute__((format(printf, 2, 3))); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define __pr(level, fmt, ...) \ 738c2ecf20Sopenharmony_cido { \ 748c2ecf20Sopenharmony_ci libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ 758c2ecf20Sopenharmony_ci} while (0) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__) 788c2ecf20Sopenharmony_ci#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__) 798c2ecf20Sopenharmony_ci#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#ifndef __has_builtin 828c2ecf20Sopenharmony_ci#define __has_builtin(x) 0 838c2ecf20Sopenharmony_ci#endif 848c2ecf20Sopenharmony_ci/* 858c2ecf20Sopenharmony_ci * Re-implement glibc's reallocarray() for libbpf internal-only use. 868c2ecf20Sopenharmony_ci * reallocarray(), unfortunately, is not available in all versions of glibc, 878c2ecf20Sopenharmony_ci * so requires extra feature detection and using reallocarray() stub from 888c2ecf20Sopenharmony_ci * <tools/libc_compat.h> and COMPAT_NEED_REALLOCARRAY. All this complicates 898c2ecf20Sopenharmony_ci * build of libbpf unnecessarily and is just a maintenance burden. Instead, 908c2ecf20Sopenharmony_ci * it's trivial to implement libbpf-specific internal version and use it 918c2ecf20Sopenharmony_ci * throughout libbpf. 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_cistatic inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci size_t total; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#if __has_builtin(__builtin_mul_overflow) 988c2ecf20Sopenharmony_ci if (unlikely(__builtin_mul_overflow(nmemb, size, &total))) 998c2ecf20Sopenharmony_ci return NULL; 1008c2ecf20Sopenharmony_ci#else 1018c2ecf20Sopenharmony_ci if (size == 0 || nmemb > ULONG_MAX / size) 1028c2ecf20Sopenharmony_ci return NULL; 1038c2ecf20Sopenharmony_ci total = nmemb * size; 1048c2ecf20Sopenharmony_ci#endif 1058c2ecf20Sopenharmony_ci return realloc(ptr, total); 1068c2ecf20Sopenharmony_ci} 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_civoid *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, 1098c2ecf20Sopenharmony_ci size_t cur_cnt, size_t max_cnt, size_t add_cnt); 1108c2ecf20Sopenharmony_ciint btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistatic inline bool libbpf_validate_opts(const char *opts, 1138c2ecf20Sopenharmony_ci size_t opts_sz, size_t user_sz, 1148c2ecf20Sopenharmony_ci const char *type_name) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci if (user_sz < sizeof(size_t)) { 1178c2ecf20Sopenharmony_ci pr_warn("%s size (%zu) is too small\n", type_name, user_sz); 1188c2ecf20Sopenharmony_ci return false; 1198c2ecf20Sopenharmony_ci } 1208c2ecf20Sopenharmony_ci if (user_sz > opts_sz) { 1218c2ecf20Sopenharmony_ci size_t i; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci for (i = opts_sz; i < user_sz; i++) { 1248c2ecf20Sopenharmony_ci if (opts[i]) { 1258c2ecf20Sopenharmony_ci pr_warn("%s has non-zero extra bytes\n", 1268c2ecf20Sopenharmony_ci type_name); 1278c2ecf20Sopenharmony_ci return false; 1288c2ecf20Sopenharmony_ci } 1298c2ecf20Sopenharmony_ci } 1308c2ecf20Sopenharmony_ci } 1318c2ecf20Sopenharmony_ci return true; 1328c2ecf20Sopenharmony_ci} 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define OPTS_VALID(opts, type) \ 1358c2ecf20Sopenharmony_ci (!(opts) || libbpf_validate_opts((const char *)opts, \ 1368c2ecf20Sopenharmony_ci offsetofend(struct type, \ 1378c2ecf20Sopenharmony_ci type##__last_field), \ 1388c2ecf20Sopenharmony_ci (opts)->sz, #type)) 1398c2ecf20Sopenharmony_ci#define OPTS_HAS(opts, field) \ 1408c2ecf20Sopenharmony_ci ((opts) && opts->sz >= offsetofend(typeof(*(opts)), field)) 1418c2ecf20Sopenharmony_ci#define OPTS_GET(opts, field, fallback_value) \ 1428c2ecf20Sopenharmony_ci (OPTS_HAS(opts, field) ? (opts)->field : fallback_value) 1438c2ecf20Sopenharmony_ci#define OPTS_SET(opts, field, value) \ 1448c2ecf20Sopenharmony_ci do { \ 1458c2ecf20Sopenharmony_ci if (OPTS_HAS(opts, field)) \ 1468c2ecf20Sopenharmony_ci (opts)->field = value; \ 1478c2ecf20Sopenharmony_ci } while (0) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ciint parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz); 1508c2ecf20Sopenharmony_ciint parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz); 1518c2ecf20Sopenharmony_ciint libbpf__load_raw_btf(const char *raw_types, size_t types_len, 1528c2ecf20Sopenharmony_ci const char *str_sec, size_t str_len); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ciint bpf_object__section_size(const struct bpf_object *obj, const char *name, 1558c2ecf20Sopenharmony_ci __u32 *size); 1568c2ecf20Sopenharmony_ciint bpf_object__variable_offset(const struct bpf_object *obj, const char *name, 1578c2ecf20Sopenharmony_ci __u32 *off); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistruct btf_ext_info { 1608c2ecf20Sopenharmony_ci /* 1618c2ecf20Sopenharmony_ci * info points to the individual info section (e.g. func_info and 1628c2ecf20Sopenharmony_ci * line_info) from the .BTF.ext. It does not include the __u32 rec_size. 1638c2ecf20Sopenharmony_ci */ 1648c2ecf20Sopenharmony_ci void *info; 1658c2ecf20Sopenharmony_ci __u32 rec_size; 1668c2ecf20Sopenharmony_ci __u32 len; 1678c2ecf20Sopenharmony_ci}; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define for_each_btf_ext_sec(seg, sec) \ 1708c2ecf20Sopenharmony_ci for (sec = (seg)->info; \ 1718c2ecf20Sopenharmony_ci (void *)sec < (seg)->info + (seg)->len; \ 1728c2ecf20Sopenharmony_ci sec = (void *)sec + sizeof(struct btf_ext_info_sec) + \ 1738c2ecf20Sopenharmony_ci (seg)->rec_size * sec->num_info) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci#define for_each_btf_ext_rec(seg, sec, i, rec) \ 1768c2ecf20Sopenharmony_ci for (i = 0, rec = (void *)&(sec)->data; \ 1778c2ecf20Sopenharmony_ci i < (sec)->num_info; \ 1788c2ecf20Sopenharmony_ci i++, rec = (void *)rec + (seg)->rec_size) 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci/* 1818c2ecf20Sopenharmony_ci * The .BTF.ext ELF section layout defined as 1828c2ecf20Sopenharmony_ci * struct btf_ext_header 1838c2ecf20Sopenharmony_ci * func_info subsection 1848c2ecf20Sopenharmony_ci * 1858c2ecf20Sopenharmony_ci * The func_info subsection layout: 1868c2ecf20Sopenharmony_ci * record size for struct bpf_func_info in the func_info subsection 1878c2ecf20Sopenharmony_ci * struct btf_sec_func_info for section #1 1888c2ecf20Sopenharmony_ci * a list of bpf_func_info records for section #1 1898c2ecf20Sopenharmony_ci * where struct bpf_func_info mimics one in include/uapi/linux/bpf.h 1908c2ecf20Sopenharmony_ci * but may not be identical 1918c2ecf20Sopenharmony_ci * struct btf_sec_func_info for section #2 1928c2ecf20Sopenharmony_ci * a list of bpf_func_info records for section #2 1938c2ecf20Sopenharmony_ci * ...... 1948c2ecf20Sopenharmony_ci * 1958c2ecf20Sopenharmony_ci * Note that the bpf_func_info record size in .BTF.ext may not 1968c2ecf20Sopenharmony_ci * be the same as the one defined in include/uapi/linux/bpf.h. 1978c2ecf20Sopenharmony_ci * The loader should ensure that record_size meets minimum 1988c2ecf20Sopenharmony_ci * requirement and pass the record as is to the kernel. The 1998c2ecf20Sopenharmony_ci * kernel will handle the func_info properly based on its contents. 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_cistruct btf_ext_header { 2028c2ecf20Sopenharmony_ci __u16 magic; 2038c2ecf20Sopenharmony_ci __u8 version; 2048c2ecf20Sopenharmony_ci __u8 flags; 2058c2ecf20Sopenharmony_ci __u32 hdr_len; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci /* All offsets are in bytes relative to the end of this header */ 2088c2ecf20Sopenharmony_ci __u32 func_info_off; 2098c2ecf20Sopenharmony_ci __u32 func_info_len; 2108c2ecf20Sopenharmony_ci __u32 line_info_off; 2118c2ecf20Sopenharmony_ci __u32 line_info_len; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci /* optional part of .BTF.ext header */ 2148c2ecf20Sopenharmony_ci __u32 core_relo_off; 2158c2ecf20Sopenharmony_ci __u32 core_relo_len; 2168c2ecf20Sopenharmony_ci}; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistruct btf_ext { 2198c2ecf20Sopenharmony_ci union { 2208c2ecf20Sopenharmony_ci struct btf_ext_header *hdr; 2218c2ecf20Sopenharmony_ci void *data; 2228c2ecf20Sopenharmony_ci }; 2238c2ecf20Sopenharmony_ci struct btf_ext_info func_info; 2248c2ecf20Sopenharmony_ci struct btf_ext_info line_info; 2258c2ecf20Sopenharmony_ci struct btf_ext_info core_relo_info; 2268c2ecf20Sopenharmony_ci __u32 data_size; 2278c2ecf20Sopenharmony_ci}; 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_cistruct btf_ext_info_sec { 2308c2ecf20Sopenharmony_ci __u32 sec_name_off; 2318c2ecf20Sopenharmony_ci __u32 num_info; 2328c2ecf20Sopenharmony_ci /* Followed by num_info * record_size number of bytes */ 2338c2ecf20Sopenharmony_ci __u8 data[]; 2348c2ecf20Sopenharmony_ci}; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/* The minimum bpf_func_info checked by the loader */ 2378c2ecf20Sopenharmony_cistruct bpf_func_info_min { 2388c2ecf20Sopenharmony_ci __u32 insn_off; 2398c2ecf20Sopenharmony_ci __u32 type_id; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/* The minimum bpf_line_info checked by the loader */ 2438c2ecf20Sopenharmony_cistruct bpf_line_info_min { 2448c2ecf20Sopenharmony_ci __u32 insn_off; 2458c2ecf20Sopenharmony_ci __u32 file_name_off; 2468c2ecf20Sopenharmony_ci __u32 line_off; 2478c2ecf20Sopenharmony_ci __u32 line_col; 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value 2518c2ecf20Sopenharmony_ci * has to be adjusted by relocations. 2528c2ecf20Sopenharmony_ci */ 2538c2ecf20Sopenharmony_cienum bpf_core_relo_kind { 2548c2ecf20Sopenharmony_ci BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */ 2558c2ecf20Sopenharmony_ci BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */ 2568c2ecf20Sopenharmony_ci BPF_FIELD_EXISTS = 2, /* field existence in target kernel */ 2578c2ecf20Sopenharmony_ci BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */ 2588c2ecf20Sopenharmony_ci BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */ 2598c2ecf20Sopenharmony_ci BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */ 2608c2ecf20Sopenharmony_ci BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */ 2618c2ecf20Sopenharmony_ci BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */ 2628c2ecf20Sopenharmony_ci BPF_TYPE_EXISTS = 8, /* type existence in target kernel */ 2638c2ecf20Sopenharmony_ci BPF_TYPE_SIZE = 9, /* type size in bytes */ 2648c2ecf20Sopenharmony_ci BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */ 2658c2ecf20Sopenharmony_ci BPF_ENUMVAL_VALUE = 11, /* enum value integer value */ 2668c2ecf20Sopenharmony_ci}; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci/* The minimum bpf_core_relo checked by the loader 2698c2ecf20Sopenharmony_ci * 2708c2ecf20Sopenharmony_ci * CO-RE relocation captures the following data: 2718c2ecf20Sopenharmony_ci * - insn_off - instruction offset (in bytes) within a BPF program that needs 2728c2ecf20Sopenharmony_ci * its insn->imm field to be relocated with actual field info; 2738c2ecf20Sopenharmony_ci * - type_id - BTF type ID of the "root" (containing) entity of a relocatable 2748c2ecf20Sopenharmony_ci * type or field; 2758c2ecf20Sopenharmony_ci * - access_str_off - offset into corresponding .BTF string section. String 2768c2ecf20Sopenharmony_ci * interpretation depends on specific relocation kind: 2778c2ecf20Sopenharmony_ci * - for field-based relocations, string encodes an accessed field using 2788c2ecf20Sopenharmony_ci * a sequence of field and array indices, separated by colon (:). It's 2798c2ecf20Sopenharmony_ci * conceptually very close to LLVM's getelementptr ([0]) instruction's 2808c2ecf20Sopenharmony_ci * arguments for identifying offset to a field. 2818c2ecf20Sopenharmony_ci * - for type-based relocations, strings is expected to be just "0"; 2828c2ecf20Sopenharmony_ci * - for enum value-based relocations, string contains an index of enum 2838c2ecf20Sopenharmony_ci * value within its enum type; 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * Example to provide a better feel. 2868c2ecf20Sopenharmony_ci * 2878c2ecf20Sopenharmony_ci * struct sample { 2888c2ecf20Sopenharmony_ci * int a; 2898c2ecf20Sopenharmony_ci * struct { 2908c2ecf20Sopenharmony_ci * int b[10]; 2918c2ecf20Sopenharmony_ci * }; 2928c2ecf20Sopenharmony_ci * }; 2938c2ecf20Sopenharmony_ci * 2948c2ecf20Sopenharmony_ci * struct sample *s = ...; 2958c2ecf20Sopenharmony_ci * int x = &s->a; // encoded as "0:0" (a is field #0) 2968c2ecf20Sopenharmony_ci * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1, 2978c2ecf20Sopenharmony_ci * // b is field #0 inside anon struct, accessing elem #5) 2988c2ecf20Sopenharmony_ci * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) 2998c2ecf20Sopenharmony_ci * 3008c2ecf20Sopenharmony_ci * type_id for all relocs in this example will capture BTF type id of 3018c2ecf20Sopenharmony_ci * `struct sample`. 3028c2ecf20Sopenharmony_ci * 3038c2ecf20Sopenharmony_ci * Such relocation is emitted when using __builtin_preserve_access_index() 3048c2ecf20Sopenharmony_ci * Clang built-in, passing expression that captures field address, e.g.: 3058c2ecf20Sopenharmony_ci * 3068c2ecf20Sopenharmony_ci * bpf_probe_read(&dst, sizeof(dst), 3078c2ecf20Sopenharmony_ci * __builtin_preserve_access_index(&src->a.b.c)); 3088c2ecf20Sopenharmony_ci * 3098c2ecf20Sopenharmony_ci * In this case Clang will emit field relocation recording necessary data to 3108c2ecf20Sopenharmony_ci * be able to find offset of embedded `a.b.c` field within `src` struct. 3118c2ecf20Sopenharmony_ci * 3128c2ecf20Sopenharmony_ci * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction 3138c2ecf20Sopenharmony_ci */ 3148c2ecf20Sopenharmony_cistruct bpf_core_relo { 3158c2ecf20Sopenharmony_ci __u32 insn_off; 3168c2ecf20Sopenharmony_ci __u32 type_id; 3178c2ecf20Sopenharmony_ci __u32 access_str_off; 3188c2ecf20Sopenharmony_ci enum bpf_core_relo_kind kind; 3198c2ecf20Sopenharmony_ci}; 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci#endif /* __LIBBPF_LIBBPF_INTERNAL_H */ 322