From: Sedat Dilek <sedat.dilek@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jiri Olsa <jolsa@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
dwarves@vger.kernel.org, bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
Hao Luo <haoluo@google.com>, Tom Stellard <tstellar@redhat.com>
Subject: Re: [PATCH] btf_encoder: Add extra checks for symbol names
Date: Tue, 12 Jan 2021 21:17:41 +0100 [thread overview]
Message-ID: <CA+icZUVPNdTb1U5qGDz1Z05NWng+GEhrFtLgev-OVM_zLhzznQ@mail.gmail.com> (raw)
In-Reply-To: <20210112194724.GB1291051@krava>
On Tue, Jan 12, 2021 at 8:47 PM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Tue, Jan 12, 2021 at 11:20:44AM -0800, Andrii Nakryiko wrote:
> > On Tue, Jan 12, 2021 at 10:43 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > When processing kernel image build by clang we can
> > > find some functions without the name, which causes
> > > pahole to segfault.
> > >
> > > Adding extra checks to make sure we always have
> > > function's name defined before using it.
> > >
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> > > btf_encoder.c | 8 ++++++--
> > > 1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/btf_encoder.c b/btf_encoder.c
> > > index 333973054b61..17f7a14f2ef0 100644
> > > --- a/btf_encoder.c
> > > +++ b/btf_encoder.c
> > > @@ -72,6 +72,8 @@ static int collect_function(struct btf_elf *btfe, GElf_Sym *sym)
> > >
> > > if (elf_sym__type(sym) != STT_FUNC)
> > > return 0;
> > > + if (!elf_sym__name(sym, btfe->symtab))
> > > + return 0;
> >
> > elf_sym__name() is called below again, so might be better to just use
> > local variable to store result?
>
> right, will add
>
> >
> > >
> > > if (functions_cnt == functions_alloc) {
> > > functions_alloc = max(1000, functions_alloc * 3 / 2);
> > > @@ -730,9 +732,11 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> > > if (!has_arg_names(cu, &fn->proto))
> > > continue;
> > > if (functions_cnt) {
> > > - struct elf_function *func;
> > > + const char *name = function__name(fn, cu);
> > > + struct elf_function *func = NULL;
> > >
> > > - func = find_function(btfe, function__name(fn, cu));
> > > + if (name)
> > > + func = find_function(btfe, name);
> >
> > isn't this a more convoluted way of writing:
> >
> > name = function__name(fn, cu);
> > if (!name)
> > continue;
> >
> > func = find_function(btfe, name);
> > if (!func || func->generated)
> > continue
> >
> > ?
>
> convoluted is my middle name ;-) I'll change it
>
OK, a v2 will follow.
Thanks JCO.
- sed@ -
> thanks,
> jirka
>
> >
> > > if (!func || func->generated)
> > > continue;
> > > func->generated = true;
> > > --
> > > 2.26.2
> > >
> >
>
next prev parent reply other threads:[~2021-01-12 21:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 18:40 [PATCH] btf_encoder: Add extra checks for symbol names Jiri Olsa
2021-01-12 19:20 ` Andrii Nakryiko
2021-01-12 19:47 ` Jiri Olsa
2021-01-12 20:17 ` Sedat Dilek [this message]
2021-01-13 0:27 ` Tom Stellard
2021-01-14 7:50 ` Sedat Dilek
2021-01-14 14:33 ` Tom Stellard
2021-01-14 14:39 ` Sedat Dilek
2021-01-21 13:38 ` Arnaldo Carvalho de Melo
2021-01-21 16:06 ` Sedat Dilek
2021-01-21 19:37 ` Arnaldo Carvalho de Melo
2021-01-21 20:53 ` Andrii Nakryiko
2021-01-22 2:07 ` Sedat Dilek
2021-01-22 4:11 ` Andrii Nakryiko
2021-01-28 20:00 ` [RFT] pahole 1.20 RC was " Arnaldo Carvalho de Melo
2021-01-28 20:57 ` Sedat Dilek
2021-01-28 21:11 ` Arnaldo Carvalho de Melo
2021-01-28 22:28 ` Sedat Dilek
2021-02-02 7:48 ` Andrii Nakryiko
2021-02-03 9:03 ` Sedat Dilek
2021-02-03 10:23 ` Mark Wielaard
2021-02-03 21:48 ` Sedat Dilek
2021-02-03 23:21 ` Andrii Nakryiko
2021-02-04 1:06 ` Arnaldo Carvalho de Melo
2021-02-04 6:40 ` Sedat Dilek
2021-01-21 17:37 ` Tom Stellard
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=CA+icZUVPNdTb1U5qGDz1Z05NWng+GEhrFtLgev-OVM_zLhzznQ@mail.gmail.com \
--to=sedat.dilek@gmail.com \
--cc=acme@kernel.org \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=haoluo@google.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=tstellar@redhat.com \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).