Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to open BPF object file: Operation not supported (Android Build via xmake) #720

Open
ghost opened this issue Aug 26, 2023 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 26, 2023

From libbpf/bpftool#77

I have following map:

struct
{
  __uint(type, BPF_MAP_TYPE_RINGBUF);
  __uint(max_entries, MAX_ENTRIES);
} ring_map SEC(".maps");

under v7.0.0 it works, under v7.1.0 and v7.2.0 getting an error:
bpftool gen skeleton build/.gens/xxx/android/x86_64/release/rules/bpf/xxx.bpf.o -d -p

libbpf: map 'xxx': unsupported map linkage static.
{
    "error": "failed to open BPF object file: Operation not supported"
}

Reproduce error:

On the system there is bpftool v7.0.0 installed:

bpftool v7.0.0
using libbpf v1.0
features: libbpf_strict, skeletons

Get libbpf-bootstrap repo
git clone --recurse-submodules https://github.com/libbpf/libbpf-bootstrap

try to compile for Android via xmake according to the readme file:

$ git submodule update --init --recursive       # check out libbpf
$ cd examples/c
$ xmake f -p android
$ xmake

works.


Update the bpftool to v7.1.0
git clone --depth 1 --branch v7.1.0 ... && make install
bpftool version:

bpftool v7.1.0
using libbpf v1.1
features: llvm, skeletons

try again to compile via xmake:

[ 13%]: compiling.bpf uprobe.bpf.c
[ 13%]: compiling.bpf minimal.bpf.c
[ 13%]: compiling.bpf fentry.bpf.c
[ 13%]: compiling.bpf minimal_legacy.bpf.c
[ 17%]: cache compiling.release ../../libbpf/src/libbpf.c
[ 33%]: cache compiling.release ../../libbpf/src/netlink.c
[ 44%]: cache compiling.release ../../libbpf/src/bpf.c
[ 44%]: compiling.bpf bootstrap.bpf.c
libbpf: map 'my_pid_map': unsupported map linkage static.
Error: failed to open BPF object file: Operation not supported
error: execv(bpftool gen skeleton build/.gens/minimal_legacy/android/armeabi-v7a/release/rules/bpf/minimal_legacy.bpf.o) failed(161)

failed.

Seems like its for all .maps not only ringbuf.


Same for v.7.2.0

@anakryiko
Copy link
Member

what's your Clang version you are using to build BPF code? Can you try upgrading it and check if that helps?

@qmonnet
Copy link
Member

qmonnet commented Oct 20, 2023

Copying my notes from the bpftool report, just in case it helps.

Bisecting between [libbf] 1.0.0 and 1.1.0 for bpftool (using bpftool 7.0.0), it looks like the issue was introduced in commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=4fcac46c7e107a93030d19c6ea7b90540fc80b1b (3cd45b6). I haven't looked at the details.

I note that there's a commit fixing that one (ce8d078) but that doesn't seem helpful here, it's in the version used by the master branch of bpftool, which fails to generate the skeleton as well.

@ghost
Copy link

ghost commented Oct 20, 2023

Same for 7.3.0 (Github master branch)

bpftool v7.3.0
using libbpf v1.3
features: llvm, skeletons

@anakryiko
Copy link
Member

I think this is due to old Clang that doesn't know how to produce global variables BTF information. Can you guys try to use newer Clang? Or at least please provide a dump of BTF for your BPF object file (bpftool btf dump file <.bpf.o>). Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants