Skip to content

BTF-to-C dumper fixes and improvements

Andrii Nakryiko bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 2 repliesApplied 6/6
  2. v16 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- fix bug in natural alignment detection (Eduard).

Patches in v2 All 6 applied

#Subject and filesSizeRepliesApplied
1/6libbpf: fix single-line struct definition output in btf_dumptools/lib/bpf/btf_dump.c+5 -20 repliesApplied
2/6libbpf: handle non-standardly sized enums better in BTF-to-C dumpertools/lib/bpf/btf_dump.c+38 -00 repliesApplied
3/6selftests/bpf: add non-standardly sized enum tests for btf_dumptools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c+36 -00 repliesApplied
4/6libbpf: fix btf__align_of() by taking into account field offsetstools/lib/bpf/btf.c+13 -00 repliesApplied
5/6libbpf: fix BTF-to-C converter's padding logictools/lib/bpf/btf_dump.c tools/testing/selftests/bpf/progs/btf_dump_test_case_bitfields.c tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c+164 -652 repliesApplied
6/6selftests/bpf: add few corner cases to test padding handling of btf_dumptools/testing/selftests/bpf/progs/btf_dump_test_case_packing.c tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c+164 -10 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/6] BTF-to-C dumper fixes and improvements

Fix few tricky issues in libbpf's BTF-to-C converter, discovered thanks to Per's reports and his randomized testing script.

Most notably there is a much improved and correct padding handling. But also it turned out that some corner cases with enums weren't handled correctly (mode(byte) attribute was a new discovery for me). See respective patches for more details.

v1->v2:
- fix bug in natural alignment detection (Eduard).

Cc Eduard Zingerman <[email protected]>
Cc Per Sundström XP <[email protected]>

Andrii Nakryiko (6):
libbpf: fix single-line struct definition output in btf_dump
libbpf: handle non-standardly sized enums better in BTF-to-C dumper selftests/bpf: add non-standardly sized enum tests for btf_dump
libbpf: fix btf__align_of() by taking into account field offsets
libbpf: fix BTF-to-C converter's padding logic selftests/bpf: add few corner cases to test padding handling of
btf_dump

 tools/lib/bpf/btf.c                           |  13 ++
 tools/lib/bpf/btf_dump.c                      | 214 ++++++++++++++----
 .../bpf/progs/btf_dump_test_case_bitfields.c  |   2 +-
 .../bpf/progs/btf_dump_test_case_packing.c    |  61 ++++-
 .../bpf/progs/btf_dump_test_case_padding.c    | 162 +++++++++++--
 .../bpf/progs/btf_dump_test_case_syntax.c     |  36 +++
 6 files changed, 420 insertions(+), 68 deletions(-)
Signature · 1 line
2.30.2