Skip to content

Tracking Issue for BTF relocations (btf_relocations) #160616

Open

Description

@vadorovsky

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

  • How should non-LLVM codegen backends expose equivalent relocation support?

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    T-libs-api
    C-tracking-issue
    S-tracking-unimplemented
    on Aug 6, 2026
  2. added
    T-lang
    I-lang-radar
    on Aug 6, 2026
  3. added
    T-libs
    and removed
    T-libs-api
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueI-lang-radarS-tracking-unimplementedT-langT-libs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions