mbox series

[bpf-next,0/3] Handle no-BTF object files better

Message ID 20210319205909.1748642-1-andrii@kernel.org
Headers show
Series Handle no-BTF object files better | expand

Message

Andrii Nakryiko March 19, 2021, 8:59 p.m. UTC
Fix two issues caused by BPF object files with missing BTF type information:
  1. BPF skeleton generated for BPF object files that use global variables but
     are compiled without BTF won't compile.
  2. BPF static linker will crash attempting to fix up BTF for input object
     file with no BTF.

This patch set also extends static linking selftest to validate correct
handling of both conditions now. For that, selftests Makefile is enhanced to
allow selecting whether a given BPF object file should be compiled with BTF or
not, based on naming convention (.nobtf.c suffix).

Andrii Nakryiko (3):
  bpftool: improve skeleton generation for objects without BTF
  libbpf: skip BTF fixup if object file has no BTF
  selftests/bpf: allow compiling BPF objects without BTF

 tools/bpf/bpftool/gen.c                       | 81 +++++++++++++++----
 tools/lib/bpf/linker.c                        |  3 +
 tools/testing/selftests/bpf/Makefile          | 21 +++--
 .../selftests/bpf/prog_tests/static_linked.c  |  6 +-
 .../bpf/progs/test_static_linked3.nobtf.c     | 36 +++++++++
 5 files changed, 123 insertions(+), 24 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_static_linked3.nobtf.c