Em Tue, Jan 08, 2019 at 07:38:10AM +0000, Andrii Nakryiko escreveu: > When dealing with BTF encoding of multiple CUs, special `void` type > should be handled explicitly. This is already handled for all BTF > types except recently added FUNC_PROTO. Without this fix, any `void` > type directly referenced from FUNC_PROTO will turn into last type > from previous CU (see example below, for FUNC_PROTO [4]). > > $ cat test1.c > void (*foo)(void); > > int main() { > return 0; > } > > $ cat test2.c > void (*bar)(void); > > $ cc -g test1.c test2.c -o test > > Without fix: > > $ LLVM_OBJCOPY=objcopy ~/local/pahole/build/pahole -JV /tmp/test > File /tmp/test: > [1] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED > [2] FUNC_PROTO (anon) return=0 args=(void) > [3] PTR (anon) type_id=2 > [4] FUNC_PROTO (anon) return=3 args=(void) > [5] PTR (anon) type_id=4 Reproduced the problem, but couldn't so far try the fix as the patch came mangled, see below, fixing it by hand, probably related to some MS outlook setting: Content-ID: <02DD2D329C450C4FB23C8218B6842E31@xxxxxxxxxxxxxxxxxxxxxxxxx> i--- a/libbtf.c +++ b/libbtf.c @@ -535,7 +535,7 @@ int32_t btf__add_func_proto(struct btf *btf, struct fty= pe *ftype, =20 t.name_off =3D 0; t.info =3D BTF_INFO_ENCODE(BTF_KIND_FUNC_PROTO, 0, nr_params); - t.type =3D type_id_off + ftype->tag.type; + t.type =3D ftype->tag.type =3D=3D 0 ? 0 : type_id_off + ftype->tag.type; =20 ++btf->type_index; if (gobuffer__add(&btf->types, &t, sizeof(t)) >=3D 0) {