Skip to content

bpf2go: type *btf.Pointer: not supported #1066

Answered by lmb
cleverhu asked this question in Q&A
Discussion options

You must be logged in to vote
struct openat_args {
    int flags;
    const char *fname_ptr;
    char fname[NAME_MAX];
};

The problem here is fname_ptr as you've probably figured out. Pointers are not supported because we can't put C pointer values into Go pointer types. Taking a pointer from kernel space and doing something with it in user space in general is complicated. The way to work around this is by changing the type declaration:

struct openat_args {
    int flags;
    uintptr_t fname_ptr;
    char fname[NAME_MAX];
};

Instead of a pointer you store the raw value of the pointer. In userspace you can retrieve that value and do with it what you want (maybe via ptrace?), but you can't stuff it into a Go pointer.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cleverhu
Comment options

Answer selected by cleverhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bpf2go Topics related to the bpf2go tool
2 participants
Converted from issue

This discussion was converted from issue #1064 on June 15, 2023 08:13.