[Bug libstdc++/70560] Review configure checks for _GLIBCXX_ATOMIC_BUILTINS and atomicity_dir

2020-08-17 Thread james.hilliard1 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70560

James Hilliard  changed:

   What|Removed |Added

 CC||james.hilliard1 at gmail dot 
com

--- Comment #2 from James Hilliard  ---
We've been hitting a bug in buildroot with an application(apcupsd) that links
against libsupc++.a directly.

This issue appears to be due to a sparc/arc specific missing symbols bug in
libsupc++, we aren't seeing this build error for any other architectures at the
moment.

See discussions:
http://lists.busybox.net/pipermail/buildroot/2020-May/282779.html
http://lists.busybox.net/pipermail/buildroot/2020-August/289413.html

Build error
http://autobuild.buildroot.org/results/3be/3bedf404de0ea42ee3ba624cded65d310a847af9//build-end.log:

/tmp/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/8.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
/tmp/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/8.3.0/../../../../sparc-buildroot-linux-uclibc/lib/libsupc++.a(eh_throw.o):
in function `__gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*)':
eh_throw.cc:(.text._ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception+0x38):
undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:33: apcupsd] Error 1

[Bug libstdc++/70560] Review configure checks for _GLIBCXX_ATOMIC_BUILTINS and atomicity_dir

2020-08-17 Thread james.hilliard1 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70560

--- Comment #5 from James Hilliard  ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to James Hilliard from comment #2)
> > We've been hitting a bug in buildroot with an application(apcupsd) that
> > links against libsupc++.a directly.
> 
> Maybe I missed it, but I don't see the linker command in the build log.
That might be somewhere here:
http://autobuild.buildroot.org/results/3be/3bedf404de0ea42ee3ba624cded65d310a847af9/apcupsd-3.14.14/config.log
> Could you show the command that's failing? Could you check if the symbol
> _ZN9__gnu_cxx18__exchange_and_addEPVii is actually defined in libsupc++.a or
> if something else like _ZN9__gnu_cxx18__exchange_and_addEPVll is defined
> instead?

The toolchain in that failed build is available here:
http://autobuild.buildroot.org/toolchains/tarballs/br-sparc-uclibc-2020.02.tar.bz2

It appears reference to _ZN9__gnu_cxx18__exchange_and_addEPVii are in the
following objects in libsupc++.a.

$ nm eh_throw.o
 U __cxa_begin_catch
 U __cxa_free_exception
 U __cxa_get_globals
 T __cxa_init_primary_exception
 T __cxa_rethrow
 T __cxa_throw
 U _GLOBAL_OFFSET_TABLE_
 w __pthread_key_create
 W __sparc_get_pc_thunk.l7
 U _Unwind_RaiseException
 U _Unwind_Resume_or_Rethrow
 t
_ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception
 U _ZN10__cxxabiv111__terminateEPFvvE
 U _ZN9__gnu_cxx18__exchange_and_addEPVii
 U _ZSt13get_terminatev
 U _ZSt14get_unexpectedv
 U _ZSt9terminatev

$ nm eh_tm.o
 U __cxa_call_unexpected
 U __cxa_free_dependent_exception
 U __cxa_free_exception
 U __cxa_get_globals_fast
 T __cxa_tm_cleanup
 V DW.ref.__gxx_personality_v0
 U _GLOBAL_OFFSET_TABLE_
 U __gxx_personality_v0
 w __pthread_key_create
 W __sparc_get_pc_thunk.l7
 U _Unwind_DeleteException
 U _Unwind_Resume
 t _ZL22free_any_cxa_exceptionP17_Unwind_Exception
 U _ZN9__gnu_cxx18__exchange_and_addEPVii

$ nm eh_ptr.o
 U __cxa_allocate_dependent_exception
 U __cxa_begin_catch
 U __cxa_free_dependent_exception
 U __cxa_free_exception
 U __cxa_get_globals
 V DW.ref.__gxx_personality_v0
 U _GLOBAL_OFFSET_TABLE_
 U __gxx_personality_v0
 w __pthread_key_create
 W __sparc_get_pc_thunk.l7
 U _Unwind_RaiseException
 t
_ZL33__gxx_dependent_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception
 U _ZN10__cxxabiv111__terminateEPFvvE
 U _ZN9__gnu_cxx12__atomic_addEPVii
 U _ZN9__gnu_cxx18__exchange_and_addEPVii
 T _ZNKSt15__exception_ptr13exception_ptr20__cxa_exception_typeEv
 T _ZNKSt15__exception_ptr13exception_ptr6_M_getEv
 T _ZNKSt15__exception_ptr13exception_ptrcvMS0_FvvEEv
 T _ZNKSt15__exception_ptr13exception_ptrntEv
 T _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv
 T _ZNSt15__exception_ptr13exception_ptr18_M_safe_bool_dummyEv
 T _ZNSt15__exception_ptr13exception_ptr4swapERS0_
 T _ZNSt15__exception_ptr13exception_ptr9_M_addrefEv
 T _ZNSt15__exception_ptr13exception_ptraSERKS0_
 T _ZNSt15__exception_ptr13exception_ptrC1EMS0_FvvE
 T _ZNSt15__exception_ptr13exception_ptrC1EPv
 T _ZNSt15__exception_ptr13exception_ptrC1ERKS0_
 T _ZNSt15__exception_ptr13exception_ptrC1Ev
 T _ZNSt15__exception_ptr13exception_ptrC2EMS0_FvvE
 T _ZNSt15__exception_ptr13exception_ptrC2EPv
 T _ZNSt15__exception_ptr13exception_ptrC2ERKS0_
 T _ZNSt15__exception_ptr13exception_ptrC2Ev
 T _ZNSt15__exception_ptr13exception_ptrD1Ev
 T _ZNSt15__exception_ptr13exception_ptrD2Ev
 T _ZNSt15__exception_ptreqERKNS_13exception_ptrES2_
 T _ZNSt15__exception_ptrneERKNS_13exception_ptrES2_
 U _ZSt13get_terminatev
 U _ZSt14get_unexpectedv
 T _ZSt17current_exceptionv
 T _ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE
 U _ZSt9terminatev

[Bug libstdc++/96657] New: libsupc++.a missing required functions from src/c++98/atomicity.cc when atomic builtins are not supported

2020-08-17 Thread james.hilliard1 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96657

Bug ID: 96657
   Summary: libsupc++.a missing required functions from
src/c++98/atomicity.cc when atomic builtins are not
supported
   Product: gcc
   Version: 9.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
CC: redi at gcc dot gnu.org
  Target Milestone: ---

We've been hitting a bug in buildroot with an application(apcupsd) that links
against libsupc++.a directly.

This issue appears to be due to a sparc/arc specific missing symbols bug in
libsupc++, we aren't seeing this build error for any other architectures at the
moment.

See discussions:
http://lists.busybox.net/pipermail/buildroot/2020-May/282779.html
http://lists.busybox.net/pipermail/buildroot/2020-August/289413.html

Build error
http://autobuild.buildroot.org/results/3be/3bedf404de0ea42ee3ba624cded65d310a847af9//build-end.log:

/tmp/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/8.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
/tmp/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/8.3.0/../../../../sparc-buildroot-linux-uclibc/lib/libsupc++.a(eh_throw.o):
in function `__gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*)':
eh_throw.cc:(.text._ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception+0x38):
undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:33: apcupsd] Error 1

Based on previous
discussions(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70560#c6) it appears
this has been broken since r244051 enabled std::exception_ptr for targets
without lock-free atomic built-ins.

[Bug libstdc++/70560] Review configure checks for _GLIBCXX_ATOMIC_BUILTINS and atomicity_dir

2020-08-17 Thread james.hilliard1 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70560

--- Comment #7 from James Hilliard  ---
(In reply to Jonathan Wakely from comment #6)
> (In reply to James Hilliard from comment #5)
> > That might be somewhere here:
> > http://autobuild.buildroot.org/results/3be/
> > 3bedf404de0ea42ee3ba624cded65d310a847af9/apcupsd-3.14.14/config.log
> 
> No, I meant the command that fails when running 'make'. But it doesn't
> matter now, because ...
> 
> > It appears reference to _ZN9__gnu_cxx18__exchange_and_addEPVii are in the
> > following objects in libsupc++.a.
> 
> I was looking for the definition of the function not the references to it,
> but I think the problem is that those functions are defined by
> src/c++98/atomicity.cc which isn't included in libsupc++.a at all.
> 
> Using the atomic functions in libsupc++.a assumes that atomic builtins are
> supported and so we won't need the extern functions from atomicity.cc, which
> isn't necessarily true.
> 
> I think this has been broken since r244051 enabled std::exception_ptr for
> targets without lock-free atomic built-ins. Previously if we didn't have
> atomic built-ins, libsupc++ just wouldn't try to use atomics. Now it uses
> the built-ins or falls back to the extern functions in atomicity.cc, but the
> latter are not in libsupc++.a so it only works if you link to the full
> libstdc++.{a,so} library.
> 
> Please file a new bug, yours is a separate issue to this one.

New bug report opened here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96657

[Bug libstdc++/96657] [9/10/11 Regression] libsupc++.a missing required functions from src/c++98/atomicity.cc when atomic builtins are not supported

2020-08-17 Thread james.hilliard1 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96657

--- Comment #2 from James Hilliard  ---
(In reply to Jonathan Wakely from comment #1)
> I think r244051 caused libsupc++.a to depend on libstdc++.so for targets
> that don't support lock-free atomics for int.

Yeah, the current workaround we came up with was to force linking to
libstdc++.so, but that's probably not a real fix for the root cause of the
issue. I'm assuming the real fix would be to change libsupc++.a so that it
includes the missing symbols?

[Bug debug/106263] BTF_KIND_FUNC type does not encode linkage

2022-08-19 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106263

--- Comment #2 from James Hilliard  ---
Should this be backported to the gcc 12 branch?

[Bug c/106745] New: segfault in bpf_core_get_sou_member_index

2022-08-25 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106745

Bug ID: 106745
   Summary: segfault in bpf_core_get_sou_member_index
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

Created attachment 53510
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53510&action=edit
bug report output

Running into this on master with the following patch(seems unrelated to the
crash):
https://patchwork.ozlabs.org/project/gcc/patch/87a681d7tf.fsf...@oracle.com/

[Bug c/106773] New: libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'

2022-08-29 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106773

Bug ID: 106773
   Summary: libbpf: failed to find BTF info for global/extern
symbol 'bpf_link_fops'
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

GCC BTF Generation appears to not be working correctly for bpf_link_fops in the
bpf test test_ksyms.c

See:
https://github.com/torvalds/linux/blob/v6.0-rc3/tools/testing/selftests/bpf/progs/test_ksyms.c

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 BTF info for global/extern symbol 'bpf_link_fops'
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
'

[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'

2022-09-01 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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 bits_offset=768

[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'

2022-09-01 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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' type_id=32

[Bug target/107843] New: error: incompatible type for argument in ___bpf_ctx_cast2

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107843

Bug ID: 107843
   Summary: error: incompatible type for argument in
___bpf_ctx_cast2
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this error which does not occur in llvm for a bpf test(bpf_cubic.c)
in bpf-next:

In file included from
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_tcp_helpers.h:9,
 from progs/bpf_cubic.c:20:
progs/bpf_cubic.c: In function 'bpf_cubic_cwnd_event':
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:399:63:
error: incompatible type for argument 3 of 'bpf_cubic_cwnd_event'
  399 | #define ___bpf_ctx_cast2(x, args...)  ___bpf_ctx_cast1(args), (void
*)ctx[1]
  |  
^~
  |   |
  |   void *
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_helpers.h:187:29:
note: in expansion of macro '___bpf_ctx_cast2'
  187 | #define ___bpf_concat(a, b) a ## b
  | ^
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_helpers.h:190:29:
note: in expansion of macro '___bpf_concat'
  190 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
  | ^
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:410:39:
note: in expansion of macro '___bpf_apply'
  410 | #define ___bpf_ctx_cast(args...)  ___bpf_apply(___bpf_ctx_cast,
___bpf_narg(args))(args)
  |   ^~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:435:27:
note: in expansion of macro '___bpf_ctx_cast'
  435 | return ##name(___bpf_ctx_cast(args));  
\
  |   ^~~
progs/bpf_cubic.c:189:6: note: in expansion of macro 'BPF_PROG'
  189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
  |  ^~~~
progs/bpf_cubic.c:189:72: note: expected 'enum tcp_ca_event' but argument is of
type 'void *'
  189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
  | 
~~^
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:430:39:
note: in definition of macro 'BPF_PROG'
  430 | ##name(unsigned long long *ctx, ##args);   
\
  |   ^~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:435:16:
error: 'return' with a value, in function returning void [-Werror]
  435 | return ##name(___bpf_ctx_cast(args));  
\
  |^~~~
progs/bpf_cubic.c:189:6: note: in expansion of macro 'BPF_PROG'
  189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
  |  ^~~~
progs/bpf_cubic.c:189:15: note: declared here
  189 | void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event
event)
  |   ^~~~
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_tracing.h:431:17:
note: in definition of macro 'BPF_PROG'
  431 | typeof(name(0)) name(unsigned long long *ctx)  
\
  |

[Bug target/107844] New: error: argument is not a field access for __builtin_preserve_field_info

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107844

Bug ID: 107844
   Summary: error: argument is not a field access for
__builtin_preserve_field_info
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this error which does not occur in llvm for a bpf
test(test_core_reloc_existence.c) in bpf-next:

In file included from progs/test_core_reloc_existence.c:7:
progs/test_core_reloc_existence.c: In function 'test_core_existence':
/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include/bpf/bpf_core_read.h:132:9:
error: argument is not a field access
  132 | __builtin_preserve_field_info(___bpf_field_ref(field),
BPF_FIELD_EXISTS)
  | ^
progs/test_core_reloc_existence.c:66:13: note: in expansion of macro
'bpf_core_field_exists'
   66 | if (bpf_core_field_exists(struct core_reloc_existence, arr))
  | ^

[Bug target/107846] New: error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107846

Bug ID: 107846
   Summary: error: result of '8000 << 8' requires 22 bits to
represent, but 'short int' only has 16 bits
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this error which does not occur in llvm for a bpf
test(test_tc_tunnel.c) in bpf-next, I'm not sure if this is an upstream bug in
the test itself or a bug in gcc:

In function '__encap_ipv4':
cc1: error: result of '8000 << 8' requires 22 bits to represent, but 'short
int' only has 16 bits [-Werror=shift-overflow=]
cc1: error: result of '2 << 8' requires 24 bits to represent, but 'short
int' only has 16 bits [-Werror=shift-overflow=]
progs/test_tc_tunnel.c:228:31: warning: taking address of packed member of
'struct v4hdr' may result in an unaligned pointer value
[-Waddress-of-packed-member]
  228 | set_ipv4_csum((void *)&h_outer.ip);
  |   ^~~
In function '__encap_ipv6':
cc1: error: result of '8000 << 8' requires 22 bits to represent, but 'short
int' only has 16 bits [-Werror=shift-overflow=]
cc1: error: result of '2 << 8' requires 24 bits to represent, but 'short
int' only has 16 bits [-Werror=shift-overflow=]

[Bug target/107847] New: error: integer overflow in expression in bpf-next test_xdp_vlan.c

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107847

Bug ID: 107847
   Summary: error: integer overflow in expression in bpf-next
test_xdp_vlan.c
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this error which does not occur in llvm for a bpf
test(test_xdp_vlan.c) in bpf-next, I'm not sure if this is an upstream bug in
the test itself or a bug in gcc:

progs/test_xdp_vlan.c: In function 'xdp_prognum1':
progs/test_xdp_vlan.c:163:25: error: integer overflow in expression '(short
int)(((__builtin_constant_p((int)vlan_hdr->h_vlan_TCI)) != 0 ? (int)(short
unsigned int)((short int)((int)vlan_hdr->h_vlan_TCI << 8 >> 8) << 8 | (short
int)((int)vlan_hdr->h_vlan_TCI << 0 >> 8 << 0)) & 61440 :
(int)__builtin_bswap16(vlan_hdr->h_vlan_TCI) & 61440) << 8 >> 8) << 8' of type
'short int' results in '0' [-Werror=overflow]
  163 | bpf_htons((bpf_ntohs(vlan_hdr->h_vlan_TCI) &
0xf000)
  | ^

[Bug target/107848] New: libbpf: ELF relo #0 in section #7 has unexpected type 12

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107848

Bug ID: 107848
   Summary: libbpf: ELF relo #0 in section #7 has unexpected type
12
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

GCC gen object appears to not be working correctly in the bpf test
bpf_dctcp_release.c

GCC gen object failure:
$ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool
--debug gen object
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/bpf_dctcp_release.bpf.linked1.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/bpf_dctcp_release.bpf.o
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/bpf_dctcp_release.bpf.o'...
libbpf: ELF relo #0 in section #7 has unexpected type 12 in
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/bpf_dctcp_release.bpf.o
Error: failed to link
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/bpf_dctcp_release.bpf.o':
Invalid argument (22)

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/bpf_dctcp_release.bpf.o
format raw
[1] INT 'long int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED
[2] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none)
[3] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[4] INT 'long long int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED
[5] FLOAT 'long double' size=8
[6] INT 'signed char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED
[7] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=(none)
[8] TYPEDEF '__u8' type_id=7
[9] INT 'short int' size=2 bits_offset=0 nr_bits=16 encoding=SIGNED
[10] INT 'short unsigned int' size=2 bits_offset=0 nr_bits=16 encoding=(none)
[11] TYPEDEF '__u16' type_id=10
[12] TYPEDEF '__s32' type_id=3
[13] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none)
[14] TYPEDEF '__u32' type_id=13
[15] TYPEDEF '__s64' type_id=4
[16] INT 'long long unsigned int' size=8 bits_offset=0 nr_bits=64
encoding=(none)
[17] TYPEDEF '__u64' type_id=16
[18] TYPEDEF '__be16' type_id=11
[19] TYPEDEF '__be32' type_id=14
[20] TYPEDEF '__sum16' type_id=11
[21] TYPEDEF '__wsum' type_id=14
[22] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED
[23] ARRAY '(anon)' type_id=22 index_type_id=2 nr_elems=16
[24] CONST '(anon)' type_id=22
[25] UNION '(anon)' size=8 vlen=1
'flow_keys' type_id=31 bits_offset=0
[26] STRUCT 'bpf_flow_keys' size=56 vlen=13
'nhoff' type_id=11 bits_offset=0
'thoff' type_id=11 bits_offset=16
'addr_proto' type_id=11 bits_offset=32
'is_frag' type_id=8 bits_offset=48
'is_first_frag' type_id=8 bits_offset=56
'is_encap' type_id=8 bits_offset=64
'ip_proto' type_id=8 bits_offset=72
'n_proto' type_id=18 bits_offset=80
'sport' type_id=18 bits_offset=96
'dport' type_id=18 bits_offset=112
'(anon)' type_id=27 bits_offset=128
'flags' type_id=14 bits_offset=384
'flow_label' type_id=19 bits_offset=416
[27] UNION '(anon)' size=32 vlen=2
'(anon)' type_id=28 bits_offset=0
'(anon)' type_id=29 bits_offset=0
[28] STRUCT '(anon)' size=8 vlen=2
'ipv4_src' type_id=19 bits_offset=0
'ipv4_dst' type_id=19 bits_offset=32
[29] STRUCT '(anon)' size=32 vlen=2
'ipv6_src' type_id=30 bits_offset=0
'ipv6_dst' type_id=30 bits_offset=128
[30] ARRAY '(anon)' type_id=14 index_type_id=2 nr_elems=4
[31] PTR '(anon)' type_id=26
[32] UNION '(anon)' size=8 vlen=1
'sk' type_id=34 bits_offset=0
[33] STRUCT 'bpf_sock' size=80 vlen=14
'bound_dev_if' type_id=14 bits_offset=0
'family' type_id=14 bits_offset=32
'type' type_id=14 bits_offset=64
'protocol' type_id=14 bits_offset=96
'mark' type_id=14 bits_offset=128
'priority' type_id=14 bits_offset=160
'src_ip4' type_id=14 bits_offset=192
'src_ip6' type_id=30 bits_offset=224
'src_port' type_id=14 bits_offset=352
 

[Bug target/107848] libbpf: ELF relo #0 in section #7 has unexpected type 12

2022-11-23 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107848

--- Comment #1 from James Hilliard  ---
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/bpf_dctcp_release.bpf.o
format raw
[1] PTR '(anon)' type_id=2
[2] INT 'unsigned long long' size=8 bits_offset=0 nr_bits=64 encoding=(none)
[3] FUNC_PROTO '(anon)' ret_type_id=0 vlen=1
'ctx' type_id=1
[4] FUNC 'dctcp_nouse_release' type_id=3 linkage=global
[5] INT 'char' size=1 bits_offset=0 nr_bits=8 encoding=SIGNED
[6] ARRAY '(anon)' type_id=5 index_type_id=7 nr_elems=4
[7] INT '__ARRAY_SIZE_TYPE__' size=4 bits_offset=0 nr_bits=32 encoding=(none)
[8] VAR '_license' type_id=6, linkage=global
[9] CONST '(anon)' type_id=5
[10] ARRAY '(anon)' type_id=9 index_type_id=7 nr_elems=6
[11] VAR 'cubic' type_id=10, linkage=global
[12] STRUCT 'tcp_congestion_ops' size=128 vlen=15
'name' type_id=13 bits_offset=0
'flags' type_id=14 bits_offset=128
'init' type_id=16 bits_offset=192
'release' type_id=16 bits_offset=256
'ssthresh' type_id=25 bits_offset=320
'cong_avoid' type_id=27 bits_offset=384
'set_state' type_id=29 bits_offset=448
'cwnd_event' type_id=32 bits_offset=512
'in_ack_event' type_id=35 bits_offset=576
'undo_cwnd' type_id=25 bits_offset=640
'pkts_acked' type_id=37 bits_offset=704
'min_tso_segs' type_id=25 bits_offset=768
'sndbuf_expand' type_id=25 bits_offset=832
'cong_control' type_id=44 bits_offset=896
'owner' type_id=52 bits_offset=960
[13] ARRAY '(anon)' type_id=5 index_type_id=7 nr_elems=16
[14] TYPEDEF '__u32' type_id=15
[15] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32 encoding=(none)
[16] PTR '(anon)' type_id=17
[17] FUNC_PROTO '(anon)' ret_type_id=0 vlen=1
'(anon)' type_id=18
[18] PTR '(anon)' type_id=19
[19] STRUCT 'sock' size=24 vlen=3
'__sk_common' type_id=20 bits_offset=0
'sk_pacing_rate' type_id=24 bits_offset=64
'sk_pacing_status' type_id=14 bits_offset=128
[20] STRUCT 'sock_common' size=4 vlen=2
'skc_state' type_id=21 bits_offset=0
'skc_num' type_id=22 bits_offset=16
[21] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=(none)
[22] TYPEDEF '__u16' type_id=23
[23] INT 'unsigned short' size=2 bits_offset=0 nr_bits=16 encoding=(none)
[24] INT 'unsigned long' size=8 bits_offset=0 nr_bits=64 encoding=(none)
[25] PTR '(anon)' type_id=26
[26] FUNC_PROTO '(anon)' ret_type_id=14 vlen=1
'(anon)' type_id=18
[27] PTR '(anon)' type_id=28
[28] FUNC_PROTO '(anon)' ret_type_id=0 vlen=3
'(anon)' type_id=18
'(anon)' type_id=14
'(anon)' type_id=14
[29] PTR '(anon)' type_id=30
[30] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'(anon)' type_id=18
'(anon)' type_id=31
[31] TYPEDEF '__u8' type_id=21
[32] PTR '(anon)' type_id=33
[33] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'(anon)' type_id=18
'(anon)' type_id=34
[34] ENUM 'tcp_ca_event' encoding=UNSIGNED size=4 vlen=6
'CA_EVENT_TX_START' val=0
'CA_EVENT_CWND_RESTART' val=1
'CA_EVENT_COMPLETE_CWR' val=2
'CA_EVENT_LOSS' val=3
'CA_EVENT_ECN_NO_CE' val=4
'CA_EVENT_ECN_IS_CE' val=5
[35] PTR '(anon)' type_id=36
[36] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'(anon)' type_id=18
'(anon)' type_id=14
[37] PTR '(anon)' type_id=38
[38] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'(anon)' type_id=18
'(anon)' type_id=39
[39] PTR '(anon)' type_id=40
[40] CONST '(anon)' type_id=41
[41] STRUCT 'ack_sample' size=12 vlen=3
'pkts_acked' type_id=14 bits_offset=0
'rtt_us' type_id=42 bits_offset=32
'in_flight' type_id=14 bits_offset=64
[42] TYPEDEF '__s32' type_id=43
[43] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[44] PTR '(anon)' type_id=45
[45] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'(anon)' type_id=18
'(anon)' type_id=46
[46] PTR '(anon)' type_id=47
[47] CONST '(anon)' type_id=48
[48] STRUCT 'rate_sample' size=56 vlen=13
'prior_mstamp' type_id=49 bits_offset=0
'prior_delivered' type_id=14 bits_offset=64
'delivered' type_id=42 bits_offset=96
'interval_us' type_id=50 bits_offset=128
'snd_interval_us' type_id=14 bits_offset=192
'rcv_interval_us' type_id=14 bits_offset=224
'rtt_us' type_id=50 bits_offset=256
'losses' type_id=43 bits_offset=320
'acked_sacked' type_id=14 bits_offset=352
'prior_in_flight' type_id=14 bits_offset=384
'is_app_limited' type_id=51 bits_offset=416
'is_retrans' type_id=51 bits_offset=424
'is_ack_delayed' type_id=51 bits_offset=432
[49] TYPEDEF '__u64' type_id=2
[50] INT 'long' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED
[51] INT '_Bool' size=1 bits_offset=0 nr_bits=8 encoding=BOOL
[52] PTR '(anon)' type_id=0
[53] VAR 'dctc

[Bug c/107846] [13 Regression] error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits

2022-11-29 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107846

--- Comment #7 from James Hilliard  ---
(In reply to Jakub Jelinek from comment #6)
> Created attachment 53984 [details]
> gcc13-pr107846.patch
> 
> Untested fix.

This appears to fix error, the warning is still present:
progs/test_tc_tunnel.c: In function '__encap_ipv4':
progs/test_tc_tunnel.c:228:31: warning: taking address of packed member of
'struct v4hdr' may result in an unaligned pointer value
[-Waddress-of-packed-member]
  228 | set_ipv4_csum((void *)&h_outer.ip);
  |   ^~~

[Bug c/107846] [13 Regression] error: result of '8000 << 8' requires 22 bits to represent, but 'short int' only has 16 bits

2022-11-29 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107846

--- Comment #10 from James Hilliard  ---
(In reply to Jakub Jelinek from comment #8)
> (In reply to James Hilliard from comment #7)
> > (In reply to Jakub Jelinek from comment #6)
> > > Created attachment 53984 [details]
> > > gcc13-pr107846.patch
> > > 
> > > Untested fix.
> > 
> > This appears to fix error, the warning is still present:
> > progs/test_tc_tunnel.c: In function '__encap_ipv4':
> > progs/test_tc_tunnel.c:228:31: warning: taking address of packed member of
> > 'struct v4hdr' may result in an unaligned pointer value
> > [-Waddress-of-packed-member]
> >   228 | set_ipv4_csum((void *)&h_outer.ip);
> >   |   ^~~
> 
> That is unrelated and why do you think it is wrong?  I don't think that
> warning has false positives.

I wasn't entirely sure if it was wrong or not, was just testing the patch.

[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'

2022-11-30 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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] U

[Bug target/106773] libbpf: failed to find BTF info for global/extern symbol 'bpf_link_fops'

2022-11-30 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-11-30 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-12-01 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-12-01 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-12-01 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-12-05 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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'

2022-12-05 Thread james.hilliard1 at gmail dot com via Gcc-bugs
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/107983] New: btf: bad call relo against 'test_task_acquire_release_current' in section 'tp_btf/task_newtask'

2022-12-05 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107983

Bug ID: 107983
   Summary: btf: bad call relo against
'test_task_acquire_release_current' in section
'tp_btf/task_newtask'
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this failure in GCC which does not occur with LLVM:
$ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool
--debug gen skeleton
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/task_kfunc_success.bpf.linked3.o
name task_kfunc_success
libbpf: loading object 'task_kfunc_success' from buffer
libbpf: elf: section(2) .symtab, size 600, 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 8, link 0, flags 3, type=8
libbpf: elf: section(5) tp_btf/task_newtask, size 2704, link 0, flags 6, type=1
libbpf: sec 'tp_btf/task_newtask': found program
'test_task_acquire_release_argument' at insn offset 0 (0 bytes), code size 13
insns (104 bytes)
libbpf: sec 'tp_btf/task_newtask': found program
'test_task_acquire_release_current' at insn offset 13 (104 bytes), code size 13
insns (104 bytes)
libbpf: sec 'tp_btf/task_newtask': found program
'test_task_acquire_leave_in_map' at insn offset 26 (208 bytes), code size 56
insns (448 bytes)
libbpf: sec 'tp_btf/task_newtask': found program 'test_task_xchg_release' at
insn offset 82 (656 bytes), code size 88 insns (704 bytes)
libbpf: sec 'tp_btf/task_newtask': found program 'test_task_get_release' at
insn offset 170 (1360 bytes), code size 86 insns (688 bytes)
libbpf: sec 'tp_btf/task_newtask': found program
'test_task_current_acquire_release' at insn offset 256 (2048 bytes), code size
3 insns (24 bytes)
libbpf: sec 'tp_btf/task_newtask': found program 'test_task_from_pid_arg' at
insn offset 259 (2072 bytes), code size 26 insns (208 bytes)
libbpf: sec 'tp_btf/task_newtask': found program 'test_task_from_pid_current'
at insn offset 285 (2280 bytes), code size 26 insns (208 bytes)
libbpf: sec 'tp_btf/task_newtask': found program 'test_task_from_pid_invalid'
at insn offset 311 (2488 bytes), code size 27 insns (216 bytes)
libbpf: elf: section(6) license, size 4, link 0, flags 3, type=1
libbpf: license of task_kfunc_success is GPL
libbpf: elf: section(7) .maps, size 32, link 0, flags 3, type=1
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) .reltp_btf/task_newtask, size 864, link 2, flags 40,
type=9
libbpf: elf: section(10) .BTF, size 469313, link 0, flags 0, type=1
libbpf: looking for externs among 25 symbols...
libbpf: collected 4 externs total
libbpf: extern (ksym) #0: symbol 10, name bpf_task_acquire
libbpf: extern (ksym) #1: symbol 21, name bpf_task_from_pid
libbpf: extern (ksym) #2: symbol 18, name bpf_task_kptr_get
libbpf: extern (ksym) #3: symbol 11, name bpf_task_release
libbpf: map '__tasks_kfunc_map': at sec_idx 7, offset 0.
libbpf: map '__tasks_kfunc_map': found type = 1.
libbpf: map '__tasks_kfunc_map': found key [15], sz = 4.
libbpf: map '__tasks_kfunc_map': found value [6621], sz = 8.
libbpf: map '__tasks_kfunc_map': found max_entries = 1.
libbpf: map 'task_kfu.bss' (global data): at sec_idx 4, offset 0, flags 400.
libbpf: map 1 is "task_kfu.bss"
libbpf: sec '.reltp_btf/task_newtask': collecting relocation for section(5)
'tp_btf/task_newtask'
libbpf: sec '.reltp_btf/task_newtask': relo #0: insn #2 against 'pid'
libbpf: prog 'test_task_acquire_release_argument': found data map 1
(task_kfu.bss, sec 4, off 0) for insn 2
libbpf: sec '.reltp_btf/task_newtask': relo #1: insn #8 against
'bpf_task_acquire'
libbpf: prog 'test_task_acquire_release_argument': found extern #0
'bpf_task_acquire' (sym 10) for insn #8
libbpf: sec '.reltp_btf/task_newtask': relo #2: insn #10 against
'bpf_task_release'
libbpf: prog 'test_task_acquire_release_argument': found extern #3
'bpf_task_release' (sym 11) for insn #10
libbpf: sec '.reltp_btf/task_newtask': relo #3: insn #14 against 'pid'
libbpf: prog 'test_task_acquire_release_current': found data map 1
(task_kfu.bss, sec 4, off 0) for insn 1
libbpf: sec '.reltp_btf/task_newtask': relo #4: insn #21 against
'bpf_task_acquire&

[Bug target/107983] btf: bad call relo against 'test_task_acquire_release_current' in section 'tp_btf/task_newtask'

2022-12-05 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107983

--- Comment #1 from James Hilliard  ---
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/task_kfunc_success.bpf.linked3.o
format raw
[1] PTR '(anon)' type_id=3
[2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[3] ARRAY '(anon)' type_id=2 index_type_id=4 nr_elems=1
[4] INT '__ARRAY_SIZE_TYPE__' size=4 bits_offset=0 nr_bits=32 encoding=(none)
[5] PTR '(anon)' type_id=2
[6] PTR '(anon)' type_id=7
[7] STRUCT '__tasks_kfunc_map_value' size=8 vlen=1
'task' type_id=8 bits_offset=0
[8] PTR '(anon)' type_id=16
[9] STRUCT 'hash_map' size=32 vlen=4
'type' type_id=1 bits_offset=0
'key' type_id=5 bits_offset=64
'value' type_id=6 bits_offset=128
'max_entries' type_id=1 bits_offset=192
[10] VAR '__tasks_kfunc_map' type_id=9, linkage=global
[11] PTR '(anon)' type_id=12
[12] INT 'unsigned long long' size=8 bits_offset=0 nr_bits=64 encoding=(none)
[13] FUNC_PROTO '(anon)' ret_type_id=2 vlen=1
'ctx' type_id=11
[14] FUNC 'test_task_acquire_release_argument' type_id=13 linkage=global
[15] FUNC_PROTO '(anon)' ret_type_id=8 vlen=1
'(anon)' type_id=8
[16] STRUCT 'task_struct' size=10048 vlen=253
'thread_info' type_id=17 bits_offset=0
'__state' type_id=21 bits_offset=192
'stack' type_id=22 bits_offset=256
'usage' type_id=23 bits_offset=320
'flags' type_id=21 bits_offset=352
'ptrace' type_id=21 bits_offset=384
'on_cpu' type_id=2 bits_offset=416
'wake_entry' type_id=27 bits_offset=448
'wakee_flips' type_id=21 bits_offset=576
'wakee_flip_decay_ts' type_id=18 bits_offset=640
'last_wakee' type_id=8 bits_offset=704
'recent_used_cpu' type_id=2 bits_offset=768
'wake_cpu' type_id=2 bits_offset=800
'on_rq' type_id=2 bits_offset=832
'prio' type_id=2 bits_offset=864
'static_prio' type_id=2 bits_offset=896
'normal_prio' type_id=2 bits_offset=928
'rt_priority' type_id=21 bits_offset=960
'se' type_id=34 bits_offset=1024
'rt' type_id=46 bits_offset=3072
'dl' type_id=48 bits_offset=3456
'sched_class' type_id=64 bits_offset=5248
'sched_task_group' type_id=66 bits_offset=5312
'stats' type_id=67 bits_offset=5632
'btrace_seq' type_id=21 bits_offset=7680
'policy' type_id=21 bits_offset=7712
'nr_cpus_allowed' type_id=2 bits_offset=7744
'cpus_ptr' type_id=68 bits_offset=7808
'user_cpus_ptr' type_id=71 bits_offset=7872
'cpus_mask' type_id=70 bits_offset=7936
'migration_pending' type_id=22 bits_offset=8064
'migration_disabled' type_id=33 bits_offset=8128
'migration_flags' type_id=33 bits_offset=8144
'rcu_read_lock_nesting' type_id=2 bits_offset=8160
'rcu_read_unlock_special' type_id=74 bits_offset=8192
'rcu_node_entry' type_id=38 bits_offset=8256
'rcu_blocked_node' type_id=76 bits_offset=8384
'rcu_tasks_nvcsw' type_id=18 bits_offset=8448
'rcu_tasks_holdout' type_id=60 bits_offset=8512
'rcu_tasks_idx' type_id=60 bits_offset=8520
'rcu_tasks_idle_cpu' type_id=2 bits_offset=8544
'rcu_tasks_holdout_list' type_id=38 bits_offset=8576
'trc_reader_nesting' type_id=2 bits_offset=8704
'trc_ipi_to_cpu' type_id=2 bits_offset=8736
'trc_reader_special' type_id=74 bits_offset=8768
'trc_holdout_list' type_id=38 bits_offset=8832
'trc_blkd_node' type_id=38 bits_offset=8960
'trc_blkd_cpu' type_id=2 bits_offset=9088
'sched_info' type_id=77 bits_offset=9152
'tasks' type_id=38 bits_offset=9408
'pushable_tasks' type_id=78 bits_offset=9536
'pushable_dl_tasks' type_id=36 bits_offset=9856
'mm' type_id=79 bits_offset=10048
'active_mm' type_id=79 bits_offset=10112
'rss_stat' type_id=80 bits_offset=10176
'exit_state' type_id=2 bits_offset=10336
'exit_code' type_id=2 bits_offset=10368
'exit_signal' type_id=2 bits_offset=10400
'pdeath_signal' type_id=2 bits_offset=10432
'jobctl' type_id=18 bits_offset=10496
'personality' type_id=21 bits_offset=10560
'sched_reset_on_fork' type_id=21 bits_offset=10592 bitfield_size=1
'sched_contributes_to_load' type_id=21 bits_offset=10593
bitfield_size=1
'sched_migrated' type_id=21 bits_offset=10594 bitfield_size=1
'sched_remote_wakeup' type_id=21 bits_offset=10624 bitfield_size=1
'in_execve' type_id=21 bits_offset=10625 bitfield_size=1
'in_iowait' type_id=21 bits_offset=10626 bitfield_size=1
'restore_sigmask' type_id=21 bits_offset=10627 bitfield_size=1
'in_user_fault' type_id=21 bits_offset=10628 bitfield_size=1
'brk_randomized' type_id=21 bits_offset=10629 bitfie

[Bug target/108189] New: anonymous struct declared inside parameter list will not be visible outside of this definition or declaration

2022-12-20 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108189

Bug ID: 108189
   Summary: anonymous struct declared inside parameter list will
not be visible outside of this definition or
declaration
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this error which does not occur in llvm for a bpf
test(btf_dump_test_case_bitfields.c) in bpf-next:

progs/btf_dump_test_case_bitfields.c:85:7: error: anonymous struct declared
inside parameter list will not be visible outside of this definition or
declaration [-Werror]
   85 | int f(struct {
  |   ^~

[Bug target/108189] anonymous struct declared inside parameter list will not be visible outside of this definition or declaration

2022-12-20 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108189

--- Comment #2 from James Hilliard  ---
(In reply to Andrew Pinski from comment #1)
> The error is correct at least for C before C23.

Hmm, seeing it with -std=gnu2x passed still:
/home/buildroot/opt/cross/bin/bpf-gcc  -g -Werror -D__TARGET_ARCH_x86
-mlittle-endian
-I/home/buildroot/bpf-next/tools/bpf/resolve_btfids/libbpf/include
-I/home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/include
-I/home/buildroot/bpf-next/tools/testing/selftests/bpf
-I/home/buildroot/bpf-next/tools/include/uapi
-I/home/buildroot/bpf-next/tools/testing/selftests/usr/include -gbtf -mco-re
-Wno-error=attributes -Wno-error=address-of-packed-member
-Wno-compare-distinct-pointer-types -std=gnu2x -idirafter
/usr/lib/gcc/x86_64-linux-gnu/11/include -idirafter /usr/local/include
-idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include  -nostdinc -O2
-c progs/btf_dump_test_case_bitfields.c -mcpu=v3 -o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/btf_dump_test_case_bitfields.bpf.o
progs/btf_dump_test_case_bitfields.c:85:7: error: anonymous struct declared
inside parameter list will not be visible outside of this definition or
declaration [-Werror]
   85 | int f(struct {
  |   ^~

[Bug target/108189] anonymous struct declared inside parameter list will not be visible outside of this definition or declaration

2022-12-20 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108189

--- Comment #8 from James Hilliard  ---
(In reply to Andrew Pinski from comment #7)
> Yes the warning is really still correct even if a closer testcase would be:
> ```
> int f(struct {int t;} *b)
> {
>   return b->t;
> }
> 
> int f1(void *a)
> {
>   return f(a);
> }
> ```
> I am actually shocked clang didn't implement this warning since there is no
> type which is compatible with the typeof *b outside of function f.

Yeah, clang with -std=gnu17 -pedantic doesn't even complain at all from the
looks of it. Does it make sense to allow disabling this specific warning in
GCC?

[Bug target/108189] anonymous struct declared inside parameter list will not be visible outside of this definition or declaration

2022-12-20 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108189

--- Comment #9 from James Hilliard  ---
(In reply to Andrew Pinski from comment #5)
> Also Clang does not implement this warning at all.
> 
> It is a bug in bpf-next really.

What would be the correct way to fix these in bpf-next?

[Bug target/108189] anonymous struct declared inside parameter list will not be visible outside of this definition or declaration

2022-12-22 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108189

--- Comment #11 from James Hilliard  ---
(In reply to Andrew Pinski from comment #1)
> The error is correct at least for C before C23.

Can you clarify where exactly in the C23 specification that this will be
allowed?

[Bug debug/109253] New: libbpf: failed to find BTF info for global/extern symbol '__divdi3'

2023-03-22 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109253

Bug ID: 109253
   Summary: libbpf: failed to find BTF info for global/extern
symbol '__divdi3'
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this gen object error which does not occur in llvm for a bpf
test(tcp_ca_write_sk_pacing.c) in bpf-next.


GCC gen object failure:
$ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool
--debug gen object
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tcp_ca_write_sk_pacing.bpf.linked1.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tcp_ca_write_sk_pacing.bpf.o
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tcp_ca_write_sk_pacing.bpf.o'...
libbpf: failed to find BTF info for global/extern symbol '__divdi3'
Error: failed to link
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/tcp_ca_write_sk_pacing.bpf.o':
No such file or directory (2)

[Bug target/109255] New: libbpf: global 'input_data1': section mismatch 4 vs 5

2023-03-22 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109255

Bug ID: 109255
   Summary: libbpf: global 'input_data1': section mismatch 4 vs 5
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this gen object error which does not occur in llvm for a bpf
test(which uses both linked_vars1.c and linked_vars2.c) in bpf-next.


GCC gen object failure:
$ /home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool
--debug gen object
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars.linked1.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars1.bpf.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars2.bpf.o
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars1.bpf.o'...
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars2.bpf.o'...
libbpf: global 'input_data1': section mismatch 4 vs 5
Error: failed to link
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_vars2.bpf.o':
Invalid argument (22)

In broken GCC linked_vars1.bpf.o BTF I see:
[6900] VAR 'input_data1' type_id=8, linkage=global
[7129] DATASEC '.data' size=0 vlen=2
type_id=7020 offset=0 size=4 (VAR 'input_data_weak')
type_id=6900 offset=0 size=4 (VAR 'input_data1')

In broken GCC linked_vars2.bpf.o BTF I see:
[7068] VAR 'input_data1' type_id=8, linkage=extern
[7126] DATASEC '.bss' size=0 vlen=8
type_id=7068 offset=0 size=4 (VAR 'input_data1')
type_id=6921 offset=0 size=4 (VAR 'input_bss1')
type_id=6912 offset=0 size=4 (VAR 'output_sink2')
type_id=7092 offset=0 size=4 (VAR 'output_rodata2')
type_id=7006 offset=0 size=4 (VAR 'output_data2')
type_id=6899 offset=0 size=4 (VAR 'output_bss2')
type_id=6919 offset=0 size=4 (VAR 'input_bss_weak')
type_id=6979 offset=0 size=4 (VAR 'input_bss2')

In working LLVM linked_vars1.bpf.o BTF I see:
[8] VAR 'input_data1' type_id=4, linkage=global
[36] DATASEC '.data' size=0 vlen=2
type_id=8 offset=0 size=4 (VAR 'input_data1')
type_id=12 offset=0 size=4 (VAR 'input_data_weak')

In working LLVM linked_vars2.bpf.o BTF I see:
[31] VAR 'input_data1' type_id=4, linkage=extern

In working LLVM linked_vars.linked1.o(output of gen object) BTF I see:
[8] VAR 'input_data1' type_id=4, linkage=global
[42] DATASEC '.data' size=16 vlen=3
type_id=8 offset=0 size=4 (VAR 'input_data1')
type_id=12 offset=4 size=4 (VAR 'input_data_weak')
type_id=32 offset=8 size=4 (VAR 'input_data2')

[Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)

2023-03-22 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

Bug ID: 109256
   Summary: Error: failed to link 'linked_maps2.bpf.o': Cannot
allocate memory (12)
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this gen object error which does not occur in llvm for a bpf
test(which uses both linked_maps1.c and linked_maps2.c) in bpf-next.

It seems this is triggering a double free in libbpf, not entirely clear if this
is a gcc issue or libbpf issue.

GCC gen object failure:
==2125110== Command:
/home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug
gen object
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps.linked1.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps1.bpf.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o
==2125110== 
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps1.bpf.o'...
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o'...
Error: failed to link
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o':
Cannot allocate memory (12)
==2125110== Invalid free() / delete / delete[] / realloc()
==2125110==at 0x484B0C4: free (vg_replace_malloc.c:884)
==2125110==by 0x17F8AB: bpf_linker__free (linker.c:204)
==2125110==by 0x12833C: do_object (gen.c:1608)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x129B53: do_gen (gen.c:2332)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x12DB9E: main (main.c:539)
==2125110==  Address 0xda4b420 is 0 bytes after a block of size 0 free'd
==2125110==at 0x484B027: free (vg_replace_malloc.c:883)
==2125110==by 0x484D6F8: realloc (vg_replace_malloc.c:1451)
==2125110==by 0x181FA3: extend_sec (linker.c:1117)
==2125110==by 0x182326: linker_append_sec_data (linker.c:1201)
==2125110==by 0x1803DC: bpf_linker__add_file (linker.c:453)
==2125110==by 0x12829E: do_object (gen.c:1593)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x129B53: do_gen (gen.c:2332)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x12DB9E: main (main.c:539)
==2125110==  Block was alloc'd at
==2125110==at 0x484876A: malloc (vg_replace_malloc.c:392)
==2125110==by 0x484D6EB: realloc (vg_replace_malloc.c:1451)
==2125110==by 0x181FA3: extend_sec (linker.c:1117)
==2125110==by 0x182326: linker_append_sec_data (linker.c:1201)
==2125110==by 0x1803DC: bpf_linker__add_file (linker.c:453)
==2125110==by 0x12829E: do_object (gen.c:1593)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x129B53: do_gen (gen.c:2332)
==2125110==by 0x12CDAB: cmd_select (main.c:206)
==2125110==by 0x12DB9E: main (main.c:539)

[Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)

2023-03-22 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

--- Comment #2 from James Hilliard  ---
(In reply to Andrew Pinski from comment #1)
> Even a bad input should cause an error reported rather than a double free.
> So you should at least report it to libbpf too

libbpf bug report:
https://lore.kernel.org/bpf/cadvtj4o7zwuikkwntwfq0o_aax+46t_+ca9gvwmydwdrttg...@mail.gmail.com/

[Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)

2023-03-27 Thread james.hilliard1 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

James Hilliard  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from James Hilliard  ---
Fix has been merged upstream in bpf-next:
https://lore.kernel.org/bpf/20230328004738.381898-3-eddy...@gmail.com/
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=d08ab82f59d55b0e5acfeb453081278dfc33f232