How aya-rs/bpf-linker works
BPF Linker is a command-line static linker for LLVM bitcode, textual IR, and object/archive inputs, producing BPF code or intermediate output. The main flow accepts inputs and linker options, combines and prepares LLVM modules, optionally sanitizes debug metadata for BTF, then emits the selected output. The graph also includes the LLVM wrapper layer and documented compatibility options. Some orchestration details are unsampled; those links are omitted rather than inferred from module names.
Main entry points: linker.rs Linker API · module.rs LLVM module · mod.rs LLVM operations · di.rs BTF sanitization
Components 17
Command line
- CLI options
src/bin/bpf-linker.rs
Linking pipeline
- Linker API
src/linker.rs - Input detection
src/linker.rs - Archive inputs
src/linker.rs - Module optimization
src/llvm/mod.rs - Linked output
src/linker.rs
LLVM interface
- LLVM operations
src/llvm/mod.rs - LLVM context
src/llvm/types/context.rs - LLVM module
src/llvm/types/module.rs - Memory buffers
src/llvm/types/memory_buffer.rs - IR iterators
src/llvm/iter.rs - Target machine
src/llvm/types/target_machine.rs - IR value wrappers
src/llvm/types/ir.rs
Debug metadata
- BTF sanitization
src/llvm/di.rs - DI wrappers
src/llvm/types/di.rs - DI builder
src/llvm/types/di_builder.rs
Other components
- Build user
Connections 18
- Build user → CLI options: invokes
README.md - CLI options → Linker API: configures
- Linker API → Input detection: detects
src/linker.rs - Input detection → Archive inputs: recognizes
src/linker.rs - Linker API → LLVM operations: uses
src/linker.rs - LLVM operations → LLVM context: creates
src/llvm/types/context.rs - LLVM context → LLVM module: creates
src/llvm/types/context.rs - LLVM operations → LLVM module: links modules
src/llvm/mod.rs - LLVM module → IR iterators: iterates IR
src/llvm/types/module.rs - LLVM operations → Module optimization: optimizes
src/llvm/mod.rs - Linker API → BTF sanitization: sanitizes BTF
src/linker.rs - BTF sanitization → DI wrappers: rewrites metadata
src/llvm/di.rs - BTF sanitization → DI builder: builds metadata
src/llvm/di.rs - BTF sanitization → IR value wrappers: traverses values
src/llvm/di.rs - Linker API → Target machine: emits code
- Target machine → LLVM module: emits module
src/llvm/types/target_machine.rs - LLVM module → Memory buffers: writes bitcode
src/llvm/types/module.rs - Linker API → Linked output: returns output
src/linker.rs