QiuSimons 8b8cd41baf vmlinux-btf: rework BTF generation from prepared kernel headers
- Replace full shadow kernel build with direct stub compilation against target headers
- Add multi-tier stub units for core, module, and private kernel structures
- Ensure exact struct layout fidelity without modifying host kernel Kconfig
- Simplify and modernize OpenWrt Makefile for maintainability
- Add multi-arch GitHub Actions CI workflow supporting OpenWrt 24 and 25 SDKs

fix(ci): install real llvm package for multi-arch llvm-objcopy support

fix(ci): bridge llvm-objcopy to objcopy for pahole -J BTF encoding

- Clean redundant narrative comments in Makefile for idiomatic KISS structure
- Link llvm-objcopy to target/host objcopy so older pahole -J can insert .BTF section

fix(makefile): add fallback for older pahole without --btf_encode_detached

fix(makefile): use wildcard linking to prevent make eval expansion error and drop unsupported --jobs from pahole

ci: fix YAML string termination in Debian sources configuration

ci: repoint Debian Bullseye to archive.debian.org to fix EOL 404

ci: fix host pahole installation and streamline path detection

- Install dwarves (which provides pahole in Bullseye) with fallback to pahole
- Add fail-fast check in CI to verify pahole existence before OpenWrt compilation
- Symlink detected pahole binary into OpenWrt staging_dir/host/bin
- Streamline BTF_PAHOLE search paths in Makefile (KISS: staging_dir, /usr/bin, /usr/local/bin)

ci: fix host pahole detection under OpenWrt isolated PATH

- Explicitly install pahole and dwarves packages in SDK container
- Symlink host pahole into OpenWrt staging_dir/host/bin to survive PATH sanitization
- Add absolute wildcard fallbacks (/usr/bin/pahole, /usr/local/bin/pahole) in Makefile
- Verify pahole executable viability via --version before BTF generation
2026-10-19 17:53:39 +08:00

vmlinux-btf

OpenWrt package that generates a detached BTF (vmlinux) file from kernel headers and .config, enabling CO-RE (Compile Once – Run Everywhere) eBPF programs on OpenWrt without rebuilding or replacing the running kernel.

Overview

Official OpenWrt release kernels typically omit CONFIG_DEBUG_INFO_BTF=y. Without kernel BTF, modern eBPF tools that rely on CO-RE (such as libbpf-based loaders) cannot resolve kernel type layouts.

Rather than recompiling the entire kernel tree, this package compiles lightweight stub sources (src/shadow_btf_*.c) against the prepared target kernel headers ($(LINUX_DIR)) using the target configuration and toolchain. pahole then extracts the detached BTF blob from the linked object.

Requirements

  • OpenWrt buildroot or SDK environment.
  • Host pahole >= 1.22 (from the dwarves package).

Building

In OpenWrt SDK

git clone https://github.com/QiuSimons/vmlinux-btf.git package/vmlinux-btf
make package/vmlinux-btf/compile V=s

In OpenWrt Buildroot

Select vmlinux-btf under Kernel in make menuconfig, then build:

make package/vmlinux-btf/compile V=s

Installed Files

  • /usr/lib/debug/boot/vmlinux: Detached BTF file.
  • /usr/lib/debug/boot/vmlinux-<release>: Symlink targeting vmlinux (linked to uname -r on target installation).

Standard loaders such as libbpf look for BTF at /usr/lib/debug/boot/vmlinux-$(uname -r) and /usr/lib/debug/boot/vmlinux by default.

License

GPL-3.0-or-later

S
Description
No description provided
Readme
85 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 76.9%
Makefile 13.3%
C 9.8%