From: Hengqi Chen <hengqi.chen@gmail.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, alan.maguire@oracle.com
Subject: Re: [PATCH bpf-next v2 2/3] libbpf: Support symbol versioning for uprobe
Date: Sun, 10 Sep 2023 20:42:24 +0800 [thread overview]
Message-ID: <CAEyhmHQQ2CB6S0jbrZ86PGsQnc8XSrZ3v8goC3O5=tgAcn_T0A@mail.gmail.com> (raw)
In-Reply-To: <ZP2SEyyS5RFdZzaY@krava>
On Sun, Sep 10, 2023 at 5:53 PM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Tue, Sep 05, 2023 at 03:12:56PM +0000, Hengqi Chen wrote:
> > In current implementation, we assume that symbol found in .dynsym section
> > would have a version suffix and use it to compare with symbol user supplied.
> > According to the spec ([0]), this assumption is incorrect, the version info
> > of dynamic symbols are stored in .gnu.version and .gnu.version_d sections
> > of ELF objects. For example:
> >
> > $ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock
> > 000000000009b1a0 T __pthread_rwlock_wrlock@GLIBC_2.2.5
> > 000000000009b1a0 T pthread_rwlock_wrlock@@GLIBC_2.34
> > 000000000009b1a0 T pthread_rwlock_wrlock@GLIBC_2.2.5
> >
> > $ readelf -W --dyn-syms /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock
> > 706: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 __pthread_rwlock_wrlock@GLIBC_2.2.5
> > 2568: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@@GLIBC_2.34
> > 2571: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@GLIBC_2.2.5
> >
> > In this case, specify pthread_rwlock_wrlock@@GLIBC_2.34 or
> > pthread_rwlock_wrlock@GLIBC_2.2.5 in bpf_uprobe_opts::func_name won't work.
> > Because the qualified name does NOT match `pthread_rwlock_wrlock` (without
> > version suffix) in .dynsym sections.
> >
> > This commit implements the symbol versioning for dynsym and allows user to
> > specify symbol in the following forms:
> > - func
> > - func@LIB_VERSION
> > - func@@LIB_VERSION
> >
> > In case of symbol conflicts, error out and users should resolve it by
> > specifying a qualified name.
> >
> > [0]: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html
> >
> > Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
>
> I have a question below, but other than that
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
>
> thanks,
> jirka
>
>
> SNIP
>
> > @@ -119,6 +148,7 @@ static struct elf_sym *elf_sym_iter_next(struct elf_sym_iter *iter)
> > struct elf_sym *ret = &iter->sym;
> > GElf_Sym *sym = &ret->sym;
> > const char *name = NULL;
> > + GElf_Versym versym;
> > Elf_Scn *sym_scn;
> > size_t idx;
> >
> > @@ -138,12 +168,112 @@ static struct elf_sym *elf_sym_iter_next(struct elf_sym_iter *iter)
> >
> > iter->next_sym_idx = idx + 1;
> > ret->name = name;
> > + ret->ver = 0;
> > + ret->hidden = false;
> > +
> > + if (iter->versyms) {
> > + if (!gelf_getversym(iter->versyms, idx, &versym))
> > + continue;
> > + ret->ver = versym & VERSYM_VERSION;
> > + ret->hidden = versym & VERSYM_HIDDEN;
>
> the doc mentions value 1 being special, also I can see readelf
> code checking on that.. is that taken into account?
>
Yes. For value 1, there is a corresponding version def, so no difference.
> > + }
> > return ret;
> > }
> >
> > return NULL;
> > }
> >
>
> SNIP
next prev parent reply other threads:[~2023-09-10 12:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-05 15:12 [PATCH bpf-next v2 0/3] libbpf: Support symbol versioning for uprobe Hengqi Chen
2023-09-05 15:12 ` [PATCH bpf-next v2 1/3] libbpf: Resolve symbol conflicts at the same offset " Hengqi Chen
2023-09-08 14:30 ` Alan Maguire
2023-09-10 9:53 ` Jiri Olsa
2023-09-05 15:12 ` [PATCH bpf-next v2 2/3] libbpf: Support symbol versioning " Hengqi Chen
2023-09-08 15:07 ` Alan Maguire
2023-09-10 12:39 ` Hengqi Chen
2023-09-10 9:53 ` Jiri Olsa
2023-09-10 12:42 ` Hengqi Chen [this message]
2023-09-05 15:12 ` [PATCH bpf-next v2 3/3] selftests/bpf: Add tests for " Hengqi Chen
2023-09-08 14:40 ` Alan Maguire
2023-09-10 9:53 ` Jiri Olsa
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='CAEyhmHQQ2CB6S0jbrZ86PGsQnc8XSrZ3v8goC3O5=tgAcn_T0A@mail.gmail.com' \
--to=hengqi.chen@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=olsajiri@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.