When encoding from a lot of object file sources, it is possible some will not contain BTF, so if --btf_features=encode_force is set, drive on as long as at least one _does_ contain a .BTF section. With this in place, we can test how gcc -gbtf generation across vmlinux works in a simple manner by doing the following on a kernel build which specified -gbtf in the KCFLAGS environment variable (tested with gcc 14): pahole --format_path=btf -J --btf_features=encode_force \ --btf_encode_detached=/tmp/vmlinux.btf $(ar t vmlinux.a) ("ar t vmlinux.a" gives a list of the object files comprising vmlinux) This is no substitute for link-time BTF deduplication of course, but it does provide a simple way to see the BTF that gcc generates for vmlinux. The idea is that we can explore differences in BTF generation across the various combinations 1. debug info source: DWARF; dedup done via pahole (traditional) 2. debug info source: compiler-generated BTF; dedup done via pahole (above) 3. debug info source: compiler-generated BTF; dedup done via linker (TBD) Handling 3 - linker-based dedup - will require BTF archives so that is the next step we need to explore. Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx> --- dwarves.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dwarves.c b/dwarves.c index ef93239..8b37b13 100644 --- a/dwarves.c +++ b/dwarves.c @@ -2948,17 +2948,27 @@ try_elf: int cus__load_files(struct cus *cus, struct conf_load *conf, char *filenames[]) { - int i = 0; + int i = 0, loaded = 0, failed = 0; while (filenames[i] != NULL) { int err = cus__load_file(cus, conf, filenames[i]); if (err) { errno = -err; - return -++i; + if (conf->btf_encode_force) + failed = -(i + 1); + else + return -++i; + } else { + loaded++; } ++i; } + if (conf->btf_encode_force) { + /* If no files loaded, error out, otherwise return success */ + if (loaded == 0) + return failed; + } return i ? 0 : cus__load_running_kernel(cus, conf); } -- 2.43.5