2026-09-18 14:09 UTC+1000 ~ Thiébaud Weksteen <[email protected]> > When generating a light skeleton (bpftool gen skeleton -L), > bpf_object__load() skips loading programs marked as non-autoload (e.g. > SEC("?...")), so the generated loader program only records and populates > file descriptors for autoloaded programs. > > Previously, bpftool emitted struct bpf_prog_desc fields, link fields, > and attach/detach/destroy functions for all programs in the BPF object, > causing the loader program to store subsequent program FDs into > incorrect skeleton struct fields when non-autoload programs were > present. > > Furthermore, bpf_object__load() can update a program's autoload status > during preparation (e.g. for struct_ops programs when resolving kernel > BTF members or adjusting autoload based on map autocreate settings). > Move bpf_object__gen_loader() and bpf_object__load() out of gen_trace() > into do_skeleton() before counting programs and emitting struct fields so > that struct field declarations and attach/detach/destroy functions all > observe the final post-load autoload state. > > Skip programs with !bpf_program__autoload(prog) when counting programs > and generating progs/links struct fields as well as attach, detach, and > destroy functions for light skeletons. > > Fixes: d510296d331a ("bpftool: Use syscall/loader program in "prog load" and > "gen skeleton" command.") > Signed-off-by: Thiébaud Weksteen <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]> Thanks!

