[PATCH] D93563: BPF: add extern func to data sections if specified
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 18 19:36:41 PST 2020
yonghong-song added a comment.
For:
void foo1(int); works ?
void foo2(int) __ attribute __((section("bar"))); sort-of works, but this one goes into the same section as foo1 ?
Current llvm without this patch, the following are generated BTFs:
BTF_KIND_FUNC (foo1) -> BTF_KIND_FUNC_PROTO (foo1)
BTF_KIND_FUNC (foo2) -> BTF_KIND_FUNC_PROTO (foo2)
there are no data sections generated.
With this patch, the following BTFs are generated:
BTF_KIND_FUNC (foo1) -> BTF_KIND_FUNC_PROTO (foo1)
BTF_KIND_FUNC (foo2) -> BTF_KIND_FUNC_PROTO (foo2)
BTF_KIND_VAR(foo2) -> BTF_KIND_FUNC(foo2)
BTF_KIND_DATASEC(bar) -> BTF_KIND_VAR(foo2)
The above is not perfect either.
extern functions are actually extern variables, ideally we should treat them the same as
extern variables, so we probably should not generate BTF_KIND_FUNC() in the above,
we should generate
BTF_KIND_VAR(foo1) -> BTF_KIND_FUNC_PROTO(foo1)
BTF_KIND_VAR(foo2) -> BTF_KIND_FUNC_PROTO(foo2)
BTF_KIND_DATASEC(.extern) -> BTF_KIND_VAR(foo1)
BTF_KIND_DATASEC(bar) -> BTF_KIND_VAR(foo2)
So we do not generate BTF_KIND_FUNC for extern functions.
But unfortunately, we have the following in uapi,
enum btf_func_linkage {
BTF_FUNC_STATIC = 0,
BTF_FUNC_GLOBAL = 1,
BTF_FUNC_EXTERN = 2,
};
But BTF_FUNC_EXTERN is not used yet, maybe we can remove this
and BTF_KIND_VAR to represent external function instead of
using BTF_KIND_FUNC? This will make things a little bit
easier to unify with section handling. Or alternatively we can
have BTF_KIND_VAR points to BTF_KIND_FUNC but it feels
a little bit redundant.
The only issue is consistency w.r.t. non-extern functions.
Currently we don't put them into any BTF_KIND_VAR.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93563/new/
https://reviews.llvm.org/D93563
More information about the llvm-commits
mailing list