C CO-RE eBPF compiler implementing @behaviour MaeBPF.Compiler for
use MaeBPFC modules and direct {:c, source} compilation.
Compiles generated or raw C source in memory via Linux memfd_create (with
temporary file fallback on non-Linux hosts) and clang -O2 -g -target bpf -mcpu=v3 -c -o -, with optional static BPF .bpf.o object linking via
bpftool gen object.
Summary
Functions
Compiles C source to an eBPF ELF64 object binary in memory.
Implements MaeBPF.Compiler.compile_ir/2 for use MaeBPFC modules.
Compiles C source to an eBPF ELF64 binary and returns elapsed microseconds.
Ensures vmlinux.h exists in cache_dir, dumping it once from kernel BTF.
Statically links one or more precompiled BPF-target .bpf.o objects
(EM_BPF, ET_REL) into primary_elf via bpftool gen object.
Functions
Compiles C source to an eBPF ELF64 object binary in memory.
Returns {:ok, elf_binary} or {:error, reason}.
Implements MaeBPF.Compiler.compile_ir/2 for use MaeBPFC modules.
Lowers %MaeBPF.IR.Module{} via MaeBPFC.Codegen.generate/2, compiles the
C CO-RE source with clang -target bpf, and statically links any
link_objects: (EM_BPF .bpf.o) via bpftool gen object.
Returns {:ok, %{elf: bin, ir: valid_ir, c_source: c_src, source_map: %{}, elapsed_us: us}}.
Compiles C source to an eBPF ELF64 binary and returns elapsed microseconds.
Ensures vmlinux.h exists in cache_dir, dumping it once from kernel BTF.
Statically links one or more precompiled BPF-target .bpf.o objects
(EM_BPF, ET_REL) into primary_elf via bpftool gen object.
Only kernel BPF relocatable objects (e_type=ET_REL, e_machine=EM_BPF=247)
are accepted; userspace native .o/.so/libc binaries cannot be linked
into Linux kernel eBPF.