# solana-labs/rbpf architecture

> Architecture diagram of the GitHub repository solana-labs/rbpf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/solana-labs/rbpf
- Repository: https://github.com/solana-labs/rbpf

## Overview

solana_rbpf is a Rust user-space eBPF virtual machine. Its principal workflow is to configure a loader and built-ins, create an executable from bytecode or ELF, optionally JIT-compile it, map memory and create an instruction-meter context, then execute it in the interpreter or JIT. Separate capabilities include assembly and disassembly, verification, debugging, and syscall support. The workflow links are documented in the README; source-level links are limited to relationships visible in the supplied excerpts or SOURCE INDEX, so unsampled implementation details are not inferred.

Main entry points: [`src/program.rs`](https://github.com/solana-labs/rbpf/blob/main/src/program.rs) (Executable and built-ins), [`src/elf.rs`](https://github.com/solana-labs/rbpf/blob/main/src/elf.rs) (ELF loader), [`src/jit.rs`](https://github.com/solana-labs/rbpf/blob/main/src/jit.rs) (x86 JIT compiler), [`src/vm.rs`](https://github.com/solana-labs/rbpf/blob/main/src/vm.rs) (Virtual machine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Program authoring"]
  node_asm_parser["Assembly parser<br/>[asm_parser.rs]"]
  node_assembler["Assembler<br/>[assembler.rs]"]
  node_insn_builder["Instruction builder<br/>[insn_builder.rs]"]
  node_disassembler["Disassembler<br/>[disassembler.rs]"]
  node_debugger["Debugger<br/>[debugger.rs]"]
end

subgraph group_loading["Loading and analysis"]
  node_elf_parser["ELF parser<br/>[mod.rs]"]
  node_elf_loader["ELF loader<br/>[elf.rs]"]
  node_verifier["Verifier<br/>[verifier.rs]"]
  node_static_analysis["Static analysis<br/>[static_analysis.rs]"]
  node_program["Executable and built-ins<br/>[program.rs]"]
end

subgraph group_runtime["VM runtime"]
  node_syscalls["Syscall registry<br/>[syscalls.rs]"]
  node_memory_region["Memory mapping<br/>[memory_region.rs]"]
  node_aligned_memory["Aligned memory<br/>[aligned_memory.rs]"]
  node_vm["Virtual machine<br/>[vm.rs]"]
end

subgraph group_execution["Execution engines"]
  node_interpreter["Interpreter<br/>[interpreter.rs]"]
  node_jit["x86 JIT compiler<br/>[jit.rs]"]
  node_x86["x86 instruction emission<br/>[x86.rs]"]
end

node_user(("Application user"))

node_user -->|"configures loader"| node_program
node_user -->|"loads ELF"| node_elf_loader
node_user -->|"creates executable"| node_program
node_elf_loader -->|"parses ELF"| node_elf_parser
node_elf_loader -.->|"builds executable"| node_program
node_elf_loader -->|"references JIT"| node_jit
node_user -.->|"verifies program"| node_verifier
node_user -->|"compiles executable"| node_jit
node_jit -->|"uses analysis"| node_static_analysis
node_user -->|"maps memory"| node_memory_region
node_user -->|"creates VM"| node_vm
node_program -->|"uses VM types"| node_vm
node_program -->|"uses syscall registry"| node_syscalls
node_user -->|"runs interpreter"| node_interpreter
node_user -->|"runs compiled code"| node_jit

click node_asm_parser "https://github.com/solana-labs/rbpf/blob/main/src/asm_parser.rs"
click node_assembler "https://github.com/solana-labs/rbpf/blob/main/src/assembler.rs"
click node_insn_builder "https://github.com/solana-labs/rbpf/blob/main/src/insn_builder.rs"
click node_disassembler "https://github.com/solana-labs/rbpf/blob/main/src/disassembler.rs"
click node_debugger "https://github.com/solana-labs/rbpf/blob/main/src/debugger.rs"
click node_elf_parser "https://github.com/solana-labs/rbpf/blob/main/src/elf_parser/mod.rs"
click node_elf_loader "https://github.com/solana-labs/rbpf/blob/main/src/elf.rs"
click node_verifier "https://github.com/solana-labs/rbpf/blob/main/src/verifier.rs"
click node_static_analysis "https://github.com/solana-labs/rbpf/blob/main/src/static_analysis.rs"
click node_program "https://github.com/solana-labs/rbpf/blob/main/src/program.rs"
click node_syscalls "https://github.com/solana-labs/rbpf/blob/main/src/syscalls.rs"
click node_memory_region "https://github.com/solana-labs/rbpf/blob/main/src/memory_region.rs"
click node_aligned_memory "https://github.com/solana-labs/rbpf/blob/main/src/aligned_memory.rs"
click node_vm "https://github.com/solana-labs/rbpf/blob/main/src/vm.rs"
click node_interpreter "https://github.com/solana-labs/rbpf/blob/main/src/interpreter.rs"
click node_jit "https://github.com/solana-labs/rbpf/blob/main/src/jit.rs"
click node_x86 "https://github.com/solana-labs/rbpf/blob/main/src/x86.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_asm_parser,node_assembler,node_insn_builder,node_disassembler,node_debugger,node_user toneBlue
class node_elf_parser,node_elf_loader,node_verifier,node_static_analysis,node_program toneAmber
class node_syscalls,node_memory_region,node_aligned_memory,node_vm toneMint
class node_interpreter,node_jit,node_x86 toneRose
```

## Components

### Program authoring

- [Assembly parser](https://github.com/solana-labs/rbpf/blob/main/src/asm_parser.rs): `src/asm_parser.rs`
- [Assembler](https://github.com/solana-labs/rbpf/blob/main/src/assembler.rs): `src/assembler.rs`
- [Instruction builder](https://github.com/solana-labs/rbpf/blob/main/src/insn_builder.rs): `src/insn_builder.rs`
- [Disassembler](https://github.com/solana-labs/rbpf/blob/main/src/disassembler.rs): `src/disassembler.rs`
- [Debugger](https://github.com/solana-labs/rbpf/blob/main/src/debugger.rs): `src/debugger.rs`

### Loading and analysis

- [ELF parser](https://github.com/solana-labs/rbpf/blob/main/src/elf_parser/mod.rs): `src/elf_parser/mod.rs`
- [ELF loader](https://github.com/solana-labs/rbpf/blob/main/src/elf.rs): `src/elf.rs`
- [Verifier](https://github.com/solana-labs/rbpf/blob/main/src/verifier.rs): `src/verifier.rs`
- [Static analysis](https://github.com/solana-labs/rbpf/blob/main/src/static_analysis.rs): `src/static_analysis.rs`
- [Executable and built-ins](https://github.com/solana-labs/rbpf/blob/main/src/program.rs): `src/program.rs`

### VM runtime

- [Syscall registry](https://github.com/solana-labs/rbpf/blob/main/src/syscalls.rs): `src/syscalls.rs`
- [Memory mapping](https://github.com/solana-labs/rbpf/blob/main/src/memory_region.rs): `src/memory_region.rs`
- [Aligned memory](https://github.com/solana-labs/rbpf/blob/main/src/aligned_memory.rs): `src/aligned_memory.rs`
- [Virtual machine](https://github.com/solana-labs/rbpf/blob/main/src/vm.rs): `src/vm.rs`

### Execution engines

- [Interpreter](https://github.com/solana-labs/rbpf/blob/main/src/interpreter.rs): `src/interpreter.rs`
- [x86 JIT compiler](https://github.com/solana-labs/rbpf/blob/main/src/jit.rs): `src/jit.rs`
- [x86 instruction emission](https://github.com/solana-labs/rbpf/blob/main/src/x86.rs): `src/x86.rs`

### Other components

- **Application user**

## Connections

- Application user → Executable and built-ins: configures loader
- Application user → ELF loader: loads ELF
- Application user → Executable and built-ins: creates executable
- ELF loader → ELF parser: parses ELF (evidence: `src/elf.rs`)
- ELF loader → Executable and built-ins: builds executable
- ELF loader → x86 JIT compiler: references JIT (evidence: `src/elf.rs`)
- Application user → Verifier: verifies program
- Application user → x86 JIT compiler: compiles executable
- x86 JIT compiler → Static analysis: uses analysis (evidence: `src/jit.rs`)
- Application user → Memory mapping: maps memory
- Application user → Virtual machine: creates VM
- Executable and built-ins → Virtual machine: uses VM types (evidence: `src/program.rs`)
- Executable and built-ins → Syscall registry: uses syscall registry (evidence: `src/program.rs`)
- Application user → Interpreter: runs interpreter
- Application user → x86 JIT compiler: runs compiled code
