On Fri, Oct 9, 2020 at 7:53 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote: > > Em Thu, Oct 08, 2020 at 04:39:53PM -0700, Andrii Nakryiko escreveu: > > From: Andrii Nakryiko <andriin@xxxxxx> > > > > Switch BTF loading to completely use libbpf's own struct btf and related APIs. > > BTF encoding is still happening with pahole's own code, so these two code > > paths are not sharing anything now. String fetching is happening based on > > whether btfe->strings were set to non-NULL pointer by btf_encoder. > > While testing this one I noticed a problem, but it isn't caused by this > particular patch: > > [acme@five pahole]$ cp ~/git/build/v5.9-rc6+/net/ipv4/tcp_ipv4.o . > [acme@five pahole]$ readelf -SW tcp_ipv4.o | grep BTF > [acme@five pahole]$ pahole -J tcp_ipv4.o > [acme@five pahole]$ readelf -SW tcp_ipv4.o | grep BTF > [105] .BTF PROGBITS 0000000000000000 0fbb3c 03f697 00 0 0 1 > [acme@five pahole]$ ./btfdiff tcp_ipv4.o > --- /tmp/btfdiff.dwarf.BDAvGi 2020-10-09 11:41:45.161509391 -0300 > +++ /tmp/btfdiff.btf.p81icw 2020-10-09 11:41:45.177509720 -0300 > @@ -4056,7 +4056,7 @@ struct tcp_congestion_ops { > u32 (*min_tso_segs)(struct sock *); /* 96 8 */ > u32 (*sndbuf_expand)(struct sock *); /* 104 8 */ > void (*cong_control)(struct sock *, const struct rate_sample *); /* 112 8 */ > - size_t (*get_info)(struct sock *, u32, int *, union tcp_cc_info *); /* 120 8 */ > + size_t (*get_info)(struct sock *, u32, int *, struct tcp_cc_info *); /* 120 8 */ It's a bug in btf_loader.c. When loading BTF_KIND_FWD, we always assume it's struct forward reference. But I checked, generated BTF does have the valid info (kind_flag), so it should be easy to fix, I'll send a fix. The reason we don't see it in vmlinux is because after dedup that forward reference is resolved to a full type, which is clearly union. [...]