diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2021-01-27 19:55:45 +0000 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2021-02-04 16:01:53 +0000 |
commit | caa170493e884215af4d07ea891ed1e2eeeb0578 (patch) | |
tree | 0d247c34146921550f50dd93081922fc2096132c /libctf | |
parent | 78f28b89e8c7a2c9e262e2819f0da5629f226efc (diff) | |
download | gdb-caa170493e884215af4d07ea891ed1e2eeeb0578.zip gdb-caa170493e884215af4d07ea891ed1e2eeeb0578.tar.gz gdb-caa170493e884215af4d07ea891ed1e2eeeb0578.tar.bz2 |
libctf: prohibit nameless ints, floats, typedefs and forwards
Now that "anonymous typedef nodes" have been extirpated, we can mandate
that things that have names in C must have names in CTF too. (Unlike
the no-forwards embarrassment, the deduplicator does nothing special
with names: types that have names in C will have the same name in CTF.
So we can assume that the CTF rules and the C rules are the same.)
include/ChangeLog
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (ECTF_NONAME): New.
(ECTF_NERR): Adjust.
libctf/ChangeLog
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-create.c (ctf_add_encoded): Add check for non-empty name.
(ctf_add_forward): Likewise.
(ctf_add_typedef): Likewise.
Diffstat (limited to 'libctf')
-rw-r--r-- | libctf/ChangeLog | 6 | ||||
-rw-r--r-- | libctf/ctf-create.c | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 9b0dad9..10178bc 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,11 @@ 2021-01-27 Nick Alcock <nick.alcock@oracle.com> + * ctf-create.c (ctf_add_encoded): Add check for non-empty name. + (ctf_add_forward): Likewise. + (ctf_add_typedef): Likewise. + +2021-01-27 Nick Alcock <nick.alcock@oracle.com> + * ctf-open.c (init_types): Rip out code to check anonymous typedef nodes. * ctf-create.c (ctf_add_reftype): Likewise. diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index cf47384..cf12557 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -1595,6 +1595,9 @@ ctf_add_encoded (ctf_dict_t *fp, uint32_t flag, if (ep == NULL) return (ctf_set_errno (fp, EINVAL)); + if (name == NULL || name[0] == '\0') + return (ctf_set_errno (fp, ECTF_NONAME)); + if ((type = ctf_add_generic (fp, flag, name, kind, &dtd)) == CTF_ERR) return CTF_ERR; /* errno is set for us. */ @@ -1961,11 +1964,13 @@ ctf_add_forward (ctf_dict_t *fp, uint32_t flag, const char *name, if (!ctf_forwardable_kind (kind)) return (ctf_set_errno (fp, ECTF_NOTSUE)); + if (name == NULL || name[0] == '\0') + return (ctf_set_errno (fp, ECTF_NONAME)); + /* If the type is already defined or exists as a forward tag, just return the ctf_id_t of the existing definition. */ - if (name != NULL) - type = ctf_lookup_by_rawname (fp, kind, name); + type = ctf_lookup_by_rawname (fp, kind, name); if (type) return type; @@ -1990,6 +1995,9 @@ ctf_add_typedef (ctf_dict_t *fp, uint32_t flag, const char *name, if (ref == CTF_ERR || ref > CTF_MAX_TYPE) return (ctf_set_errno (fp, EINVAL)); + if (name == NULL || name[0] == '\0') + return (ctf_set_errno (fp, ECTF_NONAME)); + if (ref != 0 && ctf_lookup_by_id (&tmp, ref) == NULL) return CTF_ERR; /* errno is set for us. */ |