tools/testing/selftests/bpf/progs/test_core_reloc_size.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_core_reloc_size.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_core_reloc_size.c- Extension
.c- Size
- 1985 bytes
- Lines
- 78
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hstdint.hbpf/bpf_helpers.hbpf/bpf_core_read.h
Detected Declarations
struct core_reloc_size_outputstruct core_reloc_sizefunction test_core_size
Annotated Snippet
struct core_reloc_size_output {
int int_sz;
int int_off;
int struct_sz;
int struct_off;
int union_sz;
int union_off;
int arr_sz;
int arr_off;
int arr_elem_sz;
int arr_elem_off;
int ptr_sz;
int ptr_off;
int enum_sz;
int enum_off;
int float_sz;
int float_off;
};
struct core_reloc_size {
int int_field;
struct { int x; } struct_field;
union { int x; } union_field;
int arr_field[4];
void *ptr_field;
enum { VALUE = 123 } enum_field;
float float_field;
};
SEC("raw_tracepoint/sys_enter")
int test_core_size(void *ctx)
{
struct core_reloc_size *in = (void *)&data.in;
struct core_reloc_size_output *out = (void *)&data.out;
out->int_sz = bpf_core_field_size(in->int_field);
out->int_off = bpf_core_field_offset(in->int_field);
out->struct_sz = bpf_core_field_size(in->struct_field);
out->struct_off = bpf_core_field_offset(in->struct_field);
out->union_sz = bpf_core_field_size(in->union_field);
out->union_off = bpf_core_field_offset(in->union_field);
out->arr_sz = bpf_core_field_size(in->arr_field);
out->arr_off = bpf_core_field_offset(in->arr_field);
out->arr_elem_sz = bpf_core_field_size(struct core_reloc_size, arr_field[1]);
out->arr_elem_off = bpf_core_field_offset(struct core_reloc_size, arr_field[1]);
out->ptr_sz = bpf_core_field_size(struct core_reloc_size, ptr_field);
out->ptr_off = bpf_core_field_offset(struct core_reloc_size, ptr_field);
out->enum_sz = bpf_core_field_size(struct core_reloc_size, enum_field);
out->enum_off = bpf_core_field_offset(struct core_reloc_size, enum_field);
out->float_sz = bpf_core_field_size(struct core_reloc_size, float_field);
out->float_off = bpf_core_field_offset(struct core_reloc_size, float_field);
return 0;
}
Annotation
- Immediate include surface: `linux/bpf.h`, `stdint.h`, `bpf/bpf_helpers.h`, `bpf/bpf_core_read.h`.
- Detected declarations: `struct core_reloc_size_output`, `struct core_reloc_size`, `function test_core_size`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.