diff options
| author | Andrii Nakryiko <[email protected]> | 2019-11-01 22:28:08 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2019-11-04 15:06:56 +0000 |
| commit | 94f060e98495e26fd02e18c14e78c61f0d643fd6 (patch) | |
| tree | 268a181aa151235586834f3cc4212c6d1d18107e /tools/lib/bpf/bpf_core_read.h | |
| parent | libbpf: Add support for relocatable bitfields (diff) | |
| download | kernel-94f060e98495e26fd02e18c14e78c61f0d643fd6.tar.gz kernel-94f060e98495e26fd02e18c14e78c61f0d643fd6.zip | |
libbpf: Add support for field size relocations
Add bpf_core_field_size() macro, capturing a relocation against field size.
Adjust bits of internal libbpf relocation logic to allow capturing size
relocations of various field types: arrays, structs/unions, enums, etc.
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/bpf_core_read.h')
| -rw-r--r-- | tools/lib/bpf/bpf_core_read.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf_core_read.h b/tools/lib/bpf/bpf_core_read.h index 0935cd68e7de..11461b2623b0 100644 --- a/tools/lib/bpf/bpf_core_read.h +++ b/tools/lib/bpf/bpf_core_read.h @@ -97,6 +97,13 @@ enum bpf_field_info_kind { __builtin_preserve_field_info(field, BPF_FIELD_EXISTS) /* + * Convenience macro to get byte size of a field. Works for integers, + * struct/unions, pointers, arrays, and enums. + */ +#define bpf_core_field_size(field) \ + __builtin_preserve_field_info(field, BPF_FIELD_BYTE_SIZE) + +/* * bpf_core_read() abstracts away bpf_probe_read() call and captures offset * relocation for source address using __builtin_preserve_access_index() * built-in, provided by Clang. |
