aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/tools/ctf/cvt
diff options
context:
space:
mode:
authorAlexander Kabaev <kan@FreeBSD.org>2010-05-03 18:04:17 +0000
committerAlexander Kabaev <kan@FreeBSD.org>2010-05-03 18:04:17 +0000
commit59879e52c1d56b4c7e7ff1cee46770722d254fe8 (patch)
treec1213ce3a18f1e15e9eb7be442b559119f0dfa18 /cddl/contrib/opensolaris/tools/ctf/cvt
parent2d5d7f7f61f2217db46e1f9673aecc111d651df9 (diff)
downloadsrc-59879e52c1d56b4c7e7ff1cee46770722d254fe8.tar.gz
src-59879e52c1d56b4c7e7ff1cee46770722d254fe8.zip
Do not encode more than CTF_MAX_VLEN(1023) enum members.
CTF can not represent enums with more than CTF_MAX_VLEN members, but ctfconvert will happily ignore that limitation and create CTF section no other tool can interpret. This change is different from similar change from upstream, which just returns an error if big enum is encountered. Doing that means that every FreeBSD kernel with compiled in hwpmc will have no useable CTF information due to pmc_event enum having 1236+ members.
Notes
Notes: svn path=/head/; revision=207578
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf/cvt')
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
index 6a9d67aa3002..d95dd1db1653 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
@@ -355,14 +355,21 @@ write_type(void *arg1, void *arg2)
for (i = 0, ep = tp->t_emem; ep != NULL; ep = ep->el_next)
i++; /* count up enum members */
+ if (i > CTF_MAX_VLEN) {
+ warning("enum %s has too many values: %d > %d\n",
+ tdesc_name(tp), i, CTF_MAX_VLEN);
+ i = CTF_MAX_VLEN;
+ }
+
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, isroot, i);
write_sized_type_rec(b, &ctt, tp->t_size);
- for (ep = tp->t_emem; ep != NULL; ep = ep->el_next) {
+ for (ep = tp->t_emem; ep != NULL && i > 0; ep = ep->el_next) {
offset = strtab_insert(&b->ctb_strtab, ep->el_name);
cte.cte_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset);
cte.cte_value = ep->el_number;
ctf_buf_write(b, &cte, sizeof (cte));
+ i--;
}
break;