]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: Corrected index computation when present with unnamed struct fields
authorCupertino Miranda <cupertino.miranda@oracle.com>
Fri, 8 Mar 2024 13:33:42 +0000 (13:33 +0000)
committerCupertino Miranda <cupertino.miranda@oracle.com>
Wed, 20 Mar 2024 20:27:16 +0000 (20:27 +0000)
commitf10c18df9c02dc518360426c021971838e0012d2
tree22bda6703d1f7f26ac42dd12e04fa8d52440ea9f
parent624d025f62fdbc969cca08fdb1ac77246b8535a5
bpf: Corrected index computation when present with unnamed struct fields

Any unnamed non-struct-or-union field is not a member of the
BTF_KIND_STRUCT.
For that reason, CO-RE access strings indexes should take that in
consideration. This patch adds a condition to the incrementer that
computes the index for the field access.

gcc/ChangeLog:
* config/bpf/core-builtins.cc (bpf_core_get_index): Check if
field contains a DECL_NAME.

gcc/testsuite/ChangeLog:
* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: Add
testcase for unnamed fields.
gcc/config/bpf/core-builtins.cc
gcc/testsuite/gcc.target/bpf/core-builtin-fieldinfo-offset-1.c