Skip to content

BPF static linker: support static vars and maps

Andrii Nakryiko bpf netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 40 repliesIn review
  2. v16 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- rebased on top of v3 of BPF static linker extern support patch set;
- dropped selftests doc update, which went into mentioned patch set;
- added skip modifiers for .data/.bss which was missed on initial submission.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6bpftool: strip const/volatile/restrict modifiers from .bss and .data varstools/bpf/bpftool/gen.c+2 -01 reply
2/6libbpf: rename static variables during linkingtools/bpf/bpftool/gen.c tools/lib/bpf/libbpf.h tools/lib/bpf/linker.c +9 more+151 -2834 replies
3/6libbpf: support static map definitionstools/lib/bpf/libbpf.c+5 -21 reply
4/6bpftool: handle transformed static map names in BPF skeletontools/bpf/bpftool/gen.c+22 -141 reply
5/6selftests/bpf: extend linked_vars selftests with static variablestools/testing/selftests/bpf/prog_tests/linked_vars.c tools/testing/selftests/bpf/progs/linked_vars1.c tools/testing/selftests/bpf/progs/linked_vars2.c+14 -62 replies
6/6selftests/bpf: extend linked_maps selftests with static mapstools/testing/selftests/bpf/prog_tests/linked_maps.c tools/testing/selftests/bpf/progs/linked_maps1.c tools/testing/selftests/bpf/progs/linked_maps2.c+50 -11 reply

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchYonghong Song
1/6A-b
2/6
3/6A-b
4/6A-b
5/6A-b A-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/6] BPF static linker: support static vars and maps

Deal with static variables and maps better to make them work with BPF skeleton well. All static variables and maps are renamed in corresponding BTF information so as to have an "<obj_name>.." prefix, which allows to distinguish name-conflicting static entities between multiple linked files.

Also make libbpf support static maps properly. Previously static map reference resulted in the most probably erroneous use of the very *first* defined map, because it was the one with offset 0. Now static map references are resolved properly and thus static maps are finally usable. BPF static linker already supports static maps and no further changes are required, beyond variable renaming.

Patch #1 adds missed documentation of the latest Clang dependency.

N.B. This patch set is based on top of patch set [0].

[0] https://patchwork.kernel.org/project/netdevbpf/list/?series=472405&state=*

v1->v2:
- rebased on top of v3 of BPF static linker extern support patch set;
- dropped selftests doc update, which went into mentioned patch set;
- added skip modifiers for .data/.bss which was missed on initial submission.

Andrii Nakryiko (6):
bpftool: strip const/volatile/restrict modifiers from .bss and .data
vars
libbpf: rename static variables during linking
libbpf: support static map definitions
bpftool: handle transformed static map names in BPF skeleton selftests/bpf: extend linked_vars selftests with static variables selftests/bpf: extend linked_maps selftests with static maps

 tools/bpf/bpftool/gen.c                       |  40 +++---
 tools/lib/bpf/libbpf.c                        |   7 +-
 tools/lib/bpf/libbpf.h                        |  12 +-
 tools/lib/bpf/linker.c                        | 121 +++++++++++++++++-
 .../selftests/bpf/prog_tests/linked_maps.c    |  20 ++-
 .../selftests/bpf/prog_tests/linked_vars.c    |  12 +-
 .../selftests/bpf/prog_tests/skeleton.c       |   8 +-
 .../selftests/bpf/prog_tests/static_linked.c  |   8 +-
 .../selftests/bpf/progs/bpf_iter_test_kern4.c |   4 +-
 .../selftests/bpf/progs/linked_maps1.c        |  13 ++
 .../selftests/bpf/progs/linked_maps2.c        |  18 +++
 .../selftests/bpf/progs/linked_vars1.c        |   4 +-
 .../selftests/bpf/progs/linked_vars2.c        |   4 +-
 .../selftests/bpf/progs/test_check_mtu.c      |   4 +-
 .../selftests/bpf/progs/test_cls_redirect.c   |   4 +-
 .../bpf/progs/test_snprintf_single.c          |   2 +-
 .../selftests/bpf/progs/test_sockmap_listen.c |   4 +-
 .../selftests/bpf/progs/test_static_linked1.c |   6 +-
 .../selftests/bpf/progs/test_static_linked2.c |   4 +-
 19 files changed, 244 insertions(+), 51 deletions(-)
Signature · 1 line
2.30.2