linux-stable/tools/lib/bpf
Hengqi Chen bb7fa09399 libbpf: Support symbol versioning for uprobe
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>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20230918024813.237475-3-hengqi.chen@gmail.com
2023-09-22 14:27:36 -07:00
..
.gitignore
bpf.c libbpf: Add bpf_link_create support for multi uprobes 2023-08-21 15:51:26 -07:00
bpf.h libbpf: Add bpf_link_create support for multi uprobes 2023-08-21 15:51:26 -07:00
bpf_core_read.h libbpf: Fix BPF_PROBE_READ{_STR}_INTO() on s390x 2023-01-28 12:45:14 -08:00
bpf_endian.h
bpf_gen_internal.h libbpf: Support kfunc detection in light skeleton. 2023-03-22 09:31:05 -07:00
bpf_helpers.h libbpf: Add __percpu_kptr macro definition 2023-09-08 08:42:18 -07:00
bpf_prog_linfo.c
bpf_tracing.h libbpf: Use local includes inside the library 2023-08-04 15:06:46 -07:00
btf.c libbpf: Add basic BTF sanity validation 2023-09-08 08:42:17 -07:00
btf.h
btf_dump.c libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE 2023-05-01 15:37:38 +02:00
Build libbpf: Move elf_find_func_offset* functions to elf object 2023-08-21 15:51:25 -07:00
elf.c libbpf: Support symbol versioning for uprobe 2023-09-22 14:27:36 -07:00
gen_loader.c libbpf: Store zero fd to fd_array for loader kfunc relocation 2023-05-16 22:09:23 -07:00
hashmap.c libbpf: Hashmap interface update to allow both long and void* keys/values 2022-11-09 20:45:14 -08:00
hashmap.h libbpf: Remove HASHMAP_INIT static initialization helper 2023-07-11 09:40:05 -07:00
libbpf.c libbpf: Support symbol versioning for uprobe 2023-09-22 14:27:36 -07:00
libbpf.h libbpf: Add bpf_object__unpin() 2023-08-23 17:10:09 -07:00
libbpf.map libbpf: Add bpf_object__unpin() 2023-08-23 17:10:09 -07:00
libbpf.pc.template
libbpf_common.h libbpf: Add helper macro to clear opts structs 2023-07-19 10:07:28 -07:00
libbpf_errno.c libbpf: Optimized return value in libbpf_strerror when errno is libbpf errno 2022-12-14 18:39:33 +01:00
libbpf_internal.h libbpf: Add uprobe multi link detection 2023-08-21 15:51:26 -07:00
libbpf_legacy.h
libbpf_probes.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-06-08 11:35:14 -07:00
libbpf_version.h libbpf: Start v1.3 development cycle 2023-05-23 21:39:12 +02:00
linker.c libbpf: Fix double-free when linker processes empty sections 2023-03-27 20:02:15 -07:00
Makefile libbpf: fix typos in Makefile 2023-08-02 13:58:51 -07:00
netlink.c xsk: add new netlink attribute dedicated for ZC max frags 2023-07-19 09:56:49 -07:00
nlattr.c libbpf: Fix alen calculation in libbpf_nla_dump_errormsg() 2023-02-10 15:27:22 -08:00
nlattr.h libbpf: add API to get XDP/XSK supported features 2023-02-02 20:48:24 -08:00
relo_core.c libbpf: fix signedness determination in CO-RE relo handling logic 2023-08-23 21:13:48 -07:00
relo_core.h
ringbuf.c libbpf: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
skel_internal.h
str_error.c
str_error.h
strset.c libbpf: Hashmap interface update to allow both long and void* keys/values 2022-11-09 20:45:14 -08:00
strset.h
usdt.bpf.h libbpf: Use local includes inside the library 2023-08-04 15:06:46 -07:00
usdt.c libbpf: Add uprobe multi link support to bpf_program__attach_usdt 2023-08-21 15:51:26 -07:00
zip.c libbpf: Ignore warnings about "inefficient alignment" 2023-03-16 18:20:08 +01:00
zip.h libbpf: Implement basic zip archive parsing support 2023-03-01 16:05:34 -08:00