{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifhvcueuqokahaf7neaow57cm2ptailccxt57ls35qqa7irlcx2dy",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mksvsj4xskv2"
},
"path": "/t/pre-rfc-btf-relocations/24161?page=2#post_23",
"publishedAt": "2026-05-01T19:11:50.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"@llvm.preserve."
],
"textContent": "I think the current implementation in LLVM makes it quite hard to implement with anything else than real structs:\n\nUsing `@llvm.preserve.*.access.index` intrinsics instead of `getelementptr` in LLVM has two effects:\n\n * It ensures the offset stays literally in the code and is not transformed by optimization passes,\n * and it allows debuginfo metadata with type information to be attached to the access.\n\n\n\nThe BPF codegen backend then writes the used type names and field names into a symbol table and generates BTF relocations that connect each such offset in the code with the symbolic names of the accessed type and field and type layout information.\n\nWith a macro or intrinsic function, the compiler would still need to generate type debug metadata, so that the BPF codegen backend can find the names and check the types for compatibility. It's probably way easier to reuse the infrastructure that already generates debuginfo metadata for Rust types than to reimplement part of it just for BPF.",
"title": "[Pre-RFC] BTF relocations"
}