Expand description
Match the return types of the object’s kfunc prototypes to the running kernel’s.
libbpf refuses an extern kfunc whose prototype is not compatible with the kernel’s, and a return type that is void on one side and a value on the other is not. Such changes happen while the cid-form interface settles: scx_bpf_kick_cid() returned s32 on kernels where it now returns nothing, and scx_bpf_cidperf_set() the other way around. The BPF side never reads what these return, so the object can be told whichever the kernel has.
The object’s BTF is rewritten before libbpf opens it. Each kfunc whose return type has to change gets a copy of its prototype with the kernel’s choice, appended after the last type, since the linker may share one prototype between kfuncs that look alike. Type ids and string offsets stay where they were, so .BTF.ext still holds. The longer .BTF goes at the end of the image and its section header is pointed there.
Re-exports§
use std::collections::BTreeMap;🔒use anyhow::Context;🔒use anyhow::bail;🔒use anyhow::ensure;🔒use libbpf_rs::Btf;🔒use libbpf_rs::btf::ReferencesType;🔒use libbpf_rs::btf::types::Func;🔒use crate::Result;🔒
Structs§
- Type 🔒
Constants§
Functions§
- adapt
- Return
objectwith the return types of its kfuncs matched to the running kernel’s, and the names of the kfuncs that changed. - btf_
section 🔒 - The section header of
.BTFin an ELF64 little-endian object: where the header is, and the section’s offset and size. - put_u32 🔒
- put_u64 🔒
- trailing 🔒
- The bytes a type takes after its 12-byte header.
- u16_at 🔒
- u32_at 🔒
- u64_at 🔒