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