linux/tools
Martin KaFai Lau f0187f0b17 bpf: libbpf: Refactor and bug fix on the bpf_func_info loading logic
This patch refactor and fix a bug in the libbpf's bpf_func_info loading
logic.  The bug fix and refactoring are targeting the same
commit 2993e0515b ("tools/bpf: add support to read .BTF.ext sections")
which is in the bpf-next branch.

1) In bpf_load_program_xattr(), it should retry when errno == E2BIG
   regardless of log_buf and log_buf_sz.  This patch fixes it.

2) btf_ext__reloc_init() and btf_ext__reloc() are essentially
   the same except btf_ext__reloc_init() always has insns_cnt == 0.
   Hence, btf_ext__reloc_init() is removed.

   btf_ext__reloc() is also renamed to btf_ext__reloc_func_info()
   to get ready for the line_info support in the next patch.

3) Consolidate func_info section logic from "btf_ext_parse_hdr()",
   "btf_ext_validate_func_info()" and "btf_ext__new()" to
   a new function "btf_ext_copy_func_info()" such that similar
   logic can be reused by the later libbpf's line_info patch.

4) The next line_info patch will store line_info_cnt instead of
   line_info_len in the bpf_program because the kernel is taking
   line_info_cnt also.  It will save a few "len" to "cnt" conversions
   and will also save some function args.

   Hence, this patch also makes bpf_program to store func_info_cnt
   instead of func_info_len.

5) btf_ext depends on btf.  e.g. the func_info's type_id
   in ".BTF.ext" is not useful when ".BTF" is absent.
   This patch only init the obj->btf_ext pointer after
   it has successfully init the obj->btf pointer.

   This can avoid always checking "obj->btf && obj->btf_ext"
   together for accessing ".BTF.ext".  Checking "obj->btf_ext"
   alone will do.

6) Move "struct btf_sec_func_info" from btf.h to btf.c.
   There is no external usage outside btf.c.

Fixes: 2993e0515b ("tools/bpf: add support to read .BTF.ext sections")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2018-12-09 13:54:38 -08:00
..
accounting delayacct: track delays from thrashing cache pages 2018-10-26 16:26:32 -07:00
arch tools headers barrier: Fix arm64 tools build failure wrt smp_load_{acquire,release} 2018-11-01 10:07:43 -03:00
bpf bpf: Expect !info.func_info and insn_off name changes in test_btf/libbpf/bpftool 2018-12-05 18:48:40 -08:00
build Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-08-15 15:04:25 -07:00
cgroup
crypto crypto: tools - Add cryptostat userspace 2018-09-28 12:46:26 +08:00
firewire
gpio Linux 4.16-rc5 2018-03-18 17:48:59 +01:00
hv tools: hv: fcopy: set 'error' in case an unknown operation was requested 2018-09-30 08:49:55 -07:00
iio iio: Add modifier for DUV light 2018-07-23 19:18:10 +01:00
include bpf: tools: Sync uapi bpf.h 2018-12-09 13:54:38 -08:00
kvm/kvm_stat tools/kvm_stat: cut down decimal places in update interval dialog 2018-10-01 15:40:59 +02:00
laptop
leds
lib bpf: libbpf: Refactor and bug fix on the bpf_func_info loading logic 2018-12-09 13:54:38 -08:00
memory-model tools/memory-model: Add more LKMM limitations 2018-10-02 10:28:04 +02:00
nfsd
objtool Merge branch 'core/urgent' into x86/urgent, to pick up objtool fix 2018-11-03 23:42:16 +01:00
pci tools: PCI: Change pcitest compiling process 2018-10-03 11:19:52 +01:00
pcmcia
perf perf/urgent improvements and fixes: 2018-11-06 20:03:11 +01:00
power tools cpupower: Override CFLAGS assignments 2018-11-06 08:54:16 -07:00
scripts Kbuild: fix # escaping in .cmd files for future Make 2018-04-11 00:03:02 +09:00
spi spi: spidev_test: Improve decoded text part of hex dump 2018-09-04 17:00:37 +01:00
testing bpf: Add unit tests for bpf_line_info 2018-12-09 13:54:38 -08:00
thermal/tmon tools/thermal: tmon: fix for segfault 2018-03-27 09:51:23 +02:00
time
usb usbip: tools: fix atoi() on non-null terminated string 2018-10-18 19:44:39 +02:00
virtio tools/virtio: add kmalloc_array stub 2018-07-27 16:54:40 +03:00
vm tools/vm/page-types.c: fix "defined but not used" warning 2018-09-04 16:45:02 -07:00
wmi
Makefile tools: PCI: Change pcitest compiling process 2018-10-03 11:19:52 +01:00