aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-link.c
diff options
context:
space:
mode:
Diffstat (limited to 'libctf/ctf-link.c')
-rw-r--r--libctf/ctf-link.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 3bfc36e..0d122e6 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -336,6 +336,8 @@ ctf_create_per_cu (ctf_dict_t *fp, ctf_dict_t *input, const char *cu_name)
return NULL;
}
+ /* The deduplicator is ready for strict enumerator value checking. */
+ cu_fp->ctf_flags |= LCTF_STRICT_NO_DUP_ENUMERATORS;
ctf_import_unref (cu_fp, fp);
if ((dynname = ctf_new_per_cu_name (fp, ctf_name)) == NULL)
@@ -1233,6 +1235,9 @@ ctf_link_deduplicating_per_cu (ctf_dict_t *fp)
goto err_inputs;
}
+ /* The deduplicator is ready for strict enumerator value checking. */
+ out->ctf_flags |= LCTF_STRICT_NO_DUP_ENUMERATORS;
+
/* Share the atoms table to reduce memory usage. */
out->ctf_dedup_atoms = fp->ctf_dedup_atoms_alloc;
@@ -1498,6 +1503,7 @@ int
ctf_link (ctf_dict_t *fp, int flags)
{
int err;
+ int oldflags = fp->ctf_flags;
fp->ctf_link_flags = flags;
@@ -1515,9 +1521,9 @@ ctf_link (ctf_dict_t *fp, int flags)
if (fp->ctf_link_outputs == NULL)
return ctf_set_errno (fp, ENOMEM);
- fp->ctf_flags |= LCTF_LINKING;
+ fp->ctf_flags |= LCTF_LINKING & LCTF_STRICT_NO_DUP_ENUMERATORS;
ctf_link_deduplicating (fp);
- fp->ctf_flags &= ~LCTF_LINKING;
+ fp->ctf_flags = oldflags;
if ((ctf_errno (fp) != 0) && (ctf_errno (fp) != ECTF_NOCTFDATA))
return -1;
@@ -1537,14 +1543,14 @@ ctf_link (ctf_dict_t *fp, int flags)
const char *to = (const char *) k;
if (ctf_create_per_cu (fp, NULL, to) == NULL)
{
- fp->ctf_flags &= ~LCTF_LINKING;
+ fp->ctf_flags = oldflags;
ctf_next_destroy (i);
return -1; /* Errno is set for us. */
}
}
if (err != ECTF_NEXT_END)
{
- fp->ctf_flags &= ~LCTF_LINKING;
+ fp->ctf_flags = oldflags;
ctf_err_warn (fp, 1, err, _("iteration error creating empty CUs"));
return ctf_set_errno (fp, err);
}
@@ -2040,9 +2046,14 @@ ctf_link_write (ctf_dict_t *fp, size_t *size, size_t threshold)
goto err_no;
}
- /* Turn off the is-linking flag on all the dicts in this link. */
+ /* Turn off the is-linking flag on all the dicts in this link: if the strict enum
+ checking flag is off on the parent, turn it off on all the children too. */
for (i = 0; i < arg.i; i++)
- arg.files[i]->ctf_flags &= ~LCTF_LINKING;
+ {
+ arg.files[i]->ctf_flags &= ~LCTF_LINKING;
+ if (!(fp->ctf_flags & LCTF_STRICT_NO_DUP_ENUMERATORS))
+ arg.files[i]->ctf_flags &= ~LCTF_STRICT_NO_DUP_ENUMERATORS;
+ }
*size = fsize;
free (arg.names);
@@ -2061,9 +2072,13 @@ ctf_link_write (ctf_dict_t *fp, size_t *size, size_t threshold)
err_no:
ctf_set_errno (fp, errno);
- /* Turn off the is-linking flag on all the dicts in this link. */
+ /* Turn off the is-linking flag on all the dicts in this link, as above. */
for (i = 0; i < arg.i; i++)
- arg.files[i]->ctf_flags &= ~LCTF_LINKING;
+ {
+ arg.files[i]->ctf_flags &= ~LCTF_LINKING;
+ if (!(fp->ctf_flags & LCTF_STRICT_NO_DUP_ENUMERATORS))
+ arg.files[i]->ctf_flags &= ~LCTF_STRICT_NO_DUP_ENUMERATORS;
+ }
err:
free (buf);
if (f)