From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edward Cree Subject: Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO Date: Wed, 17 Oct 2018 17:13:21 +0100 Message-ID: <0a2fa960-285d-dc32-bf76-5ba27da89dba@solarflare.com> References: <20181017072315.2766920-1-yhs@fb.com> <20181017072315.2766920-3-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Cc: To: Yonghong Song , , , , Return-path: Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]:39726 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbeJRAJw (ORCPT ); Wed, 17 Oct 2018 20:09:52 -0400 In-Reply-To: <20181017072315.2766920-3-yhs@fb.com> Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: On 17/10/18 08:23, Yonghong Song wrote: > This patch adds BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO > support to the type section. BTF_KIND_FUNC_PROTO is used > to specify the type of a function pointer. With this, > BTF has a complete set of C types (except float). > > BTF_KIND_FUNC is used to specify the signature of a > defined subprogram. BTF_KIND_FUNC_PROTO can be referenced > by another type, e.g., a pointer type, and BTF_KIND_FUNC > type cannot be referenced by another type. Why are distinct kinds created for these?  A function body is  a value of function type, and since there's no way (in C) to  declare a variable of function type (only pointer-to-  function), any declaration of function type must necessarily  be a BTF_KIND_FUNC, whereas any other reference to a function  type (e.g. a declaration of type pointer to function type)  must, as you state above, be a BTF_KIND_FUNC_PROTO. In fact, you can tell the difference just from name_off, since  a (C-legal) BTF_KIND_FUNC_PROTO will always be anonymous (as  the pointee of a pointer type), while a BTF_KIND_FUNC will  have the name of the subprogram. -Ed