aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ctf-create.c8
-rw-r--r--libctf/doc/ctf-spec.texi11
-rw-r--r--libctf/testsuite/libctf-writable/ctf-nonroot-addition.c38
-rw-r--r--libctf/testsuite/libctf-writable/ctf-nonroot-addition.lk1
4 files changed, 52 insertions, 6 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index 25dd44d..5820830 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. */
@@ -1073,7 +1073,7 @@ ctf_add_enumerator (ctf_dict_t *fp, ctf_id_t enid, const char *name,
/* Enumeration constant names are only added, and only checked for duplicates,
if the enum they are part of is a root-visible type. */
- if (root == CTF_ADD_ROOT && ctf_dynhash_lookup (fp->ctf_names, name))
+ if (root && ctf_dynhash_lookup (fp->ctf_names, name))
{
if (fp->ctf_flags & LCTF_STRICT_NO_DUP_ENUMERATORS)
return (ctf_set_errno (ofp, ECTF_DUPLICATE));
diff --git a/libctf/doc/ctf-spec.texi b/libctf/doc/ctf-spec.texi
index 5b2b881..b9f60d3 100644
--- a/libctf/doc/ctf-spec.texi
+++ b/libctf/doc/ctf-spec.texi
@@ -829,7 +829,7 @@ of kind @code{CTF_K_UNKNOWN}.
@item 4
@tab @code{CTF_K_ARRAY}
-@tab An array. @xref{Arrays}.
+@tab An array or SIMD vector. @xref{Arrays}.
@item 5
@tab @code{CTF_K_FUNCTION}
@@ -1064,7 +1064,7 @@ unused and will become used in future.
@tindex CTF_FP_LDCPLX
@item 6
@tab @code{CTF_FP_LDOUBLE}
-@tab This is a @code{long double}.
+@tab This is a @code{long double}, or quad-precision IEEE 754-2008 @code{__float128}.
@tindex CTF_FP_LDOUBLE
@item 7
@tab @code{CTF_FP_INTRVL}
@@ -1232,6 +1232,13 @@ Arrays are encoded as types of kind @code{CTF_K_ARRAY} in a @code{ctf_stype_t}.
Both size and kind for arrays are zero. The variable-length data is a
@code{ctf_array_t}: @code{vlen} in the info word should be disregarded and is
always zero.
+@c In CTFv4 and BTF, the @code{kind_flag} member of @{ctf_array_t} is not set.
+
+SIMD vectors are also encoded as types of kind @code{CTF_K_ARRAY} in a
+@code{ctf_stype_t}. Both size and kind for arrays are zero. The
+variable-length data is a @code{ctf_array_t}: @code{vlen} in the info word
+should be disregarded and is always zero.
+@c In CTFv4 and BTF, the @code{kind_flag} member of @{ctf_array_t} is set.
@verbatim
typedef struct ctf_array
diff --git a/libctf/testsuite/libctf-writable/ctf-nonroot-addition.c b/libctf/testsuite/libctf-writable/ctf-nonroot-addition.c
new file mode 100644
index 0000000..94ce05c
--- /dev/null
+++ b/libctf/testsuite/libctf-writable/ctf-nonroot-addition.c
@@ -0,0 +1,38 @@
+/* Make sure adding a non-root-visible type after adding a root-visible forward
+ adds a new type rather than promoting and returning the existing one. */
+
+#include <ctf-api.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ ctf_dict_t *fp;
+ ctf_id_t root, nonroot;
+ int err;
+
+ if ((fp = ctf_create (&err)) == NULL)
+ {
+ fprintf (stderr, "Cannot create: %s\n", ctf_errmsg (err));
+ return 1;
+ }
+
+ if ((root = ctf_add_forward (fp, CTF_ADD_ROOT, "foo", CTF_K_ENUM)) == CTF_ERR)
+ goto add_err;
+
+ if ((nonroot = ctf_add_enum (fp, CTF_ADD_NONROOT, "foo")) == CTF_ERR)
+ goto add_err;
+
+ if (nonroot == root)
+ fprintf (stderr, "Non-root addition should not promote root-visible forwards\n");
+ else
+ printf ("All done.\n");
+
+ ctf_dict_close (fp);
+ return 0;
+
+ add_err:
+ fprintf (stderr, "Cannot add: %s\n", ctf_errmsg (ctf_errno (fp)));
+}
diff --git a/libctf/testsuite/libctf-writable/ctf-nonroot-addition.lk b/libctf/testsuite/libctf-writable/ctf-nonroot-addition.lk
new file mode 100644
index 0000000..b944f73
--- /dev/null
+++ b/libctf/testsuite/libctf-writable/ctf-nonroot-addition.lk
@@ -0,0 +1 @@
+All done.