From patchwork Thu Feb 24 10:14:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 12758280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00AD9C433EF for ; Thu, 24 Feb 2022 10:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232026AbiBXKEm (ORCPT ); Thu, 24 Feb 2022 05:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbiBXKEl (ORCPT ); Thu, 24 Feb 2022 05:04:41 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2775285AB9 for ; Thu, 24 Feb 2022 02:04:11 -0800 (PST) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4K47fx6LYdz1FDbT; Thu, 24 Feb 2022 17:59:37 +0800 (CST) Received: from huawei.com (10.67.174.197) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 24 Feb 2022 18:04:09 +0800 From: Xu Kuohai To: CC: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Yonghong Song , Shuah Khan , Martin KaFai Lau , Song Liu Subject: [PATCH bpf-next v2 0/2] libbpf: Fix btf dump error caused by Date: Thu, 24 Feb 2022 05:14:42 -0500 Message-ID: <20220224101444.1169015-1-xukuohai@huawei.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Originating-IP: [10.67.174.197] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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(-)