aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2024-07-15 22:08:10 +0100
committerNick Alcock <nick.alcock@oracle.com>2024-11-18 11:50:08 +0000
commitefefe2ec714a680f0c70a5777c1d474bae9061f1 (patch)
treeab2fa2417a575f0f9c35b75a1671811a12727f09
parent5d0de5db96bf59bd5411d5029938fc9d673ea9d5 (diff)
downloadbinutils-efefe2ec714a680f0c70a5777c1d474bae9061f1.zip
binutils-efefe2ec714a680f0c70a5777c1d474bae9061f1.tar.gz
binutils-efefe2ec714a680f0c70a5777c1d474bae9061f1.tar.bz2
libctf: do not deduplicate strings in the header
It is unreasonable to expect users to ctf_import the parent before being able to understand the header -- doubly so because the only string in the header which is likely to be deduplicable is the parent name, which is the same in every child, yet without the parent name being *available* in the child's strtab you cannot call ctf_parent_name to figure out which parent to import! libctf/ * ctf-serialize.c (ctf_preserialize): Prevent deduplication of header string fields. * ctf-open.c (ctf_set_base): Note this. * ctf-string.c (ctf_str_free_atom): Likewise.
-rw-r--r--libctf/ctf-open.c7
-rw-r--r--libctf/ctf-serialize.c4
-rw-r--r--libctf/ctf-string.c4
3 files changed, 11 insertions, 4 deletions
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 5ed1772..9e96d1f 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -364,7 +364,12 @@ ctf_set_base (ctf_dict_t *fp, const ctf_header_t *hp, unsigned char *base)
/* Note: before conversion, these will be set to values that will be
immediately invalidated by the conversion process, but the conversion
- process will call ctf_set_base() again to fix things up. */
+ process will call ctf_set_base() again to fix things up.
+
+ These labels are explicitly constrained from being deduplicated (even though
+ .ctf is usually a duplicated name), because they are the key to identifying
+ the parent dict (and determining that this dict is a child) in the first
+ place. */
if (hp->cth_parlabel != 0)
fp->ctf_parlabel = ctf_strptr (fp, hp->cth_parlabel);
diff --git a/libctf/ctf-serialize.c b/libctf/ctf-serialize.c
index 6517b6f..2a77ef0 100644
--- a/libctf/ctf-serialize.c
+++ b/libctf/ctf-serialize.c
@@ -1048,9 +1048,9 @@ ctf_preserialize (ctf_dict_t *fp)
hdrp = (ctf_header_t *) buf;
if ((fp->ctf_flags & LCTF_CHILD) && (fp->ctf_parname != NULL))
- ctf_str_add_ref (fp, fp->ctf_parname, &hdrp->cth_parname);
+ ctf_str_add_no_dedup_ref (fp, fp->ctf_parname, &hdrp->cth_parname);
if (fp->ctf_cuname != NULL)
- ctf_str_add_ref (fp, fp->ctf_cuname, &hdrp->cth_cuname);
+ ctf_str_add_no_dedup_ref (fp, fp->ctf_cuname, &hdrp->cth_cuname);
if (ctf_emit_symtypetab_sects (fp, &symstate, &t, objt_size, func_size,
objtidx_size, funcidx_size) < 0)
diff --git a/libctf/ctf-string.c b/libctf/ctf-string.c
index 2b1ce89..3c5a468 100644
--- a/libctf/ctf-string.c
+++ b/libctf/ctf-string.c
@@ -202,7 +202,9 @@ ctf_str_free_atom (void *a)
pulled in.)
Note that the *final strtab* may be entirely empty, if all its strings are
- shared with the parent: the atoms table is a superset. */
+ shared with the parent: the atoms table is a superset. (But this will never
+ happen in practice, because some header fields are explicitly never
+ deduplicated.) */
int
ctf_str_create_atoms (ctf_dict_t *fp)
{