From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roman Gushchin Subject: [PATCH net-next 2/5] libbpf: prefer global symbols as bpf program name source Date: Thu, 30 Nov 2017 13:42:59 +0000 Message-ID: <20171130134302.2840-3-guro@fb.com> References: <20171130134302.2840-1-guro@fb.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , , , To: Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:50722 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbdK3Nnz (ORCPT ); Thu, 30 Nov 2017 08:43:55 -0500 In-Reply-To: <20171130134302.2840-1-guro@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: Libbpf picks the name of the first symbol in the corresponding elf section to use as a program name. But without taking symbol's scope into account it may end's up with some local label as a program name. E.g.: $ bpftool cglist /sys/fs/cgroup/system.slice/tmp.mount/ 16 device LBB0_10 Fix this by preferring global symbols as program name. For instance: $ bpftool cglist /sys/fs/cgroup/system.slice/tmp.mount/ 17 device bpf_prog1 Signed-off-by: Roman Gushchin Cc: Martin KaFai Lau Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Jakub Kicinski --- tools/lib/bpf/libbpf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 9f2410beaa18..5191afd46556 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -387,6 +387,8 @@ bpf_object__init_prog_names(struct bpf_object *obj) continue; if (sym.st_shndx != prog->idx) continue; + if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL) + continue; name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, -- 2.14.3