Feature gate: #![feature(btf_relocations)]
This is a tracking issue for experimental BPF Type Format (BTF) Compile Once, Run Everywhere (CO-RE) relocation support, as proposed in rust-lang/rfcs#3966.
The feature introduces #[btf_relocatable] for structs and unions that model external BTF types. Ordinary field projection and offset_of! are rejected for these types because they would produce fixed offsets without preserving the field identity needed for CO-RE relocation.
The feature also provides BTF-aware field metadata queries through core::btf. These queries return Option<usize> so programs can account for fields that do not exist in the target BTF.
The current implementation supports LLVM BPF targets and requires debug info. Unsupported targets, backends, and codegen configurations produce a compile error.
Public API
// core::btf
pub macro field_byte_offset($Carrier:ty, $($fields:expr)+ $(,)?);
pub macro field_byte_size($Carrier:ty, $($fields:expr)+ $(,)?);
Both macros expand to an expression of type Option<usize>.
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
Feature gate:
#![feature(btf_relocations)]This is a tracking issue for experimental BPF Type Format (BTF) Compile Once, Run Everywhere (CO-RE) relocation support, as proposed in rust-lang/rfcs#3966.
The feature introduces
#[btf_relocatable]for structs and unions that model external BTF types. Ordinary field projection andoffset_of!are rejected for these types because they would produce fixed offsets without preserving the field identity needed for CO-RE relocation.The feature also provides BTF-aware field metadata queries through
core::btf. These queries returnOption<usize>so programs can account for fields that do not exist in the target BTF.The current implementation supports LLVM BPF targets and requires debug info. Unsupported targets, backends, and codegen configurations produce a compile error.
Public API
Both macros expand to an expression of type
Option<usize>.Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩