Zero-clang pure-Elixir eBPF ISA v3 + ELF64 + .BTF + .BTF.ext compiler.
Emits standards-compliant little-endian ELF64 (EM_BPF, ELFDATA2LSB)
relocatable objects containing:
- One or more executable program sections (
xdp,tcx/ingress,tcx/egress,tracepoint/<category>/<name>) licensesection (without a leading dot, matching libbpf requirements)- Optional
.mapssection and.rel<sec> R_BPF_64_64relocations - Valid
.BTFtype graph (BTF-defined maps includingLPM_TRIEwithBPF_F_NO_PREALLOCandRINGBUFwithoutkey/value,DATASEC(".maps"), per-programFUNC+FUNC_PROTO) and.BTF.extfunc_inforecords solibbpf 1.5.0and the Linux kernel load all programs and shared maps cleanly.
Supports both low-level instruction specifications (compile/1,
compile_timed/1, xdp_packet_counter/1, xdp_percpu_packet_counter/1,
xdp_return/1) and high-level fused %MaeBPF.IR.Module{} compilation
(compile_ir/1, compile_ir/2, compile_ir!/1, compile_ir!/2).
Summary
Functions
Compiles a low-level program specification map into a valid ELF64 eBPF binary.
Compiles a %MaeBPF.IR.Module{} (multi-program, multi-map, fused packet
parser, static safety checked) into a little-endian bpfel ELF64 object.
Like compile_ir/2, raising ArgumentError on validation or compilation
failure.
Compiles a low-level program specification map and returns
{:ok, elf_bin, elapsed_us}.
Builds a ready-to-load XDP program in pure Elixir that counts packets in a
BTF-defined BPF_MAP_TYPE_ARRAY or BPF_MAP_TYPE_PERCPU_ARRAY map
(key: u32, value: u64) and returns XDP_PASS (2) by default.
Convenience wrapper for xdp_packet_counter/1 using a lock-free
BPF_MAP_TYPE_PERCPU_ARRAY counter map.
Builds a minimal pure-Elixir XDP program returning action (default XDP_PASS = 2).
Functions
Compiles a low-level program specification map into a valid ELF64 eBPF binary.
Specification keys:
:section- ELF section name (default"xdp"):name- program function name (default"xdp_prog"):license- license string (default"GPL"):maps- list of map specs:instructions- list of eBPF instructions and{:label, atom}markers
Compiles a %MaeBPF.IR.Module{} (multi-program, multi-map, fused packet
parser, static safety checked) into a little-endian bpfel ELF64 object.
Options:
:debug_trace- whentrue, injects"__maebpf_debug_rb"and"__maebpf_rb_drops___maebpf_debug_rb"and emits per-plug trace events (defaultfalse):sample- debug trace sampling interval (>= 1, default1):ringbuf_kb- debug RingBuf size in KiB (default256):max_stack_bytes- stack limit override (default512):max_instructions- instruction budget override (default4096):max_branches- branch budget override (default512)
Returns {:ok, %{elf: bin, ir: ir, source_map: map, insn_counts: map, stack_bytes: map, elapsed_us: int}}.
Like compile_ir/2, raising ArgumentError on validation or compilation
failure.
Compiles a low-level program specification map and returns
{:ok, elf_bin, elapsed_us}.
Builds a ready-to-load XDP program in pure Elixir that counts packets in a
BTF-defined BPF_MAP_TYPE_ARRAY or BPF_MAP_TYPE_PERCPU_ARRAY map
(key: u32, value: u64) and returns XDP_PASS (2) by default.
Convenience wrapper for xdp_packet_counter/1 using a lock-free
BPF_MAP_TYPE_PERCPU_ARRAY counter map.
Builds a minimal pure-Elixir XDP program returning action (default XDP_PASS = 2).