[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0a2fa960-285d-dc32-bf76-5ba27da89dba@solarflare.com>
Date: Wed, 17 Oct 2018 17:13:21 +0100
From: Edward Cree <ecree@...arflare.com>
To: Yonghong Song <yhs@...com>, <ast@...com>, <kafai@...com>,
<daniel@...earbox.net>, <netdev@...r.kernel.org>
CC: <kernel-team@...com>
Subject: Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and
BTF_KIND_FUNC_PROTO
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
Powered by blists - more mailing lists