Re: [PATCH v2] libbpf: Improve version handling when attaching uprobe

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

 



On Wed, Apr 26, 2023 at 02:47:27PM -0700, Yonghong Song wrote:
>
>
> On 4/23/23 11:55 AM, Espen Grindhaug wrote:
> > This change fixes the handling of versions in elf_find_func_offset.
> > In the previous implementation, we incorrectly assumed that the
>
> Could you give more explanation/example in the commit message
> what does 'incorrectly' mean here? In which situations the
> current libbpf implementation will not be correct?
>

How about something like this?


libbpf: Improve version handling when attaching uprobe

This change fixes the handling of versions in elf_find_func_offset.

For example, let's assume we are trying to attach an uprobe to pthread_create in
glibc. Prior to this commit, it would fail with an error message saying 'elf:
ambiguous match [...]', this is because there are two entries in the symbol
table with that name.

$ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep pthread_create
0000000000094cc0 T pthread_create@GLIBC_2.2.5
0000000000094cc0 T pthread_create@@GLIBC_2.34

So we go ahead and modify our code to attach to 'pthread_create@@GLIBC_2.34',
and this also fails, but this time with the error 'elf: failed to find symbol
[...]'. This fails because we incorrectly assumed that the version information
would be present in the string found in the string table, but there is only the
string 'pthread_create'.

This patch reworks how we compare the symbol name provided by the user if it is
qualified with a version (using @ or @@). We now look up the correct version
string in the version symbol table before constructing the full name, as also
done above by nm, before comparing.

> > version information would be present in the string found in the
> > string table.
> >
> > We now look up the correct version string in the version symbol
> > table before constructing the full name and then comparing.
> >
> > This patch adds support for both name@version and name@@version to
> > match output of the various elf parsers.
> >
> > Signed-off-by: Espen Grindhaug <espen.grindhaug@xxxxxxxxx>
>
> [...]



[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