---
title: "Compile Once – Run Everywhere"
---

> Documentation Index
> Fetch the complete documentation index at: https://example.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Compile Once – Run Everywhere

[CO-RE](https://example.com/ebpf-field-guide/glossary/#co-re) (Compile Once – Run Everywhere) combines Clang, BTF, and `libbpf`. At build time, Clang records *field access recipes* (like `sk_buff->len`) inside the ELF's `.BTF.ext` section.

When the tiny binary starts on a target host, `libbpf` reads `/sys/kernel/btf/vmlinux`, calculates each field's true byte offset on *that* kernel, and rewrites the bytecode before calling `bpf()`.

## What changed

- Clang on every server → single CI compile (~35 KiB .bpf.o)
- Hardcoded offsets → .BTF.ext relocation records
- Runtime guesswork → exact patch against host vmlinux BTF

Source: https://example.com/ebpf-field-guide/portability-and-toolchain/btf-and-core/co-re/index.mdx
