From: Song Liu <songliubraving@fb.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>,
Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next] libbpf: provide more helpful message on uninitialized global var
Date: Tue, 23 Jul 2019 08:51:02 +0000 [thread overview]
Message-ID: <ECB3771E-B6E8-45EC-B673-A0E0F79340BF@fb.com> (raw)
In-Reply-To: <20190723042329.3121956-1-andriin@fb.com>
> On Jul 22, 2019, at 9:23 PM, Andrii Nakryiko <andriin@fb.com> wrote:
>
> When BPF program defines uninitialized global variable, it's put into
> a special COMMON section. Libbpf will reject such programs, but will
> provide very unhelpful message with garbage-looking section index.
>
> This patch detects special section cases and gives more explicit error
> message.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
> tools/lib/bpf/libbpf.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 794dd5064ae8..5f9e7eedb134 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -1760,15 +1760,23 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
> (long long) sym.st_value, sym.st_name, name);
>
> shdr_idx = sym.st_shndx;
> + insn_idx = rel.r_offset / sizeof(struct bpf_insn);
> + pr_debug("relocation: insn_idx=%u, shdr_idx=%u\n",
> + insn_idx, shdr_idx);
> +
> + if (shdr_idx >= SHN_LORESERVE) {
> + pr_warning("relocation: not yet supported relo for non-static global \'%s\' variable "
> + "in special section (0x%x) found in insns[%d].code 0x%x\n",
For easy grep, we should keep this one long long string.
Thanks,
Song
next prev parent reply other threads:[~2019-07-23 8:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 4:23 [PATCH bpf-next] libbpf: provide more helpful message on uninitialized global var Andrii Nakryiko
2019-07-23 8:51 ` Song Liu [this message]
2019-07-23 17:33 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ECB3771E-B6E8-45EC-B673-A0E0F79340BF@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox