SIGN IN SIGN UP

libbpf: Support sanitization of BTF layout for older kernels

Add a FEAT_BTF_LAYOUT feature check which checks if the
kernel supports BTF layout information.  Also sanitize
BTF if it contains layout data but the kernel does not
support it.  The sanitization requires rewriting raw
BTF data to update the header and eliminate the layout
section (since it lies between the types and strings),
so refactor sanitization to do the raw BTF retrieval
and creation of updated BTF, returning that new BTF
on success.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260326145444.2076244-7-alan.maguire@oracle.com
A
Alan Maguire committed
fd04b4eae1a3ea5c418bb686a20830d616cd6490
Parent: c95ad95
Committed by Andrii Nakryiko <andrii.nakryiko@gmail.com> on 4/9/2026, 10:12:21 PM