BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Hengqi Chen <hengqi.chen@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH bpf-next] libbpf: Allow Golang symbols in uprobe secdef
Date: Mon, 25 Sep 2023 10:19:03 +0200	[thread overview]
Message-ID: <ZRFCd6sY5bp29JRB@krava> (raw)
In-Reply-To: <20230925025722.46580-1-hengqi.chen@gmail.com>

On Mon, Sep 25, 2023 at 02:57:22AM +0000, Hengqi Chen wrote:
> 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);

could you please make that work for uprobe.multi (attach_uprobe_multi)
as well?

it uses %ms at the moment and it seems it won't get pass the space
in the symbol name

thanks,
jirka

>  	switch (n) {
>  	case 1:
> -- 
> 2.34.1
> 
> 

  reply	other threads:[~2023-09-25  8:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25  2:57 [PATCH bpf-next] libbpf: Allow Golang symbols in uprobe secdef Hengqi Chen
2023-09-25  8:19 ` Jiri Olsa [this message]
2023-09-27  2:12   ` Hengqi Chen
2023-09-25 23:15 ` Andrii Nakryiko
2023-09-27  2:17   ` Hengqi Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRFCd6sY5bp29JRB@krava \
    --to=olsajiri@gmail.com \
    --cc=acme@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hengqi.chen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox