imcs
imcs_add_string(struct imcs *imcs, const char *str)
se = (struct strentry *)hash_find(imcs->htab, str, &slot);
hash_insert(imcs->htab, slot, &se->se_key, str);
se->se_off = imcs->stab.coff;
dbuf_copy(&imcs->stab, str, strlen(str) + 1);
imcs_add_func(struct imcs *imcs, struct itype *it)
dbuf_copy(&imcs->body, &func, sizeof(func));
dbuf_copy(&imcs->body, &func, sizeof(func));
dbuf_copy(&imcs->body, &arg, sizeof(arg));
imcs_add_obj(struct imcs *imcs, struct itype *it)
dbuf_copy(&imcs->body, &type, sizeof(type));
imcs_add_type(struct imcs *imcs, struct itype *it)
ctt.ctt_name = imcs_add_string(imcs, it_name(it));
dbuf_copy(&imcs->body, &ctt, ctsz);
dbuf_copy(&imcs->body, &eob, sizeof(eob));
dbuf_copy(&imcs->body, &cta, sizeof(cta));
imcs_add_string(imcs, im_name(im));
dbuf_copy(&imcs->body, &ctm, sizeof(ctm));
imcs_add_string(imcs, im_name(im));
dbuf_copy(&imcs->body, &ctlm, sizeof(ctlm));
dbuf_copy(&imcs->body, &arg, sizeof(arg));
dbuf_copy(&imcs->body, &arg, sizeof(arg));
cte.cte_name = imcs_add_string(imcs, im_name(im));
dbuf_copy(&imcs->body, &cte, sizeof(cte));
imcs_generate(struct imcs *imcs, struct ctf_header *cth, const char *label)
memset(imcs, 0, sizeof(*imcs));
dbuf_realloc(&imcs->body, DBUF_CHUNKSZ);
dbuf_realloc(&imcs->stab, DBUF_CHUNKSZ);
imcs->htab = hash_init(10);
if (imcs->htab == NULL)
dbuf_copy(&imcs->stab, "", 1);
lbl.ctl_label = imcs_add_string(imcs, label);
dbuf_copy(&imcs->body, &lbl, sizeof(lbl));
cth->cth_objtoff = dbuf_pad(&imcs->body, 2);
imcs_add_obj(imcs, it);
cth->cth_funcoff = dbuf_pad(&imcs->body, 2);
imcs_add_func(imcs, it);
cth->cth_typeoff = dbuf_pad(&imcs->body, 4);
imcs_add_type(imcs, it);
cth->cth_stroff = imcs->body.coff;
cth->cth_strlen = imcs->stab.coff;
struct imcs imcs;
imcs_generate(&imcs, &cth, label);
ctflen = sizeof(cth) + imcs.body.coff + imcs.stab.coff;
memcpy(p, imcs.body.data, imcs.body.coff);
p += imcs.body.coff;
memcpy(p, imcs.stab.data, imcs.stab.coff);
p += imcs.stab.coff;