[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181017175024.kugirxvpu2pymapk@kafai-mbp.dhcp.thefacebook.com>
Date: Wed, 17 Oct 2018 17:50:30 +0000
From: Martin Lau <kafai@...com>
To: Yonghong Song <yhs@...com>
CC: Edward Cree <ecree@...arflare.com>,
Alexei Starovoitov <ast@...com>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and
BTF_KIND_FUNC_PROTO
On Wed, Oct 17, 2018 at 10:25:21AM -0700, Yonghong Song wrote:
>
>
> On 10/17/18 9:13 AM, Edward Cree wrote:
> > 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.
>
> What you stated is true, BTF_KIND_FUNC_PROTO corresponds to
> dwarf subroutine tag which has no name while BTF_KIND_FUNC
> must have a valid name. The original design is to have both
> since they are corresponding to different dwarf constructs.
>
> Martin, what do you think?
I prefer to have separate kinds. We need a way to distinguish them.
For example, the BTF verifier is checking it. Having two kinds is
cleaner instead of resorting to other hints from 'struct btf_type'.
We don't lack of bits for kind.
>
> >
> > -Ed
> >
Powered by blists - more mailing lists