You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Inspect Linux BTF type and function metadata offline #2369
P3: lowLow priority, nice to havearea: nativeNative analysis and decompilation, including Ghidra, IDA, and Hopper analysis behaviorenhancementNew feature or request
The current contracts have no declared Linux BTF/BTF.ext inspection profile. The published BTF format contains type graphs, function metadata and line information that ordinary ELF section inventory does not decode. Issue #2003 targets Solana sBPF and does not provide a Linux BTF contract.
Acceptance criteria
Accept caller-selected BTF bytes or an explicitly identified ELF section and preserve original hash/source ranges.
Specify supported BTF versions, byte order, type kinds and BTF.ext function/line/relocation records.
Retain unknown kinds and unresolved references explicitly; bound strings, type references, records and graph traversal.
Verify original fixtures through CLI/MCP; do not load programs, attach probes, access live kernel state or invoke a verifier.
This feature needs its own docs/specs//spec.md, plan.md and tasks.md before code. Current upstream sources and existing issues were searched before filing. A new REA provider or expanded execution authority requires the maintainer scope decision specified by CONTRIBUTING.md; this proposal does not supply that decision.
Objective (ELI5):
Parse BPF Type Format (BTF) data from Linux binaries and kernel modules offline, extracting struct definitions, types, and function prototypes.
Key Requirements:
Pure TypeScript parser for the .BTF ELF section and standalone BTF files (/sys/kernel/btf/vmlinux).
I'd like to take this as inspect_btf / inspect-btf, a static reader in the same lane as inspect_kernel_module and inspect_elf_notes.
First slice: one absolute path, either a standalone BTF blob (/sys/kernel/btf/* or a saved copy) or an ELF/.ko carrying .BTF. .BTF.ext is read when present. .BTF.base / split-BTF presence is reported, and base references stay unresolved — no relocation.
Result: byte order, version, flags and header lengths; section ranges with SHA-256; string-table statistics; a paged type inventory by 1-based id with the exact kind-specific facts (members and bitfields, params, enum/enum64, arrays, vars/datasecs, decl/type tags); a one-level named reference summary for the types used by the returned page; .BTF.ext func/line/CO-RE records grouped by ELF section, paged per section; explicit unknowns for unknown kinds, out-of-range string offsets, and truncated or overlapping ranges.
Effects: reads one selected file only. No BPF program load, no attach, no verifier, no live kernel or /sys access, no network, no writes.
Verification: owned fixtures compiled from a small C source with clang -target bpf -g (source and generator checked in), plus synthetic big-endian, unknown-kind, truncated and malformed fixtures; CLI and MCP boundary coverage; one real vmlinux.BTF run recorded as evidence and not committed.
Deferred:.BTF.base relocation, .BTF_ids, pretty-printing the type graph, BTF generation.
Two format details worth pinning:
The kernel docs describe info as vlen bits 0–23 / kind 24–30, while include/uapi/linux/btf.h and libbpf decode vlen as 16 bits, kind as 5 bits at 24–28 and bit 31 as kind_flag. I plan to follow the header macros and record the discrepancy rather than silently pick one.
The .BTF.ext header's core-relo fields are optional (hdr_len 24 vs 32), so both are admitted.
Is that slice in scope, and is inspect_btf the name you want? I'll put spec/plan/tasks/verification under docs/specs/btf-inspection/ before the implementation.
P3: lowLow priority, nice to havearea: nativeNative analysis and decompilation, including Ghidra, IDA, and Hopper analysis behaviorenhancementNew feature or request
Activity
matbrgz commentedon Oct 12, 2026
Implementation & Scope Notes
Objective (ELI5):
Parse BPF Type Format (BTF) data from Linux binaries and kernel modules offline, extracting struct definitions, types, and function prototypes.
Key Requirements:
.BTFELF section and standalone BTF files (/sys/kernel/btf/vmlinux).BTF_KIND_STRUCT,BTF_KIND_UNION,BTF_KIND_FUNC,BTF_KIND_FUNC_PROTO) into typed domain structures.zaid646 commentedon Oct 28, 2026
Quick scope proposal before I write code.
I'd like to take this as
inspect_btf/inspect-btf, a static reader in the same lane asinspect_kernel_moduleandinspect_elf_notes.First slice: one absolute path, either a standalone BTF blob (
/sys/kernel/btf/*or a saved copy) or an ELF/.kocarrying.BTF..BTF.extis read when present..BTF.base/ split-BTF presence is reported, and base references stay unresolved — no relocation.Result: byte order, version, flags and header lengths; section ranges with SHA-256; string-table statistics; a paged type inventory by 1-based id with the exact kind-specific facts (members and bitfields, params, enum/enum64, arrays, vars/datasecs, decl/type tags); a one-level named reference summary for the types used by the returned page;
.BTF.extfunc/line/CO-RE records grouped by ELF section, paged per section; explicit unknowns for unknown kinds, out-of-range string offsets, and truncated or overlapping ranges.Effects: reads one selected file only. No BPF program load, no attach, no verifier, no live kernel or
/sysaccess, no network, no writes.Verification: owned fixtures compiled from a small C source with
clang -target bpf -g(source and generator checked in), plus synthetic big-endian, unknown-kind, truncated and malformed fixtures; CLI and MCP boundary coverage; one realvmlinux.BTFrun recorded as evidence and not committed.Deferred:
.BTF.baserelocation,.BTF_ids, pretty-printing the type graph, BTF generation.Two format details worth pinning:
infoas vlen bits 0–23 / kind 24–30, whileinclude/uapi/linux/btf.hand libbpf decode vlen as 16 bits, kind as 5 bits at 24–28 and bit 31 askind_flag. I plan to follow the header macros and record the discrepancy rather than silently pick one..BTF.extheader's core-relo fields are optional (hdr_len24 vs 32), so both are admitted.Is that slice in scope, and is
inspect_btfthe name you want? I'll put spec/plan/tasks/verification underdocs/specs/btf-inspection/before the implementation.