All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: Allow Golang symbols in uprobe secdef
@ 2023-09-25  2:57 Hengqi Chen
  2023-09-25  8:19 ` Jiri Olsa
  2023-09-25 23:15 ` Andrii Nakryiko
  0 siblings, 2 replies; 5+ messages in thread
From: Hengqi Chen @ 2023-09-25  2:57 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, andrii, hengqi.chen, Arnaldo Carvalho de Melo

Golang symbols in ELF files are different from C/C++
which contains special characters like '*', '(' and ')'.
With generics, things get more complicated, there are
symbols like:

  github.com/cilium/ebpf/internal.(*Deque[go.shape.interface {
   Format(fmt.State, int32); TypeName() string;
  github.com/cilium/ebpf/btf.copy() github.com/cilium/ebpf/btf.Type
  }]).Grow

Add " ()*,-/;[]{}" (in alphabetical order) to support matching
against such symbols. Note that ']' and '-' should be the first
and last characters in the %m range as sscanf required.

A working example can be found at this repo ([0]).

  [0]: https://github.com/chenhengqi/libbpf-go-symbols

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b4758e54a815..de0e068195ab 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -11630,7 +11630,7 @@ static int attach_uprobe(const struct bpf_program *prog, long cookie, struct bpf
 
 	*link = NULL;
 
-	n = sscanf(prog->sec_name, "%m[^/]/%m[^:]:%m[a-zA-Z0-9_.@]+%li",
+	n = sscanf(prog->sec_name, "%m[^/]/%m[^:]:%m[]a-zA-Z0-9 ()*,./;@[_{}-]+%li",
 		   &probe_type, &binary_path, &func_name, &offset);
 	switch (n) {
 	case 1:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-27  2:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25  2:57 [PATCH bpf-next] libbpf: Allow Golang symbols in uprobe secdef Hengqi Chen
2023-09-25  8:19 ` Jiri Olsa
2023-09-27  2:12   ` Hengqi Chen
2023-09-25 23:15 ` Andrii Nakryiko
2023-09-27  2:17   ` Hengqi Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.