This series adds support for resolving function calls to functions marked as 'extern' in eBPF source files, by resolving the function call targets at load time. For now, this only works by static linking (i.e., copying over the instructions from the function target. Once the kernel support for dynamic linking lands, support can be added for having a function target be an already loaded program fd instead of a bpf object. The API I'm proposing for this is that the caller specifies an explicit mapping between extern function names and function names in the target object file. This is to support the XDP multi-prog case, where the dispatcher program may not necessarily have control over function names in the target programs, so simple function name resolution can't be used. I'm sending this series as an RFC because it's still a bit rough around the edges: There are several places where I'm handling things in a way I'm pretty sure is not the right way. And while this works for the simple programs added to the selftest in patch 3, it fails with more complicated target programs. My problem is that I don't really know what the right thing to do is for these things, so I've marked them with FIXME comments in the code, in the hope that someone more knowledgeable can suggest fixes. Other regular RFC comments are welcome as well, of course; the API in particular could use a second set of eyes or two :) --- Toke Høiland-Jørgensen (3): libbpf: Add new bpf_object__load2() using new-style opts libbpf: Handle function externs and support static linking selftests/bpf: Add selftest for XDP multiprogs tools/lib/bpf/btf.c | 10 + tools/lib/bpf/libbpf.c | 299 ++++++++++++++++---- tools/lib/bpf/libbpf.h | 28 ++ tools/lib/bpf/libbpf.map | 1 .../selftests/bpf/prog_tests/xdp_multiprog.c | 52 +++ tools/testing/selftests/bpf/progs/xdp_drop.c | 13 + tools/testing/selftests/bpf/progs/xdp_multiprog.c | 26 ++ 7 files changed, 366 insertions(+), 63 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_multiprog.c create mode 100644 tools/testing/selftests/bpf/progs/xdp_drop.c create mode 100644 tools/testing/selftests/bpf/progs/xdp_multiprog.c