mbox series

[v2,0/6] BTF ABI

Message ID 20210622103318.478914-1-gprocida@google.com
Headers show
Series BTF ABI | expand


Giuliano Procida June 22, 2021, 10:33 a.m. UTC

This code was developed by Maria Teguiani who interned with Android
last summer and later by me.

BTF is the BPF type format.

See: https://www.kernel.org/doc/html/latest/bpf/btf.html

The Linux kernel can be compiled with BTF type information. Together
with the kernel and ELF symtabs, it can be used to as an alternative
basis for kernel ABI monitoring.

BTF has several limitations compared with libabigail ABI XML.
Foremost, it supports C types only. There are also some other
significant issues that may be resolved with time. The simplicity of
BTF makes it an ideal vehicle for experimentation.

An ELF object file containing DWARF debug information can be augmented
with BTF debug information using pahole -J. pahole is part of dwarves.

These patches contribute:

- a BTF parser / BTF graph builder
- code to dump BTF information as it is parsed
- a BTF graph difference algorithm to generate graphs of differences
- a C type name generator
- code to serialise a difference graph as a text report

The graph difference algorithm uses a strongly-connected component
finder based on the path-based SCC algorithm. My main contribution
here was the design which allows the BTF graph difference algorithm to
be written in a straightforward recursive style.

New in v2:

- Fixed bug around ELF symbol lifetimes and the use of string_view.
- Performances tweaks making more pieces of the diff algorithm O(N).

Missing from these patches are:

- Some documentation I wrote in markdown format.
- A suite of small tests, of which the C language ones have been used to
  validate the BTF utilities.

I hope this work will be useful to anyone wishing to experiment with
BTF as an ABI representation or who has an interest in graph diff

Feedback is very welcome.


Giuliano Procida (6):
  Allow C++17 code to be compiled
  Tweak clang-format
  BTF: add SCC finder and test
  BTF: add core functionality
  BTF: add btfinfo and btfdiff tools
  BTF: clang-format all the new source files

 .clang-format     |    9 +-
 COMPILING         |    5 +
 configure.ac      |   21 +-
 include/abg-btf.h |  946 ++++++++++++++++++++++++++
 include/abg-scc.h |  121 ++++
 src/Makefile.am   |    9 +-
 src/abg-btf.cc    | 1650 +++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am |    7 +
 tests/test-scc.cc |  220 ++++++
 tools/Makefile.am |   14 +
 tools/btfdiff.cc  |   71 ++
 tools/btfinfo.cc  |   22 +
 12 files changed, 3092 insertions(+), 3 deletions(-)
 create mode 100644 include/abg-btf.h
 create mode 100644 include/abg-scc.h
 create mode 100644 src/abg-btf.cc
 create mode 100644 tests/test-scc.cc
 create mode 100644 tools/btfdiff.cc
 create mode 100644 tools/btfinfo.cc