]> git.ipfire.org Git - thirdparty/gcc.git/commit
btf: emit non-representable bitfield as void
authorDavid Faust <david.faust@oracle.com>
Thu, 11 Apr 2024 18:18:55 +0000 (11:18 -0700)
committerDavid Faust <david.faust@oracle.com>
Thu, 11 Apr 2024 22:19:13 +0000 (15:19 -0700)
commitf079d69d7b1338522562516537d96e9e1285c95e
treedb75d89e5644f12e741a7da96cfa3e160608c2e7
parent33f83d3cd84f9876180a2e2a9d1ea082debdaa37
btf: emit non-representable bitfield as void

This patch fixes an issue with mangled BTF that could occur when
a struct type contains a bitfield member which cannot be represented
in BTF.  It is undefined what should happen in such cases, but we can
at least do something reasonable.

Commit

  936dd627cd9 "btf: do not skip members of data type with type id
  BTF_VOID_TYPEID"

made a similar change for un-representable non-bitfield members, but
had an unintended side-effect of mangling BTF for un-representable
bitfields: the struct (or union) would account for the offending
bitfield in its member count but the bitfield member itself was
not emitted, making the member count incorrect.

This change ensures that non-representable bitfield members of struct
and union types are always emitted with BTF_VOID_TYPEID.  This avoids
corrupting the BTF information for the entire struct or union type.

gcc/
* btfout.cc (btf_asm_sou_member): Always emit non-representable
bitfield members as having 'void' type.  Refactor slightly.

gcc/testsuite/
* gcc.dg/debug/btf/btf-bitfields-4.c: Add two new checks.
gcc/btfout.cc
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c