Use libbpf dump option to ensure that a nested struct will be declared as an equivalent anonymous struct to the named struct. With this approach we do not need -fms-extension to support such structs in vmlinux.h. Signed-off-by: Alan Maguire --- tools/bpf/bpftool/btf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index 946612029dee..523c8bf0e53a 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -771,11 +771,13 @@ static struct sort_datum *sort_btf_c(const struct btf *btf) static int dump_btf_c(const struct btf *btf, __u32 *root_type_ids, int root_type_cnt, bool sort_dump) { + DECLARE_LIBBPF_OPTS(btf_dump_opts, opts, + .force_anon_struct_members = true); struct sort_datum *datums = NULL; struct btf_dump *d; int err = 0, i; - d = btf_dump__new(btf, btf_dump_printf, NULL, NULL); + d = btf_dump__new(btf, btf_dump_printf, NULL, &opts); if (!d) return -errno; -- 2.39.3