libbpf: Expose BPF program's function name

Add APIs to get BPF program function name, as opposed to bpf_program__title(),
which returns BPF program function's section name. Function name has a benefit
of being a valid C identifier and uniquely identifies a specific BPF program,
while section name can be duplicated across multiple independent BPF programs.

Add also bpf_object__find_program_by_name(), similar to
bpf_object__find_program_by_title(), to facilitate looking up BPF programs by
their C function names.

Convert one of selftests to new API for look up.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20191214014341.3442258-9-andriin@fb.com
This commit is contained in:
Andrii Nakryiko
2019-12-13 17:43:32 -08:00
committed by Andrii Nakryiko
parent 5ec0ba6530
commit 418c07226a
3 changed files with 32 additions and 7 deletions

View File

@@ -212,6 +212,8 @@ LIBBPF_0.0.6 {
LIBBPF_0.0.7 {
global:
btf_dump__emit_type_decl;
bpf_object__find_program_by_name;
bpf_program__attach;
bpf_program__name;
btf__align_of;
} LIBBPF_0.0.6;