Re: [RFC/PATCH bpf-next 08/20] libbpf: Add elf_find_patern_func_offset function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 26, 2023 at 12:24:16PM -0700, Andrii Nakryiko wrote:
> On Mon, Apr 24, 2023 at 9:06 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Adding elf_find_patern_func_offset function that looks up
> > offsets for symbols specified by pattern argument.
> >
> > The 'pattern' argument allows wildcards (*?' supported).
> >
> > Offsets are returned in allocated array together with its
> > size and needs to be released by the caller.
> >
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> 
> 
> Why do we need to expose any elf-related helpers as libbpf public API?
> Just to use them in selftests? If yes, then selftests can use libbpf
> internal helpers just like bpftool due to static linking. In general,
> it of course doesn't make sense for libbpf to provide ELF helpers as
> part of its API.

I use them in bpftrace ;-) I can move the implementation in there,
if we don't want to expose it.. it was just convenient to use libbpf

> 
> Also s/patern/pattern/.

ok

> 
> 
> >  tools/lib/bpf/libbpf.c   | 121 +++++++++++++++++++++++++++++++++++++++
> >  tools/lib/bpf/libbpf.h   |   7 +++
> >  tools/lib/bpf/libbpf.map |   1 +
> >  3 files changed, 129 insertions(+)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 0b15609d4573..7eb7035f7b73 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -11052,6 +11052,127 @@ elf_find_multi_func_offset(const char *binary_path, int cnt,
> >         return ret;
> >  }
> >
> > +struct match_pattern_data {
> > +       const char *pattern;
> > +       struct elf_func_offset *func_offs;
> > +       size_t func_offs_cnt;
> > +       size_t func_offs_cap;
> > +};
> > +
> > +static int pattern_done(void *_data)
> > +{
> > +       struct match_pattern_data *data = _data;
> > +
> > +       // If we found anything in the first symbol section, do not search others
> > +       // to avoid duplicates.
> 
> C++ comment

ok, will fix

thanks,
jirka



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux