linux-stable/tools
Yonghong Song 5baf92a2c4 libbpf: Fix build issue with llvm-readelf
[ Upstream commit 0908a66ad1 ]

There are cases where clang compiler is packaged in a way
readelf is a symbolic link to llvm-readelf. In such cases,
llvm-readelf will be used instead of default binutils readelf,
and the following error will appear during libbpf build:

#  Warning: Num of global symbols in
#   /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/sharedobjs/libbpf-in.o (367)
#   does NOT match with num of versioned symbols in
#   /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.so libbpf.map (383).
#   Please make sure all LIBBPF_API symbols are versioned in libbpf.map.
#  --- /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf_global_syms.tmp ...
#  +++ /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf_versioned_syms.tmp ...
#  @@ -324,6 +324,22 @@
#   btf__str_by_offset
#   btf__type_by_id
#   btf__type_cnt
#  +LIBBPF_0.0.1
#  +LIBBPF_0.0.2
#  +LIBBPF_0.0.3
#  +LIBBPF_0.0.4
#  +LIBBPF_0.0.5
#  +LIBBPF_0.0.6
#  +LIBBPF_0.0.7
#  +LIBBPF_0.0.8
#  +LIBBPF_0.0.9
#  +LIBBPF_0.1.0
#  +LIBBPF_0.2.0
#  +LIBBPF_0.3.0
#  +LIBBPF_0.4.0
#  +LIBBPF_0.5.0
#  +LIBBPF_0.6.0
#  +LIBBPF_0.7.0
#   libbpf_attach_type_by_name
#   libbpf_find_kernel_btf
#   libbpf_find_vmlinux_btf_id
#  make[2]: *** [Makefile:184: check_abi] Error 1
#  make[1]: *** [Makefile:140: all] Error 2

The above failure is due to different printouts for some ABS
versioned symbols. For example, with the same libbpf.so,
  $ /bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep "LIBBPF" | grep ABS
     134: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.5.0
     202: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.6.0
     ...
  $ /opt/llvm/bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep "LIBBPF" | grep ABS
     134: 0000000000000000     0 OBJECT  GLOBAL DEFAULT   ABS LIBBPF_0.5.0@@LIBBPF_0.5.0
     202: 0000000000000000     0 OBJECT  GLOBAL DEFAULT   ABS LIBBPF_0.6.0@@LIBBPF_0.6.0
     ...
The binutils readelf doesn't print out the symbol LIBBPF_* version and llvm-readelf does.
Such a difference caused libbpf build failure with llvm-readelf.

The proposed fix filters out all ABS symbols as they are not part of the comparison.
This works for both binutils readelf and llvm-readelf.

Reported-by: Delyan Kratunov <delyank@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220204214355.502108-1-yhs@fb.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-13 21:00:56 +02:00
..
accounting
arch x86/speculation: Rename RETPOLINE_AMD to RETPOLINE_LFENCE 2022-03-11 12:11:49 +01:00
bootconfig tools/bootconfig: Fix tracing_on option checking in ftrace2bconf.sh 2021-09-26 14:08:59 +02:00
bpf tools/resolve_btfids: Do not print any commands when building silently 2022-02-08 18:30:39 +01:00
build tools build: Remove needless libpython-version feature check that breaks test-all fast path 2021-12-14 11:32:42 +01:00
cgroup tools/cgroup/slabinfo.py: updated to work on current kernel 2021-05-07 11:04:31 +02:00
debugging
edid
firewire
firmware
gpio tools: gpio: fix %llu warning in gpio-watch.c 2021-01-27 11:55:20 +01:00
hv
iio
include bpf: Fix comment for helper bpf_current_task_under_cgroup() 2022-04-08 14:40:43 +02:00
io_uring
kvm/kvm_stat tools/kvm_stat: Add restart delay 2021-04-16 11:43:20 +02:00
laptop
leds
lib libbpf: Fix build issue with llvm-readelf 2022-04-13 21:00:56 +02:00
memory-model
objtool objtool: Fix static_call list generation 2021-11-18 14:04:02 +01:00
pci
pcmcia
perf perf symbols: Fix symbol size calculation condition 2022-03-23 09:13:29 +01:00
power tweewide: Fix most Shebang lines 2021-05-22 11:40:55 +02:00
scripts tools: Allow proper CC/CXX/... override with LLVM=1 in Makefile.include 2021-07-31 08:16:10 +02:00
spi
testing selftests: test_vxlan_under_vrf: Fix broken test case 2022-04-08 14:40:29 +02:00
thermal/tmon tools/thermal/tmon: Add cross compiling support 2021-09-18 13:40:07 +02:00
time
usb usb: testusb: Fix for showing the connection speed 2021-10-09 14:40:56 +02:00
virtio tools/virtio: fix virtio_test execution 2022-04-08 14:39:47 +02:00
vm tools/vm/page-types: remove dependency on opt_file for idle page tracking 2021-10-09 14:40:57 +02:00
wmi
Makefile