]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
libctf: create: struct/union addition
authorNick Alcock <nick.alcock@oracle.com>
Thu, 24 Apr 2025 15:28:26 +0000 (16:28 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 17:07:42 +0000 (18:07 +0100)
commitcd8ea316666124567584637c179f3079d0083d11
tree6b0e971d7fa90cc95b486f9ad32d09e9307f859e
parentd5bb2772c6daa71d289b0ab2ff4a5b5e086eb63f
libctf: create: struct/union addition

There's one API addition here: the existing CTF_ADD_ROOT / CTF_ADD_NONROOT
flags can have a new flag ORed with them, CTF_ADD_STRUCT_BITFIELDS,
indicating that the newly-added struct/union is capable of having bitfields
added to it via the new ctf_add_member_bitfield function (see a later
commit).

Without this, you can only add bitfields via the deprecated slice or base
type encoding representations (the former will force CTF output).

Implementation notes: structs and unions are always added with a CTF_K_BIG
prefix: if promoting from a forward, one is added.  These are elided at
serialization time if they are not needed to encode this size of struct /
this number of members.  (This means you don't have to figure out in advance
if your struct will be too big for BTF: you can just add members to it,
and libctf will figure it out and upgrade the dict as needed, or tell you
it can't if you've forbidden such things.)

We take advantage of this to merge a couple of very similar functions,
saving a bit of code.
include/ctf-api.h
libctf/ctf-create.c