[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+khW7ji5gFXh1XN71CUy08+bofu=yKfopgXV7yOuhRkoSr1=w@mail.gmail.com>
Date: Fri, 19 Jun 2020 14:57:09 -0700
From: Hao Luo <haoluo@...gle.com>
To: Andrii Nakryiko <andriin@...com>
Cc: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
Kernel Team <kernel-team@...com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Song Liu <songliubraving@...com>,
Quentin Monnet <quentin@...valent.com>
Subject: Re: [PATCH v2 bpf-next 1/9] libbpf: generalize libbpf externs support
Only two small places on this version, otherwise it looks good to me.
I can offer my reviewed-by, if need. :)
Thanks for the patch!
Reviewed-by: Hao Luo <haoluo@...gle.com>
On Fri, Jun 19, 2020 at 1:34 PM Andrii Nakryiko <andriin@...com> wrote:
>
> Switch existing Kconfig externs to be just one of few possible kinds of more
> generic externs. This refactoring is in preparation for ksymbol extern
> support, added in the follow up patch. There are no functional changes
> intended.
>
> Signed-off-by: Andrii Nakryiko <andriin@...com>
> ---
[...]
> @@ -2756,23 +2796,29 @@ static int cmp_externs(const void *_a, const void *_b)
[...]
> +
> + if (a->type == EXT_KCFG) {
> + /* descending order by alignment requirements */
> + if (a->kcfg.align != b->kcfg.align)
> + return a->kcfg.align > b->kcfg.align ? -1 : 1;
> + /* ascending order by size, within same alignment class */
> + if (a->kcfg.sz != b->kcfg.sz)
> + return a->kcfg.sz < b->kcfg.sz ? -1 : 1;
> + /* resolve ties by name */
> + }
> +
> return strcmp(a->name, b->name);
> }
I assume the comment /* resolve ties by name */ is intended to be
close to strcmp?
> @@ -2818,22 +2864,39 @@ static int bpf_object__collect_externs(struct bpf_object *obj)
> ext->name = btf__name_by_offset(obj->btf, t->name_off);
> ext->sym_idx = i;
> ext->is_weak = GELF_ST_BIND(sym.st_info) == STB_WEAK;
> - ext->sz = btf__resolve_size(obj->btf, t->type);
> - if (ext->sz <= 0) {
> - pr_warn("failed to resolve size of extern '%s': %d\n",
> - ext_name, ext->sz);
> - return ext->sz;
> - }
> - ext->align = btf__align_of(obj->btf, t->type);
> - if (ext->align <= 0) {
> - pr_warn("failed to determine alignment of extern '%s': %d\n",
> - ext_name, ext->align);
> - return -EINVAL;
> - }
> - ext->type = find_extern_type(obj->btf, t->type,
> - &ext->is_signed);
> - if (ext->type == EXT_UNKNOWN) {
> - pr_warn("extern '%s' type is unsupported\n", ext_name);
> +
> + ext->sec_btf_id = find_extern_sec_btf_id(obj->btf, ext->btf_id);
> + if (ext->btf_id <= 0) {
> + pr_warn("failed to find BTF for extern '%s' [%d] section: %d\n",
> + ext_name, ext->btf_id, ext->sec_btf_id);
> + return ext->sec_btf_id;
> + }
Did you mean "ext->sec_btf_id <= 0" rather than "ext->btf_id <= 0"?
Powered by blists - more mailing lists