Ksyms module btf fallback#1594
Open
altugbozkurt07 wants to merge 3 commits into
Open
Conversation
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.
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
7020ff2 to
405593e
Compare
Discover module BTFs lazily when typed ksym externs cannot be resolved from vmlinux, keep module BTF FDs alive until program load, and encode module variable/kfunc relocations with the kernel ABI expected FD form. Add opt-in xtask support for building and injecting integration-test kernel modules, plus a first module-BTF typed ksym integration fixture and local custom-kernel validation helper.
405593e to
7baeca3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build on the typed ksym support in #1372 and the split-BTF view support in #1593 to resolve extern ksyms defined by kernel modules.
The ksyms PR resolves typed extern variables and kfuncs against vmlinux BTF. That is not enough for module-defined symbols, because module BTF is split BTF: it defines module-local symbols while referencing base vmlinux types. This PR discovers loaded module BTF objects lazily when vmlinux cannot resolve all typed externs, resolves those externs through
SplitBtf, and keeps the module BTF FDs alive until program load.Module-BTF relocations also need different kernel ABI encoding than vmlinux relocations. This PR tracks whether an extern resolved to vmlinux, module BTF, kallsyms, or weak-missing, then patches module kfunc calls with the module BTF fd-array index and module variable references with the module BTF object FD.
This also adds opt-in xtask support for building and injecting integration-test kernel modules, so module-BTF behavior can be tested in the VM integration flow.
Added tests for:
This change is