libbpf / bpftool

Automated upstream mirror for bpftool stand-alone build.
Other
377 stars 69 forks source link

"libbpf: map 'xxx': unsupported map linkage static" in Android #120

Closed GorilaMond closed 10 months ago

GorilaMond commented 10 months ago

On the system there is bpftool v7.0.0 installed:

$ bpftool --version
bpftool v7.0.0
using libbpf v1.0
features: libbpf_strict

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

These code were compiled successfully. But when the binaries of bootstrap and minimal_legency run in Android phone, it report some err:

P720S11:/data/local/tmp/bpf/android # ./bootstrap
libbpf: map 'exec_start': unsupported map linkage static.
libbpf: failed to initialize skeleton BPF object 'bootstrap_bpf': -95
Failed to open and load BPF skeleton

2|P720S11:/data/local/tmp/bpf/android # ./minimal_legacy
libbpf: loading object 'minimal_legacy_bpf' from buffer
libbpf: elf: section(3) tp/syscalls/sys_enter_write, size 264, link 0, flags 6, type=1
libbpf: sec 'tp/syscalls/sys_enter_write': found program 'handle_tp' at insn offset 0 (0 bytes), code size 33 insns (264 bytes)
libbpf: elf: section(4) .reltp/syscalls/sys_enter_write, size 16, link 22, flags 0, type=9
libbpf: elf: section(5) license, size 13, link 0, flags 3, type=1
libbpf: license of minimal_legacy_bpf is Dual BSD/GPL
libbpf: elf: section(6) .maps, size 32, link 0, flags 3, type=1
libbpf: elf: section(7) .rodata.str1.1, size 28, link 0, flags 32, type=1
libbpf: elf: section(13) .BTF, size 864, link 0, flags 0, type=1
libbpf: elf: section(15) .BTF.ext, size 240, link 0, flags 0, type=1
libbpf: elf: section(22) .symtab, size 936, link 1, flags 0, type=2
libbpf: looking for externs among 39 symbols...
libbpf: collected 0 externs total
libbpf: map 'my_pid_map': unsupported map linkage static.
libbpf: failed to initialize skeleton BPF object 'minimal_legacy_bpf': -95
Failed to open and load BPF skeleton

The version of the Android is 13 and its kernel version is 5.4.210.

How could I run them successfully?

qmonnet commented 10 months ago

I don't know, I'm not familiar with building or working on Android.

I note there are some similarities with https://github.com/libbpf/bpftool/issues/77 / https://github.com/libbpf/libbpf/issues/720. Although in that other report, the issue was that bpftool 7.1.0 doesn't compile (but 7.0.0 does), whereas in your case 7.0.0 compiles but the binaries don't run. Cc @kochia5 just in case.

I'm not sure this has much to do with bpftool itself though, it seems to me that this is related to libbpf

ghost commented 10 months ago

I have same problem, I think it's more about libbpf What's best way to ask questions there? Github doesn't seem to be active.

qmonnet commented 10 months ago

GitHub repositories for libbpf and bpftool are active, Andrii replied on the libbpf issue but didn't get any follow-up by the poster. You posted your own comment only three minutes before asking here.

Both repositories are mostly about tasks related to mirroring libbpf and bpftool, and running the CI. The preferred way to report issues is usually through the BPF mailing list - this one has a lot more people looking at it, if this was what you meant.

GorilaMond commented 10 months ago

GitHub repositories for libbpf and bpftool are active, Andrii replied on the libbpf issue but didn't get any follow-up by the poster. You posted your own comment only three minutes before asking here.

Both repositories are mostly about tasks related to mirroring libbpf and bpftool, and running the CI. The preferred way to report issues is usually through the BPF mailing list - this one has a lot more people looking at it, if this was what you meant.

OK, I will report issues through the mailing list, thanks for your advice.

waruqi commented 10 months ago

try xmake f -p android -c --require-bpftool=y?

see https://github.com/libbpf/libbpf-bootstrap/issues/130

GorilaMond commented 10 months ago

Yes, I have tried but with on.

---Original--- From: @.> Date: Thu, Nov 2, 2023 09:35 AM To: @.>; Cc: @.>;"State @.>; Subject: Re: [libbpf/bpftool] "libbpf: map 'xxx': unsupported map linkagestatic" in Android (Issue #120)

try xmake f -p android -c --require-bpftool=y?

see libbpf/libbpf-bootstrap#130

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

waruqi commented 10 months ago

I have fixed this error. https://github.com/libbpf/libbpf-bootstrap/pull/237

we can use bpftool 7.2.0 now.