This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 04/11] libctf: create: ctf_add_type should hand back already-added non-SoUs
- From: Nick Alcock <nick dot alcock at oracle dot com>
- To: binutils at sourceware dot org
- Cc: indu dot bhagat at oracle dot com, jose dot marchesi at oracle dot com, nick dot alcock at oracle dot com
- Date: Mon, 16 Dec 2019 22:53:50 +0000
- Subject: [PATCH 04/11] libctf: create: ctf_add_type should hand back already-added non-SoUs
- References: <20191216225357.87247-1-nick.alcock@oracle.com>
When we add a type from a dictionary and then try to add it again, we
should hand it back unchanged unless it is a structure, union or enum
with a different number of members. That's what the comment says we do.
Instead, we hand it back unchanged *only* if it is a structure, union or
enum with the same number of members: non-structs, unions and enums are
unconditionally added. This causes extreme type bloating and (in
conjunction with the bug fixed by the next commit) can easily lead to
the same type being mistakenly added to a dictionary more than once
(which, for forwards, was not banned and led to dictionary corruption).
---
libctf/ctf-create.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index 1099fd3a2c..fd7d553a6c 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -1665,13 +1665,17 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
kind and (if a struct or union) has the same number of members, hand it
straight back. */
- if ((ctf_type_kind_unsliced (tmp_fp, tmp) == (int) kind)
- && (kind == CTF_K_STRUCT || kind == CTF_K_UNION
- || kind == CTF_K_ENUM))
+ if (ctf_type_kind_unsliced (tmp_fp, tmp) == (int) kind)
{
- if ((dst_tp = ctf_lookup_by_id (&tmp_fp, dst_type)) != NULL)
- if (vlen == LCTF_INFO_VLEN (tmp_fp, dst_tp->ctt_info))
- return tmp;
+ if (kind == CTF_K_STRUCT || kind == CTF_K_UNION
+ || kind == CTF_K_ENUM)
+ {
+ if ((dst_tp = ctf_lookup_by_id (&tmp_fp, dst_type)) != NULL)
+ if (vlen == LCTF_INFO_VLEN (tmp_fp, dst_tp->ctt_info))
+ return tmp;
+ }
+ else
+ return tmp;
}
}
--
2.24.1.242.gb57e918ca5