]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
libctf: serialize: check the type section for BTF-incompatible types
authorNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 12:01:21 +0000 (13:01 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 17:07:44 +0000 (18:07 +0100)
commitdb9897214528ad4fef682b5fba79e6b8aea40c35
tree61437d2b7905d6b855a1c234130af1a85135a678
parent5ec23dfb74b1962e4a306031776a07c92d18c18a
libctf: serialize: check the type section for BTF-incompatible types

We add a new ctf_type_sect_is_btf function (internal to ctf-serialize.c) to
check the type section against the write prohibitions list and (after
write-suppression) against the set of types allowed in BTF, and determine
whether this type section contains any types BTF does not allow.

CTF-specific type kinds like CTF_K_FLOAT are obviously prohibited in BTF, as
are CTF-specific prefixes, except that CTF_K_BIG is allowed if and only if
both its ctt_size and vlen are still zero: in that case it will be elided by
type section writeout and will never appear in the BTF at all.

Structs are checked to make sure they don't use any nameless padding members
and that (if they are bitfields) all their offsets will still fit after
conversion from CTF_K_BIG gap-between-struct-members representation (if they
are not bitfields, we know they will fit, but for bitfields, they might be
too big).
libctf/ctf-serialize.c