mbox series

[bpf-next,v2,0/2] libbpf: Fix btf dump error caused by

Message ID 20220224101444.1169015-1-xukuohai@huawei.com (mailing list archive)
Headers show
Series libbpf: Fix btf dump error caused by | expand

Message

Xu Kuohai Feb. 24, 2022, 10:14 a.m. UTC
This series fixes a btf dump error caused by forward declaration.
Currently if a declaration appears in the BTF before the definition,
the definition is dumped as a conflicting name, eg:

    $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'"
    [81287] FWD 'unix_sock' fwd_kind=struct
    [89336] STRUCT 'unix_sock' size=1024 vlen=14

    $ bpftool btf dump file vmlinux format c | grep "struct unix_sock"
    struct unix_sock;
    struct unix_sock___2 {	<--- conflict, the "___2" is unexpected
		    struct unix_sock___2 *unix_sk;

This causes a "definition not found" compilation error if the dump output
is used as a header file.

Xu Kuohai (2):
  libbpf: Skip declaration when counting duplicated type names
  selftests/bpf: Update btf_dump for conflicting names caused by
    declaration

 tools/lib/bpf/btf_dump.c                      |  5 ++
 .../selftests/bpf/prog_tests/btf_dump.c       | 54 ++++++++++++++-----
 2 files changed, 46 insertions(+), 13 deletions(-)