[PATCH 1/3] libctf: create: addition of non-root types should not return root types
Bruce McCulloch
bruce.mcculloch@oracle.com
Fri Jun 27 18:45:14 GMT 2025
Hi Nick,
This LGTM.
Bruce McCulloch
On 6/27/25 11:31 AM, Nick Alcock via Binutils wrote:
> libctf/
> * ctf-create.c (ctf_add_struct_sized): Check the root-visible flag when
> doing forward promotion.
> (ctf_add_union_sized): Likewise.
> (ctf_add_enum): Likewise.
> ---
> libctf/ctf-create.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
> index 25dd44def3b..ca984e81b51 100644
> --- a/libctf/ctf-create.c
> +++ b/libctf/ctf-create.c
> @@ -788,7 +788,7 @@ ctf_add_struct_sized (ctf_dict_t *fp, uint32_t flag, const char *name,
> size_t initial_vlen = sizeof (ctf_lmember_t) * INITIAL_VLEN;
>
> /* Promote root-visible forwards to structs. */
> - if (name != NULL)
> + if (name != NULL && flag == CTF_ADD_ROOT)
> type = ctf_lookup_by_rawname (fp, CTF_K_STRUCT, name);
>
> /* Prohibit promotion if this type was ctf_open()ed. */
> @@ -832,7 +832,7 @@ ctf_add_union_sized (ctf_dict_t *fp, uint32_t flag, const char *name,
> size_t initial_vlen = sizeof (ctf_lmember_t) * INITIAL_VLEN;
>
> /* Promote root-visible forwards to unions. */
> - if (name != NULL)
> + if (name != NULL && flag == CTF_ADD_ROOT)
> type = ctf_lookup_by_rawname (fp, CTF_K_UNION, name);
>
> /* Prohibit promotion if this type was ctf_open()ed. */
> @@ -875,7 +875,7 @@ ctf_add_enum (ctf_dict_t *fp, uint32_t flag, const char *name)
> size_t initial_vlen = sizeof (ctf_enum_t) * INITIAL_VLEN;
>
> /* Promote root-visible forwards to enums. */
> - if (name != NULL)
> + if (name != NULL && flag == CTF_ADD_ROOT)
> type = ctf_lookup_by_rawname (fp, CTF_K_ENUM, name);
>
> /* Prohibit promotion if this type was ctf_open()ed. */
More information about the Binutils
mailing list