From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC64FC433E5 for ; Wed, 22 Jul 2020 21:12:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FB2122B3F for ; Wed, 22 Jul 2020 21:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595452364; bh=pR506CDklcpFTP6ptrFcKpvsgs1xKOjV09WELaNpObw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lpFNv65I6U6g0sEMY/fQolppNVfsZP/j5XZyUExMB1L7NLy/3MJamspPJQxXLUmPQ 907QAJtNk8ip95IcoyPXCa3ZK6ti2iGXR3cq7xDxmO1D8+aSqv4Ge1D90bgfqIg4bq WkorTxBCDiRUnL1RPmcqnihtJG5DEfC8EzVjL61A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726447AbgGVVMo convert rfc822-to-8bit (ORCPT ); Wed, 22 Jul 2020 17:12:44 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25783 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732858AbgGVVMm (ORCPT ); Wed, 22 Jul 2020 17:12:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-ntleJ_VoOOGtNboY6r-OqQ-1; Wed, 22 Jul 2020 17:12:37 -0400 X-MC-Unique: ntleJ_VoOOGtNboY6r-OqQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8679E1005510; Wed, 22 Jul 2020 21:12:35 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id E901B19C4F; Wed, 22 Jul 2020 21:12:31 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , Martin KaFai Lau , David Miller , John Fastabend , Wenbo Zhang , KP Singh , Brendan Gregg , Florent Revest , Al Viro Subject: [PATCH v8 bpf-next 02/13] tools resolve_btfids: Add support for set symbols Date: Wed, 22 Jul 2020 23:12:12 +0200 Message-Id: <20200722211223.1055107-3-jolsa@kernel.org> In-Reply-To: <20200722211223.1055107-1-jolsa@kernel.org> References: <20200722211223.1055107-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The set symbol does not have the unique number suffix, so we need to give it a special parsing function. This was omitted in the first batch, because there was no set support yet, so it slipped in the testing. Signed-off-by: Jiri Olsa --- tools/bpf/resolve_btfids/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index 6956b6350cad..c28ab0401818 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -220,6 +220,19 @@ static char *get_id(const char *prefix_end) return id; } +static struct btf_id *add_set(struct object *obj, char *name) +{ + char *id; + + id = strdup(name + sizeof(BTF_SET) + sizeof("__") - 2); + if (!id) { + pr_err("FAILED to parse cnt name: %s\n", name); + return NULL; + } + + return btf_id__add(&obj->sets, id, true); +} + static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size) { char *id; @@ -376,7 +389,7 @@ static int symbols_collect(struct object *obj) id = add_symbol(&obj->funcs, prefix, sizeof(BTF_FUNC) - 1); /* set */ } else if (!strncmp(prefix, BTF_SET, sizeof(BTF_SET) - 1)) { - id = add_symbol(&obj->sets, prefix, sizeof(BTF_SET) - 1); + id = add_set(obj, prefix); /* * SET objects store list's count, which is encoded * in symbol's size, together with 'cnt' field hence -- 2.25.4