diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2025-03-24 14:15:08 +0000 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2025-03-24 14:15:08 +0000 |
commit | 12e265f2c88d7d9967db8e39845001d8a748f698 (patch) | |
tree | f8e28e4f76bf1ccd2fe32fcd862d0fefbf1b4fed /libctf/ctf-create.c | |
parent | 353f77466079e6be3b2da6188d25d7a49846e64c (diff) | |
download | binutils-12e265f2c88d7d9967db8e39845001d8a748f698.zip binutils-12e265f2c88d7d9967db8e39845001d8a748f698.tar.gz binutils-12e265f2c88d7d9967db8e39845001d8a748f698.tar.bz2 |
libctf: create: boost dtd_vlen_size when the vlen is grown
ctf_grow_vlen ensures the vlen region is big enough for some operation:
it does not boost the dtd_vlen_size, because the caller can (and
sometimes does) choose to write less than that in there.
Make sure the caller bumps the dtd_vlen_size appropriately, since
serialization now trusts this value to be correct rather than recomputing
all vlens from recorded-in-type-table scratch.
Diffstat (limited to 'libctf/ctf-create.c')
-rw-r--r-- | libctf/ctf-create.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index 36d085d..dc54d14 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -1508,6 +1508,8 @@ ctf_add_enumerator (ctf_dict_t *fp, ctf_id_t enid, const char *name, if (ctf_grow_vlen (fp, dtd, sizeof (ctf_enum_t) * (vlen + 1)) < 0) return -1; /* errno is set for us. */ + dtd->dtd_vlen_size += sizeof (ctf_enum_t); + /* Check for constant duplication within any given enum: only needed for non-root-visible types, since the duplicate detection above does the job for root-visible types just fine. */ @@ -1775,6 +1777,8 @@ ctf_add_member_bitfield (ctf_dict_t *fp, ctf_id_t souid, const char *name, if (ctf_grow_vlen (fp, dtd, sizeof (ctf_member_t) * (vlen + 1)) < 0) return (ctf_set_errno (ofp, ctf_errno (fp))); + + dtd->dtd_vlen_size += sizeof (ctf_member_t); memb = (ctf_member_t *) dtd->dtd_vlen; memb[vlen].ctm_name = ctf_str_add (fp, name); @@ -2012,6 +2016,7 @@ ctf_add_section_variable (ctf_dict_t *fp, uint32_t flag, const char *datasec, if (ctf_grow_vlen (fp, sec_dtd, sizeof (ctf_var_secinfo_t) * (vlen + 1)) < 0) goto err; + sec_dtd->dtd_vlen_size += sizeof (ctf_var_secinfo_t); sec = (ctf_var_secinfo_t *) sec_dtd->dtd_vlen; sec[vlen].cvs_type = (uint32_t) var_dtd->dtd_type; |