[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 Jose E. Marchesi changed: What|Removed |Added Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED --- Comment #20 from Jose E. Marchesi --- This is fixed.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #18 from CVS Commits --- The master branch has been updated by David Faust : https://gcc.gnu.org/g:4f7aa145b796c044526c93f390e68f3b56a1b30a commit r13-4708-g4f7aa145b796c044526c93f390e68f3b56a1b30a Author: David Faust Date: Wed Dec 7 11:47:26 2022 -0800 btf: fix 'extern const void' variables [PR106773] The eBPF loader expects to find BTF_KIND_VAR records for references to extern const void symbols. We were mistakenly identifing these as unsupported types, and as a result skipping emitting VAR records for them. In addition, the internal DWARF representation from which BTF is produced does not generate 'const' modifier DIEs for the void type, which meant in BTF the 'const' qualifier was dropped for 'extern const void' variables. This patch also adds support for generating a const void type in BTF to correct emission for these variables. PR target/106773 gcc/ * btfout.cc (btf_collect_datasec): Correct size of void entries. (btf_dvd_emit_preprocess_cb): Do not skip emitting variables which refer to void types. (btf_init_postprocess): Create 'const void' type record if needed and adjust variables to refer to it as appropriate. gcc/testsuite/ * gcc.dg/debug/btf/btf-pr106773.c: New test.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #19 from CVS Commits --- The master branch has been updated by David Faust : https://gcc.gnu.org/g:70b303049e45c180236a4114f844311652bad002 commit r13-4709-g70b303049e45c180236a4114f844311652bad002 Author: David Faust Date: Wed Dec 7 11:51:59 2022 -0800 btf: correct generation for extern funcs [PR106773] The eBPF loader expects to find entries for functions declared as extern in the corresponding BTF_KIND_DATASEC record, but we were not generating these entries. This patch adds support for the 'extern' linkage of function types in BTF, and creates entries for for them BTF_KIND_DATASEC records as needed. PR target/106773 gcc/ * btfout.cc (get_section_name): New function. (btf_collect_datasec): Use it here. Process functions, marking them 'extern' and generating DATASEC entries for them as appropriate. Move creation of BTF_KIND_FUNC records to here... (btf_dtd_emit_preprocess_cb): ... from here. gcc/testsuite/ * gcc.dg/debug/btf/btf-datasec-2.c: New test. * gcc.dg/debug/btf/btf-function-6.c: New test. include/ * btf.h (enum btf_func_linkage): New. (struct btf_var_secinfo): Update comments with notes about extern functions.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #17 from CVS Commits --- The master branch has been updated by David Faust : https://gcc.gnu.org/g:2bce22e88e1c8486a0f2d42311506a8d3da20fb7 commit r13-4707-g2bce22e88e1c8486a0f2d42311506a8d3da20fb7 Author: David Faust Date: Wed Dec 7 11:44:28 2022 -0800 btf: add 'extern' linkage for variables [PR106773] Add support for the 'extern' linkage value for BTF_KIND_VAR records, which is used for variables declared as extern in the source file. This also fixes a bug with BTF generation for extern variables which have both a non-defining declaration and a defining declaration in the same CU. PR target/106773 gcc/ * btfout.cc (btf_collect_datasec): Mark extern variables as such. (btf_dvd_emit_preprocess_cb): Skip non-defining extern variable decl if there is a defining decl for the same variable. (btf_asm_varent): Accomodate 'extern' linkage. gcc/testsuite/ * gcc.dg/debug/btf/btf-variables-4.c: New test. * gcc.dg/debug/btf/btf-variables-5.c: New test. include/ * btf.h (enum btf_var_linkage): New. (struct btf_var): Update comment to note 'extern' linkage.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #16 from James Hilliard --- (In reply to David Faust from comment #15) > Created attachment 54021 [details] > [v2] DATASEC entries for extern funcs > > v2 fixes an off-by-one bug introduced in the patch which was causing > libbpf: Invalid BTF total size Yeah, this seems to work.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 David Faust changed: What|Removed |Added Attachment #54017|0 |1 is obsolete|| --- Comment #15 from David Faust --- Created attachment 54021 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54021=edit [v2] DATASEC entries for extern funcs v2 fixes an off-by-one bug introduced in the patch which was causing libbpf: Invalid BTF total size
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #14 from James Hilliard --- (In reply to David Faust from comment #13) > Created attachment 54017 [details] > DATASEC entries for extern funcs > > Applies on top of 54002: updated patch > Adds emission of DATASEC entries for extern funcs. Rough, needs cleanup. Seeing a regression in get_func_ip_test.c looks like: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen object /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.linked1.o /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o libbpf: linker: adding object file '/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o'... libbpf: Invalid BTF total size: 25303 libbpf: failed to parse .BTF from /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o: -22 Error: failed to link '/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o': Invalid argument (22) Broken GCC BTF dump: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug btf dump file /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o format raw libbpf: Invalid BTF total size: 25303 Error: failed to load BTF from /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/get_func_ip_test.bpf.o: Invalid argument Working LLVM btf dump: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug btf dump file /home/buildroot/bpf-next/tools/testing/selftests/bpf/get_func_ip_test.bpf.o format raw [1] FUNC_PROTO '(anon)' ret_type_id=2 vlen=0 [2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [3] FUNC 'unused' type_id=1 linkage=global [4] PTR '(anon)' type_id=5 [5] INT 'unsigned long long' size=8 bits_offset=0 nr_bits=64 encoding=(none) [6] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=4 [7] FUNC 'test1' type_id=6 linkage=global [8] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=4 [9] FUNC 'test2' type_id=8 linkage=global [10] PTR '(anon)' type_id=11 [11] FWD 'pt_regs' fwd_kind=struct [12] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=10 [13] FUNC 'test3' type_id=12 linkage=global [14] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=10 [15] FUNC 'test4' type_id=14 linkage=global [16] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=4 [17] FUNC 'test5' type_id=16 linkage=global [18] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1 'ctx' type_id=10 [19] FUNC 'test6' type_id=18 linkage=global [20] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [21] ARRAY '(anon)' type_id=20 index_type_id=22 nr_elems=4 [22] INT '__ARRAY_SIZE_TYPE__' size=4 bits_offset=0 nr_bits=32 encoding=(none) [23] VAR '_license' type_id=21, linkage=global [24] INT '_Bool' size=1 bits_offset=0 nr_bits=8 encoding=BOOL [25] VAR 'CONFIG_X86_KERNEL_IBT' type_id=24, linkage=extern [26] TYPEDEF '__u64' type_id=5 [27] VAR 'test1_result' type_id=26, linkage=global [28] VAR 'test2_result' type_id=26, linkage=global [29] VAR 'test3_result' type_id=26, linkage=global [30] CONST '(anon)' type_id=0 [31] VAR 'bpf_fentry_test3' type_id=30, linkage=extern [32] VAR 'test4_result' type_id=26, linkage=global [33] VAR 'test5_result' type_id=26, linkage=global [34] VAR 'test6_result' type_id=26, linkage=global [35] VAR 'bpf_fentry_test1' type_id=30, linkage=extern [36] VAR 'bpf_fentry_test2' type_id=30, linkage=extern [37] VAR 'bpf_fentry_test4' type_id=30, linkage=extern [38] VAR 'bpf_modify_return_test' type_id=30, linkage=extern [39] DATASEC '.bss' size=0 vlen=6 type_id=27 offset=0 size=8 (VAR 'test1_result') type_id=28 offset=0 size=8 (VAR 'test2_result') type_id=29 offset=0 size=8 (VAR 'test3_result') type_id=32 offset=0 size=8 (VAR 'test4_result') type_id=33 offset=0 size=8 (VAR 'test5_result') type_id=34 offset=0 size=8 (VAR 'test6_result') [40] DATASEC '.kconfig' size=0 vlen=1 type_id=25 offset=0 size=1 (VAR 'CONFIG_X86_KERNEL_IBT') [41] DATASEC '.ksyms' size=0 vlen=5 type_id=31 offset=0 size=1 (VAR 'bpf_fentry_test3') type_id=35 offset=0 size=1 (VAR 'bpf_fentry_test1') type_id=36 offset=0 size=1 (VAR 'bpf_fentry_test2') type_id=37 offset=0 size=1 (VAR 'bpf_fentry_test4') type_id=38 offset=0 size=1 (VAR 'bpf_modify_return_test') [42] DATASEC 'license' size=0 vlen=1 type_id=23 offset=0 size=4 (VAR '_license')
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #13 from David Faust --- Created attachment 54017 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54017=edit DATASEC entries for extern funcs Applies on top of 54002: updated patch Adds emission of DATASEC entries for extern funcs. Rough, needs cleanup.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #12 from James Hilliard --- (In reply to James Hilliard from comment #10) > (In reply to David Faust from comment #9) > > Created attachment 54002 [details] > > updated patch > > > > Update the 'extern' variable marking, and also mark 'extern' funcs. > > That fixes the issue in kfunc_call_test.c Actually I think there's still an issue here, did a full clean test build and am now hitting this error: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen skeleton /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/kfunc_call_test.bpf.linked3.o name kfunc_call_test libbpf: loading object 'kfunc_call_test' from buffer libbpf: elf: section(2) .symtab, size 648, link 1, flags 0, type=2 libbpf: elf: section(3) .data, size 0, link 0, flags 3, type=1 libbpf: elf: skipping section(3) .data (size 0) libbpf: elf: section(4) .bss, size 0, link 0, flags 3, type=8 libbpf: elf: section(5) tc, size 1120, link 0, flags 6, type=1 libbpf: sec 'tc': found program 'kfunc_call_test2' at insn offset 0 (0 bytes), code size 13 insns (104 bytes) libbpf: sec 'tc': found program 'kfunc_call_test1' at insn offset 13 (104 bytes), code size 21 insns (168 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_ref_btf_id' at insn offset 34 (272 bytes), code size 22 insns (176 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_pass' at insn offset 56 (448 bytes), code size 52 insns (416 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_get_mem' at insn offset 108 (864 bytes), code size 32 insns (256 bytes) libbpf: elf: section(6) syscall, size 152, link 0, flags 6, type=1 libbpf: sec 'syscall': found program 'kfunc_syscall_test' at insn offset 0 (0 bytes), code size 15 insns (120 bytes) libbpf: sec 'syscall': found program 'kfunc_syscall_test_null' at insn offset 15 (120 bytes), code size 4 insns (32 bytes) libbpf: elf: section(7) license, size 4, link 0, flags 3, type=1 libbpf: license of kfunc_call_test is GPL libbpf: elf: section(8) .comment, size 43, link 0, flags 30, type=1 libbpf: elf: skipping unrecognized data section(8) .comment libbpf: elf: section(9) .reltc, size 272, link 2, flags 40, type=9 libbpf: elf: section(10) .relsyscall, size 64, link 2, flags 40, type=9 libbpf: elf: section(11) .BTF, size 469068, link 0, flags 0, type=1 libbpf: looking for externs among 27 symbols... libbpf: failed to find BTF for extern 'bpf_kfunc_call_test2' [8134] section: -2 Error: failed to open BPF object file: No such file or directory
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #11 from James Hilliard --- Also hitting this one in cgroup_hierarchical_stats.c: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen skeleton /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/cgroup_hierarchical_stats.bpf.linked3.o name cgroup_hierarchical_stat libbpf: loading object 'cgroup_hierarchical_stat' from buffer libbpf: elf: section(2) .symtab, size 504, link 1, flags 0, type=2 libbpf: elf: section(3) .data, size 0, link 0, flags 3, type=1 libbpf: elf: skipping section(3) .data (size 0) libbpf: elf: section(4) .bss, size 0, link 0, flags 3, type=8 libbpf: elf: section(5) fentry/cgroup_attach_task, size 264, link 0, flags 6, type=1 libbpf: sec 'fentry/cgroup_attach_task': found program 'counter' at insn offset 0 (0 bytes), code size 33 insns (264 bytes) libbpf: elf: section(6) fentry/bpf_rstat_flush, size 656, link 0, flags 6, type=1 libbpf: sec 'fentry/bpf_rstat_flush': found program 'flusher' at insn offset 0 (0 bytes), code size 82 insns (656 bytes) libbpf: elf: section(7) iter.s/cgroup, size 352, link 0, flags 6, type=1 libbpf: sec 'iter.s/cgroup': found program 'dumper' at insn offset 0 (0 bytes), code size 44 insns (352 bytes) libbpf: elf: section(8) .rodata, size 67, link 0, flags 2, type=1 libbpf: elf: section(9) .maps, size 64, link 0, flags 3, type=1 libbpf: elf: section(10) license, size 4, link 0, flags 3, type=1 libbpf: license of cgroup_hierarchical_stat is GPL libbpf: elf: section(11) .comment, size 43, link 0, flags 30, type=1 libbpf: elf: skipping unrecognized data section(11) .comment libbpf: elf: section(12) .relfentry/cgroup_attach_task, size 48, link 2, flags 40, type=9 libbpf: elf: section(13) .relfentry/bpf_rstat_flush, size 96, link 2, flags 40, type=9 libbpf: elf: section(14) .reliter.s/cgroup, size 64, link 2, flags 40, type=9 libbpf: elf: section(15) .BTF, size 468873, link 0, flags 0, type=1 libbpf: looking for externs among 21 symbols... libbpf: failed to find BTF for extern 'cgroup_rstat_updated' [8134] section: -2 Error: failed to open BPF object file: No such file or directory
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #10 from James Hilliard --- (In reply to David Faust from comment #9) > Created attachment 54002 [details] > updated patch > > Update the 'extern' variable marking, and also mark 'extern' funcs. That fixes the issue in kfunc_call_test.c but I'm still hitting a few like this in cb_refs.c: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen skeleton /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/cb_refs.bpf.linked3.o name cb_refs libbpf: loading object 'cb_refs' from buffer libbpf: elf: section(2) .symtab, size 504, link 1, flags 0, type=2 libbpf: elf: section(3) .text, size 240, link 0, flags 6, type=1 libbpf: sec '.text': found program 'cb1' at insn offset 0 (0 bytes), code size 4 insns (32 bytes) libbpf: sec '.text': found program 'cb2' at insn offset 4 (32 bytes), code size 9 insns (72 bytes) libbpf: sec '.text': found program 'cb' at insn offset 13 (104 bytes), code size 2 insns (16 bytes) libbpf: sec '.text': found program 'cb3' at insn offset 15 (120 bytes), code size 15 insns (120 bytes) libbpf: elf: section(4) .data, size 0, link 0, flags 3, type=1 libbpf: elf: skipping section(4) .data (size 0) libbpf: elf: section(5) .bss, size 0, link 0, flags 3, type=8 libbpf: elf: section(6) ?tc, size 648, link 0, flags 6, type=1 libbpf: sec '?tc': found program 'underflow_prog' at insn offset 0 (0 bytes), code size 17 insns (136 bytes) libbpf: sec '?tc': found program 'leak_prog' at insn offset 17 (136 bytes), code size 26 insns (208 bytes) libbpf: sec '?tc': found program 'nested_cb' at insn offset 43 (344 bytes), code size 20 insns (160 bytes) libbpf: sec '?tc': found program 'non_cb_transfer_ref' at insn offset 63 (504 bytes), code size 18 insns (144 bytes) libbpf: elf: section(7) license, size 4, link 0, flags 3, type=1 libbpf: license of cb_refs is GPL libbpf: elf: section(8) .maps, size 32, link 0, flags 3, type=1 libbpf: elf: section(9) .comment, size 43, link 0, flags 30, type=1 libbpf: elf: skipping unrecognized data section(9) .comment libbpf: elf: section(10) .rel.text, size 80, link 2, flags 40, type=9 libbpf: elf: section(11) .rel?tc, size 224, link 2, flags 40, type=9 libbpf: elf: section(12) .BTF, size 468228, link 0, flags 0, type=1 libbpf: looking for externs among 21 symbols... libbpf: failed to find BTF for extern 'bpf_kfunc_call_test_release' [8112] section: -2 Error: failed to open BPF object file: No such file or directory
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 David Faust changed: What|Removed |Added Attachment #53993|0 |1 is obsolete|| --- Comment #9 from David Faust --- Created attachment 54002 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54002=edit updated patch Update the 'extern' variable marking, and also mark 'extern' funcs.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #8 from David Faust --- (In reply to James Hilliard from comment #5) > (In reply to David Faust from comment #4) > > Created attachment 53993 [details] > > proposed patch > > > > Should fix the remaining issues with 'extern' linkage and the missing > > 'const' modifier (and includes the earlier partial fixes in this bug) > > Fixes the reported test failure but some others(unclear if related to this > bug) are still failing such as tailcall_bpf2bpf3.c: Thanks for testing and confirming. > $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool > --debug gen object > /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/ > tailcall_bpf2bpf3.bpf.linked1.o > /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/ > tailcall_bpf2bpf3.bpf.o > libbpf: linker: adding object file > '/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/ > tailcall_bpf2bpf3.bpf.o'... > libbpf: failed to find BTF info for global/extern symbol 'llvm.bpf.load.word' > Error: failed to link > https://github.com/torvalds/linux/blob/v6.1-rc7/tools/testing/selftests/bpf/bpf_legacy.h unsigned long long load_word(void *skb, unsigned long long off) asm("llvm.bpf.load.word"); Looks like LLVM-specific inline asm to use their llvm.bpf.load.word intrinsic. GCC has equivalent __builtin_load_{byte,half,word} target builtins. > There's also this error during skeleton generation for kfunc_call_test.c: > ... > libbpf: failed to find BTF for extern 'bpf_kfunc_call_test2': -22 Hm, looks like we are OK for extern variables but are mis-generating something (or missing something) for extern funcs still. Will look into this.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #7 from James Hilliard --- There's also this error during skeleton generation for kfunc_call_test.c: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen skeleton /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/kfunc_call_test.bpf.linked3.o name kfunc_call_test libbpf: loading object 'kfunc_call_test' from buffer libbpf: elf: section(2) .symtab, size 648, link 1, flags 0, type=2 libbpf: elf: section(3) .data, size 0, link 0, flags 3, type=1 libbpf: elf: skipping section(3) .data (size 0) libbpf: elf: section(4) .bss, size 0, link 0, flags 3, type=8 libbpf: elf: section(5) tc, size 1120, link 0, flags 6, type=1 libbpf: sec 'tc': found program 'kfunc_call_test2' at insn offset 0 (0 bytes), code size 13 insns (104 bytes) libbpf: sec 'tc': found program 'kfunc_call_test1' at insn offset 13 (104 bytes), code size 21 insns (168 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_ref_btf_id' at insn offset 34 (272 bytes), code size 22 insns (176 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_pass' at insn offset 56 (448 bytes), code size 52 insns (416 bytes) libbpf: sec 'tc': found program 'kfunc_call_test_get_mem' at insn offset 108 (864 bytes), code size 32 insns (256 bytes) libbpf: elf: section(6) syscall, size 152, link 0, flags 6, type=1 libbpf: sec 'syscall': found program 'kfunc_syscall_test' at insn offset 0 (0 bytes), code size 15 insns (120 bytes) libbpf: sec 'syscall': found program 'kfunc_syscall_test_null' at insn offset 15 (120 bytes), code size 4 insns (32 bytes) libbpf: elf: section(7) license, size 4, link 0, flags 3, type=1 libbpf: license of kfunc_call_test is GPL libbpf: elf: section(8) .comment, size 43, link 0, flags 30, type=1 libbpf: elf: skipping unrecognized data section(8) .comment libbpf: elf: section(9) .reltc, size 272, link 2, flags 40, type=9 libbpf: elf: section(10) .relsyscall, size 64, link 2, flags 40, type=9 libbpf: elf: section(11) .BTF, size 467261, link 0, flags 0, type=1 libbpf: looking for externs among 27 symbols... libbpf: failed to find BTF for extern 'bpf_kfunc_call_test2': -22 Error: failed to open BPF object file: Invalid argument
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #6 from James Hilliard --- https://github.com/torvalds/linux/blob/v6.1-rc7/tools/testing/selftests/bpf/bpf_legacy.h
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #5 from James Hilliard --- (In reply to David Faust from comment #4) > Created attachment 53993 [details] > proposed patch > > Should fix the remaining issues with 'extern' linkage and the missing > 'const' modifier (and includes the earlier partial fixes in this bug) Fixes the reported test failure but some others(unclear if related to this bug) are still failing such as tailcall_bpf2bpf3.c: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen object /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tailcall_bpf2bpf3.bpf.linked1.o /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tailcall_bpf2bpf3.bpf.o libbpf: linker: adding object file '/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tailcall_bpf2bpf3.bpf.o'... libbpf: failed to find BTF info for global/extern symbol 'llvm.bpf.load.word' Error: failed to link '/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tailcall_bpf2bpf3.bpf.o': No such file or directory (2) GCC BTF dump: $ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug btf dump file /home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tailcall_bpf2bpf3.bpf.o format raw [1] INT 'signed char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [2] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=(none) [3] TYPEDEF '__u8' type_id=2 [4] INT 'short int' size=2 bits_offset=0 nr_bits=16 encoding=SIGNED [5] INT 'short unsigned int' size=2 bits_offset=0 nr_bits=16 encoding=(none) [6] TYPEDEF '__u16' type_id=5 [7] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [8] TYPEDEF '__s32' type_id=7 [9] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none) [10] TYPEDEF '__u32' type_id=9 [11] CONST '(anon)' type_id=10 [12] INT 'long long int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED [13] TYPEDEF '__s64' type_id=12 [14] INT 'long long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [15] TYPEDEF '__u64' type_id=14 [16] TYPEDEF '__be16' type_id=6 [17] TYPEDEF '__be32' type_id=10 [18] TYPEDEF '__wsum' type_id=10 [19] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [20] ENUM 'bpf_map_type' encoding=UNSIGNED size=4 vlen=34 'BPF_MAP_TYPE_UNSPEC' val=0 'BPF_MAP_TYPE_HASH' val=1 'BPF_MAP_TYPE_ARRAY' val=2 'BPF_MAP_TYPE_PROG_ARRAY' val=3 'BPF_MAP_TYPE_PERF_EVENT_ARRAY' val=4 'BPF_MAP_TYPE_PERCPU_HASH' val=5 'BPF_MAP_TYPE_PERCPU_ARRAY' val=6 'BPF_MAP_TYPE_STACK_TRACE' val=7 'BPF_MAP_TYPE_CGROUP_ARRAY' val=8 'BPF_MAP_TYPE_LRU_HASH' val=9 'BPF_MAP_TYPE_LRU_PERCPU_HASH' val=10 'BPF_MAP_TYPE_LPM_TRIE' val=11 'BPF_MAP_TYPE_ARRAY_OF_MAPS' val=12 'BPF_MAP_TYPE_HASH_OF_MAPS' val=13 'BPF_MAP_TYPE_DEVMAP' val=14 'BPF_MAP_TYPE_SOCKMAP' val=15 'BPF_MAP_TYPE_CPUMAP' val=16 'BPF_MAP_TYPE_XSKMAP' val=17 'BPF_MAP_TYPE_SOCKHASH' val=18 'BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED' val=19 'BPF_MAP_TYPE_CGROUP_STORAGE' val=19 'BPF_MAP_TYPE_REUSEPORT_SOCKARRAY' val=20 'BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE' val=21 'BPF_MAP_TYPE_QUEUE' val=22 'BPF_MAP_TYPE_STACK' val=23 'BPF_MAP_TYPE_SK_STORAGE' val=24 'BPF_MAP_TYPE_DEVMAP_HASH' val=25 'BPF_MAP_TYPE_STRUCT_OPS' val=26 'BPF_MAP_TYPE_RINGBUF' val=27 'BPF_MAP_TYPE_INODE_STORAGE' val=28 'BPF_MAP_TYPE_TASK_STORAGE' val=29 'BPF_MAP_TYPE_BLOOM_FILTER' val=30 'BPF_MAP_TYPE_USER_RINGBUF' val=31 'BPF_MAP_TYPE_CGRP_STORAGE' val=32 [21] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [22] CONST '(anon)' type_id=21 [23] VOLATILE '(anon)' type_id=21 [24] UNION '(anon)' size=8 vlen=1 'flow_keys' type_id=30 bits_offset=0 [25] STRUCT 'bpf_flow_keys' size=56 vlen=13 'nhoff' type_id=6 bits_offset=0 'thoff' type_id=6 bits_offset=16 'addr_proto' type_id=6 bits_offset=32 'is_frag' type_id=3 bits_offset=48 'is_first_frag' type_id=3 bits_offset=56 'is_encap' type_id=3 bits_offset=64 'ip_proto' type_id=3 bits_offset=72 'n_proto' type_id=16 bits_offset=80 'sport' type_id=16 bits_offset=96 'dport' type_id=16 bits_offset=112 '(anon)' type_id=26 bits_offset=128 'flags' type_id=10 bits_offset=384 'flow_label' type_id=17 bits_offset=416 [26] UNION '(anon)' size=32 vlen=2 '(anon)' type_id=27 bits_offset=0 '(anon)' type_id=28 bits_offset=0 [27] STRUCT '(anon)' size=8 vlen=2 'ipv4_src' type_id=17 bits_offset=0 'ipv4_dst' type_id=17 bits_offset=32 [28] STRUCT '(anon)' size=32 vlen=2 'ipv6_src' type_id=29 bits_offset=0 'ipv6_dst' type_id=29 bits_offset=128 [29] ARRAY '(anon)' type_id=10 index_type_id=19 nr_elems=4 [30] PTR '(anon)' type_id=25 [31]
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #4 from David Faust --- Created attachment 53993 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53993=edit proposed patch Should fix the remaining issues with 'extern' linkage and the missing 'const' modifier (and includes the earlier partial fixes in this bug)
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #3 from David Faust --- There are two remaining issues: 1. We are missing support for 'linkage=extern' encoding for variables, so 'bpf_link_fops' and others are incorrectly marked with 'linkage=global' instead. 2. 'bpf_link_fops' variable is encoded as 'void' type not 'const void'. This is a result of the BTF being generated from internal DWARF representation. The distinction seems to be intentionally removed in dwarf2out.cc:add_type_attribute(), with the later side-effect that looking up the type DIE for the variable when generating BTF actually fails and falls back to the default 'void'. I have an implementation for (1) in progress. For (2) I need to understand why the 'void'/'const void' distinction is removed in DWARF and how to work around it.
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #2 from James Hilliard --- Testing with this patch: diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 37ec662c190..ff08d0c5024 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -345,6 +345,8 @@ btf_collect_datasec (ctf_container_ref ctfc) tree size = DECL_SIZE_UNIT (node->decl); if (tree_fits_uhwi_p (size)) info.size = tree_to_uhwi (size); + else if (VOID_TYPE_P (TREE_TYPE (node->decl))) + info.size = 1; /* Offset is left as 0 at compile time, to be filled in by loaders such as libbpf. */ GCC gen object failure: $ /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen object /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.linked1.o /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o libbpf: linker: adding object file '/home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o'... libbpf: failed to find symbol for variable 'bpf_link_fops1' in section '.ksyms' Error: failed to link '/home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o': Unknown error -2 (-2) GCC BTF dump: $ /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/tools/sbin/bpftool --debug btf dump file /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o format raw [1] INT 'signed char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [2] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=(none) [3] TYPEDEF '__u8' type_id=2 [4] INT 'short int' size=2 bits_offset=0 nr_bits=16 encoding=SIGNED [5] INT 'short unsigned int' size=2 bits_offset=0 nr_bits=16 encoding=(none) [6] TYPEDEF '__u16' type_id=5 [7] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [8] TYPEDEF '__s32' type_id=7 [9] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none) [10] TYPEDEF '__u32' type_id=9 [11] INT 'long long int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED [12] TYPEDEF '__s64' type_id=11 [13] INT 'long long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [14] TYPEDEF '__u64' type_id=13 [15] TYPEDEF '__be16' type_id=6 [16] TYPEDEF '__be32' type_id=10 [17] TYPEDEF '__wsum' type_id=10 [18] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [19] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [20] CONST '(anon)' type_id=19 [21] UNION '(anon)' size=8 vlen=1 'flow_keys' type_id=27 bits_offset=0 [22] STRUCT 'bpf_flow_keys' size=56 vlen=13 'nhoff' type_id=6 bits_offset=0 'thoff' type_id=6 bits_offset=16 'addr_proto' type_id=6 bits_offset=32 'is_frag' type_id=3 bits_offset=48 'is_first_frag' type_id=3 bits_offset=56 'is_encap' type_id=3 bits_offset=64 'ip_proto' type_id=3 bits_offset=72 'n_proto' type_id=15 bits_offset=80 'sport' type_id=15 bits_offset=96 'dport' type_id=15 bits_offset=112 '(anon)' type_id=23 bits_offset=128 'flags' type_id=10 bits_offset=384 'flow_label' type_id=16 bits_offset=416 [23] UNION '(anon)' size=32 vlen=2 '(anon)' type_id=24 bits_offset=0 '(anon)' type_id=25 bits_offset=0 [24] STRUCT '(anon)' size=8 vlen=2 'ipv4_src' type_id=16 bits_offset=0 'ipv4_dst' type_id=16 bits_offset=32 [25] STRUCT '(anon)' size=32 vlen=2 'ipv6_src' type_id=26 bits_offset=0 'ipv6_dst' type_id=26 bits_offset=128 [26] ARRAY '(anon)' type_id=10 index_type_id=18 nr_elems=4 [27] PTR '(anon)' type_id=22 [28] UNION '(anon)' size=8 vlen=1 'sk' type_id=30 bits_offset=0 [29] STRUCT 'bpf_sock' size=80 vlen=14 'bound_dev_if' type_id=10 bits_offset=0 'family' type_id=10 bits_offset=32 'type' type_id=10 bits_offset=64 'protocol' type_id=10 bits_offset=96 'mark' type_id=10 bits_offset=128 'priority' type_id=10 bits_offset=160 'src_ip4' type_id=10 bits_offset=192 'src_ip6' type_id=26 bits_offset=224 'src_port' type_id=10 bits_offset=352 'dst_port' type_id=15 bits_offset=384 'dst_ip4' type_id=10 bits_offset=416 'dst_ip6' type_id=26 bits_offset=448 'state' type_id=10 bits_offset=576 'rx_queue_mapping' type_id=8 bits_offset=608 [30] PTR '(anon)' type_id=29 [31] STRUCT '__sk_buff' size=192 vlen=34 'len' type_id=10 bits_offset=0 'pkt_type' type_id=10 bits_offset=32 'mark' type_id=10 bits_offset=64 'queue_mapping' type_id=10 bits_offset=96 'protocol' type_id=10 bits_offset=128 'vlan_present' type_id=10 bits_offset=160 'vlan_tci' type_id=10 bits_offset=192 'vlan_proto' type_id=10 bits_offset=224 'priority' type_id=10 bits_offset=256 'ingress_ifindex' type_id=10 bits_offset=288 'ifindex' type_id=10 bits_offset=320 'tc_index' type_id=10 bits_offset=352 'cb'
[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773 --- Comment #1 from James Hilliard --- Getting a different error when running with: https://patchwork.ozlabs.org/project/gcc/patch/20220901195340.10653-1-david.fa...@oracle.com/ GCC gen object failure: $ /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/tools/sbin/bpftool --debug gen object /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.linked1.o /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o libbpf: linker: adding object file '/home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o'... libbpf: failed to find symbol for variable 'bpf_link_fops1' in section '.ksyms' Error: failed to link '/home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o': Unknown error -2 (-2) GCC BTF dump: $ /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/tools/sbin/bpftool --debug btf dump file /home/buildroot/bpf-next-test/tools/testing/selftests/bpf/bpf_gcc/test_ksyms.o format raw [1] INT 'signed char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [2] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=(none) [3] TYPEDEF '__u8' type_id=2 [4] INT 'short int' size=2 bits_offset=0 nr_bits=16 encoding=SIGNED [5] INT 'short unsigned int' size=2 bits_offset=0 nr_bits=16 encoding=(none) [6] TYPEDEF '__u16' type_id=5 [7] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [8] TYPEDEF '__s32' type_id=7 [9] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none) [10] TYPEDEF '__u32' type_id=9 [11] INT 'long long int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED [12] TYPEDEF '__s64' type_id=11 [13] INT 'long long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [14] TYPEDEF '__u64' type_id=13 [15] TYPEDEF '__be16' type_id=6 [16] TYPEDEF '__be32' type_id=10 [17] TYPEDEF '__wsum' type_id=10 [18] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none) [19] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [20] CONST '(anon)' type_id=19 [21] UNION '(anon)' size=8 vlen=1 'flow_keys' type_id=27 bits_offset=0 [22] STRUCT 'bpf_flow_keys' size=56 vlen=13 'nhoff' type_id=6 bits_offset=0 'thoff' type_id=6 bits_offset=16 'addr_proto' type_id=6 bits_offset=32 'is_frag' type_id=3 bits_offset=48 'is_first_frag' type_id=3 bits_offset=56 'is_encap' type_id=3 bits_offset=64 'ip_proto' type_id=3 bits_offset=72 'n_proto' type_id=15 bits_offset=80 'sport' type_id=15 bits_offset=96 'dport' type_id=15 bits_offset=112 '(anon)' type_id=23 bits_offset=128 'flags' type_id=10 bits_offset=384 'flow_label' type_id=16 bits_offset=416 [23] UNION '(anon)' size=32 vlen=2 '(anon)' type_id=24 bits_offset=0 '(anon)' type_id=25 bits_offset=0 [24] STRUCT '(anon)' size=8 vlen=2 'ipv4_src' type_id=16 bits_offset=0 'ipv4_dst' type_id=16 bits_offset=32 [25] STRUCT '(anon)' size=32 vlen=2 'ipv6_src' type_id=26 bits_offset=0 'ipv6_dst' type_id=26 bits_offset=128 [26] ARRAY '(anon)' type_id=10 index_type_id=18 nr_elems=4 [27] PTR '(anon)' type_id=22 [28] UNION '(anon)' size=8 vlen=1 'sk' type_id=30 bits_offset=0 [29] STRUCT 'bpf_sock' size=80 vlen=14 'bound_dev_if' type_id=10 bits_offset=0 'family' type_id=10 bits_offset=32 'type' type_id=10 bits_offset=64 'protocol' type_id=10 bits_offset=96 'mark' type_id=10 bits_offset=128 'priority' type_id=10 bits_offset=160 'src_ip4' type_id=10 bits_offset=192 'src_ip6' type_id=26 bits_offset=224 'src_port' type_id=10 bits_offset=352 'dst_port' type_id=15 bits_offset=384 'dst_ip4' type_id=10 bits_offset=416 'dst_ip6' type_id=26 bits_offset=448 'state' type_id=10 bits_offset=576 'rx_queue_mapping' type_id=8 bits_offset=608 [30] PTR '(anon)' type_id=29 [31] STRUCT '__sk_buff' size=192 vlen=34 'len' type_id=10 bits_offset=0 'pkt_type' type_id=10 bits_offset=32 'mark' type_id=10 bits_offset=64 'queue_mapping' type_id=10 bits_offset=96 'protocol' type_id=10 bits_offset=128 'vlan_present' type_id=10 bits_offset=160 'vlan_tci' type_id=10 bits_offset=192 'vlan_proto' type_id=10 bits_offset=224 'priority' type_id=10 bits_offset=256 'ingress_ifindex' type_id=10 bits_offset=288 'ifindex' type_id=10 bits_offset=320 'tc_index' type_id=10 bits_offset=352 'cb' type_id=32 bits_offset=384 'hash' type_id=10 bits_offset=544 'tc_classid' type_id=10 bits_offset=576 'data' type_id=10 bits_offset=608 'data_end' type_id=10 bits_offset=640 'napi_id' type_id=10 bits_offset=672 'family' type_id=10 bits_offset=704 'remote_ip4' type_id=10 bits_offset=736 'local_ip4' type_id=10