Skip to content

Split btf support#1593

Open
altugbozkurt07 wants to merge 2 commits into
aya-rs:mainfrom
altugbozkurt07:split-btf-support
Open

Split btf support#1593
altugbozkurt07 wants to merge 2 commits into
aya-rs:mainfrom
altugbozkurt07:split-btf-support

Conversation

@altugbozkurt07

@altugbozkurt07 altugbozkurt07 commented Jun 6, 2026

Copy link
Copy Markdown

Model split BTF as a borrowed view over base and split BTF objects instead of storing base BTF state inside Btf itself.

This builds on the ksyms support in #1372. That PR resolves typed extern ksyms against vmlinux BTF, but module-defined kfuncs and variables are described by split BTF: the module BTF references types and strings from the base vmlinux BTF while also defining its own module-local types.

This PR adds a BtfView abstraction for shared lookup behavior and a SplitBtf view that resolves visible type IDs and string offsets across the combined base/module BTF namespace. Btf remains a standalone parsed metadata blob, while code that needs module-BTF lookup can operate through the view.

The type compatibility helpers are now generic over BtfView, so existing callers can keep passing Btf directly, and the follow-up module-BTF ksym fallback PR can pass SplitBtf when resolving externs against module BTF.

Added unit coverage for split-BTF type resolution and compatibility checks across the base/module boundary. No integration tests are included here because this PR only introduces the reusable view abstraction; the follow-up module-BTF ksym PR exercises it through loader behavior.


This change is Reviewable

Collect extern symbols from object BTF and fix up the .ksyms datasec
so the resulting BTF is acceptable to the kernel.

Resolve typed extern vars and kfuncs through kernel BTF. Fall back to
/proc/kallsyms for typeless vars, then apply the corresponding extern
relocations before program load.

Expose the object-level ksym APIs in aya-obj via
Object::resolve_externs(), Object::relocate_externs(), and KsymsError.

Weak extern handling follows libbpf-style behavior. Unresolved weak var
references are null-patched, unresolved weak kfunc calls are poisoned,
and unresolved strong extern relocations are rejected.

Add integration coverage for typed ksyms, typed kfuncs,
kallsyms-backed ksyms, and missing strong-symbol failures.
Model split BTF as a borrowed view over base and split BTF objects instead of storing base BTF state inside Btf itself. This keeps Btf as a standalone parsed metadata blob while allowing lookup code to resolve type IDs and string offsets through the combined split-BTF namespace.

Move shared type walking helpers behind BtfView and make type/field compatibility generic over that view. Existing callers still use Btf directly, while module-BTF resolution can pass SplitBtf in a follow-up.
@altugbozkurt07 altugbozkurt07 requested a review from a team as a code owner June 6, 2026 19:22
@netlify

netlify Bot commented Jun 6, 2026

Copy link
Copy Markdown

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 09047b9
🔍 Latest deploy log https://app.netlify.com/projects/aya-rs-docs/deploys/6a247384ccde9d0009ba85a4
😎 Deploy Preview https://deploy-preview-1593--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant