]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
libctf: create: addition of non-root types should not return root types
authorNick Alcock <nick.alcock@oracle.com>
Thu, 26 Jun 2025 14:45:31 +0000 (15:45 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 27 Jun 2025 12:07:52 +0000 (13:07 +0100)
commit029fdef75d32dd44284b97f29d38f92741162594
treeeb6b529e0132fcd5e9cbdcea76027245324e08ca
parent0d366df4431cd0f3e84b7f1ac3abd0291d002538
libctf: create: addition of non-root types should not return root types

If you add a non-root type to a dict, you should always get a new, unique
type ID back, even if a root-visible type with the same name already exists.
Unfortunately, if the root-visible type is a forward, and you're adding a
non-root-visible struct, union, or enum, the machinery to detect forwards
and promote them to the concrete type fires in this case and returns the
root-visible type!  If this is an enum being inserted hidden because its
enumerands conflict with some other enum, this will lead to failure later
on: in any case, it's seriously counterintuitive to add a non-root- visible
type and get a root-visible one instead.

Fix this by checking the root-visible flag properly and only checking for
forwards if this type is root-visible.  (This may lead to a certain degree
of proliferation of non-root-visible forwards: we can add a cleanup pass for
those later if needed.)

libctf/
* ctf-create.c (ctf_add_sou_sized): Check the root-visible flag when
doing forward promotion.
(ctf_add_enum_internal): Likewise.
(ctf_add_enum_encoded_internal): Likewise.
libctf/ctf-create.c