Lines Matching refs:fp
60 ctf_file_t *fp; in ctf_create() local
73 if ((fp = ctf_bufopen(&cts, NULL, NULL, errp)) == NULL) { in ctf_create()
78 fp->ctf_flags |= LCTF_RDWR; in ctf_create()
79 fp->ctf_dthashlen = hashlen; in ctf_create()
81 fp->ctf_dthash = hash; in ctf_create()
82 fp->ctf_dtstrlen = sizeof (_CTF_STRTAB_TEMPLATE); in ctf_create()
83 fp->ctf_dtnextid = 1; in ctf_create()
84 fp->ctf_dtoldid = 0; in ctf_create()
86 return (fp); in ctf_create()
92 ctf_file_t *fp; in ctf_fdcreate() local
115 if ((fp = ctf_fdcreate_int(fd, errp, &cts)) == NULL) { in ctf_fdcreate()
120 fp->ctf_flags |= LCTF_RDWR; in ctf_fdcreate()
121 fp->ctf_dthashlen = hashlen; in ctf_fdcreate()
123 fp->ctf_dthash = hash; in ctf_fdcreate()
124 fp->ctf_dtstrlen = sizeof (_CTF_STRTAB_TEMPLATE); in ctf_fdcreate()
125 fp->ctf_dtnextid = 1; in ctf_fdcreate()
126 fp->ctf_dtoldid = 0; in ctf_fdcreate()
128 return (fp); in ctf_fdcreate()
226 ctf_ref_inc(ctf_file_t *fp, ctf_id_t tid) in ctf_ref_inc() argument
228 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, tid); in ctf_ref_inc()
233 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_ref_inc()
244 ctf_ref_dec(ctf_file_t *fp, ctf_id_t tid) in ctf_ref_dec() argument
246 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, tid); in ctf_ref_dec()
251 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_ref_dec()
278 ctf_update(ctf_file_t *fp) in ctf_update() argument
297 uintptr_t symbase = (uintptr_t)fp->ctf_symtab.cts_data; in ctf_update()
298 uintptr_t strbase = (uintptr_t)fp->ctf_strtab.cts_data; in ctf_update()
300 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_update()
301 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_update()
303 if (!(fp->ctf_flags & LCTF_DIRTY)) in ctf_update()
316 if (fp->ctf_flags & LCTF_CHILD) { in ctf_update()
317 if (fp->ctf_parname == NULL) { in ctf_update()
322 plen = strlen(fp->ctf_parname) + 1; in ctf_update()
323 plabel = ctf_label_topmost(fp->ctf_parent); in ctf_update()
333 for (labelsize = 0, dld = ctf_list_next(&fp->ctf_dldefs); in ctf_update()
341 for (size = 0, dtd = ctf_list_next(&fp->ctf_dtdefs); in ctf_update()
382 dsd = ctf_list_next(&fp->ctf_dsdefs); in ctf_update()
383 for (objsize = 0, funcsize = 0, i = 0; i < fp->ctf_nsyms; i++) { in ctf_update()
386 if (fp->ctf_symtab.cts_entsize == sizeof (Elf32_Sym)) { in ctf_update()
440 hdr.cth_strlen = fp->ctf_dtstrlen + plen; in ctf_update()
448 return (ctf_set_errno(fp, EAGAIN)); in ctf_update()
469 bcopy(fp->ctf_parname, s, plen); in ctf_update()
477 for (dld = ctf_list_next(&fp->ctf_dldefs); dld != NULL; in ctf_update()
495 for (dtd = ctf_list_next(&fp->ctf_dtdefs); in ctf_update()
584 dsd = ctf_list_next(&fp->ctf_dsdefs); in ctf_update()
585 for (i = 0; i < fp->ctf_nsyms; i++) { in ctf_update()
587 if (fp->ctf_symtab.cts_entsize == sizeof (Elf32_Sym)) { in ctf_update()
648 if (fp->ctf_nsyms == 0) { in ctf_update()
652 symp = &fp->ctf_symtab; in ctf_update()
653 strp = &fp->ctf_strtab; in ctf_update()
658 return (ctf_set_errno(fp, err)); in ctf_update()
661 (void) ctf_setmodel(nfp, ctf_getmodel(fp)); in ctf_update()
662 (void) ctf_import(nfp, fp->ctf_parent); in ctf_update()
664 nfp->ctf_refcnt = fp->ctf_refcnt; in ctf_update()
665 nfp->ctf_flags |= fp->ctf_flags & ~LCTF_DIRTY; in ctf_update()
666 nfp->ctf_dthash = fp->ctf_dthash; in ctf_update()
667 nfp->ctf_dthashlen = fp->ctf_dthashlen; in ctf_update()
668 nfp->ctf_dtdefs = fp->ctf_dtdefs; in ctf_update()
669 nfp->ctf_dsdefs = fp->ctf_dsdefs; in ctf_update()
670 nfp->ctf_dldefs = fp->ctf_dldefs; in ctf_update()
671 nfp->ctf_dtstrlen = fp->ctf_dtstrlen; in ctf_update()
672 nfp->ctf_dtnextid = fp->ctf_dtnextid; in ctf_update()
673 nfp->ctf_dtoldid = fp->ctf_dtnextid - 1; in ctf_update()
674 nfp->ctf_specific = fp->ctf_specific; in ctf_update()
676 fp->ctf_dthash = NULL; in ctf_update()
677 fp->ctf_dthashlen = 0; in ctf_update()
678 bzero(&fp->ctf_dtdefs, sizeof (ctf_list_t)); in ctf_update()
679 bzero(&fp->ctf_dsdefs, sizeof (ctf_list_t)); in ctf_update()
680 bzero(&fp->ctf_dldefs, sizeof (ctf_list_t)); in ctf_update()
689 sname = fp->ctf_symtab.cts_name; in ctf_update()
690 bzero(&fp->ctf_symtab, sizeof (ctf_sect_t)); in ctf_update()
691 fp->ctf_symtab.cts_name = sname; in ctf_update()
693 sname = fp->ctf_strtab.cts_name; in ctf_update()
694 bzero(&fp->ctf_strtab, sizeof (ctf_sect_t)); in ctf_update()
695 fp->ctf_strtab.cts_name = sname; in ctf_update()
697 bcopy(fp, &ofp, sizeof (ctf_file_t)); in ctf_update()
698 bcopy(nfp, fp, sizeof (ctf_file_t)); in ctf_update()
706 fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs; in ctf_update()
707 fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions; in ctf_update()
708 fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums; in ctf_update()
709 fp->ctf_lookups[3].ctl_hash = &fp->ctf_names; in ctf_update()
718 ctf_dtd_insert(ctf_file_t *fp, ctf_dtdef_t *dtd) in ctf_dtd_insert() argument
720 ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1); in ctf_dtd_insert()
722 dtd->dtd_hash = fp->ctf_dthash[h]; in ctf_dtd_insert()
723 fp->ctf_dthash[h] = dtd; in ctf_dtd_insert()
724 ctf_list_append(&fp->ctf_dtdefs, dtd); in ctf_dtd_insert()
728 ctf_dtd_delete(ctf_file_t *fp, ctf_dtdef_t *dtd) in ctf_dtd_delete() argument
730 ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1); in ctf_dtd_delete()
731 ctf_dtdef_t *p, **q = &fp->ctf_dthash[h]; in ctf_dtd_delete()
756 fp->ctf_dtstrlen -= len; in ctf_dtd_delete()
759 ctf_ref_dec(fp, dmd->dmd_type); in ctf_dtd_delete()
765 ctf_ref_dec(fp, dtd->dtd_data.ctt_type); in ctf_dtd_delete()
768 ctf_ref_dec(fp, dtd->dtd_u.dtu_argv[i]); in ctf_dtd_delete()
773 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_contents); in ctf_dtd_delete()
774 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_index); in ctf_dtd_delete()
777 ctf_ref_dec(fp, dtd->dtd_data.ctt_type); in ctf_dtd_delete()
783 ctf_ref_dec(fp, dtd->dtd_data.ctt_type); in ctf_dtd_delete()
790 fp->ctf_dtstrlen -= len; in ctf_dtd_delete()
793 ctf_list_delete(&fp->ctf_dtdefs, dtd); in ctf_dtd_delete()
798 ctf_dtd_lookup(ctf_file_t *fp, ctf_id_t type) in ctf_dtd_lookup() argument
800 ulong_t h = type & (fp->ctf_dthashlen - 1); in ctf_dtd_lookup()
803 if (fp->ctf_dthash == NULL) in ctf_dtd_lookup()
806 for (dtd = fp->ctf_dthash[h]; dtd != NULL; dtd = dtd->dtd_hash) { in ctf_dtd_lookup()
815 ctf_dsd_lookup(ctf_file_t *fp, ulong_t idx) in ctf_dsd_lookup() argument
819 for (dsd = ctf_list_next(&fp->ctf_dsdefs); dsd != NULL; in ctf_dsd_lookup()
832 ctf_dsd_insert(ctf_file_t *fp, ctf_dsdef_t *dsd) in ctf_dsd_insert() argument
836 for (i = ctf_list_next(&fp->ctf_dsdefs); i != NULL; in ctf_dsd_insert()
843 ctf_list_append(&fp->ctf_dsdefs, dsd); in ctf_dsd_insert()
847 ctf_list_insert_before(&fp->ctf_dsdefs, i, dsd); in ctf_dsd_insert()
852 ctf_dsd_delete(ctf_file_t *fp, ctf_dsdef_t *dsd) in ctf_dsd_delete() argument
857 ctf_list_delete(&fp->ctf_dsdefs, dsd); in ctf_dsd_delete()
862 ctf_dld_lookup(ctf_file_t *fp, const char *name) in ctf_dld_lookup() argument
866 for (dld = ctf_list_next(&fp->ctf_dldefs); dld != NULL; in ctf_dld_lookup()
876 ctf_dld_insert(ctf_file_t *fp, ctf_dldef_t *dld, uint_t pos) in ctf_dld_insert() argument
881 ctf_list_prepend(&fp->ctf_dldefs, dld); in ctf_dld_insert()
885 for (l = ctf_list_next(&fp->ctf_dldefs); pos != 0 && dld != NULL; in ctf_dld_insert()
890 ctf_list_append(&fp->ctf_dldefs, dld); in ctf_dld_insert()
892 ctf_list_insert_before(&fp->ctf_dsdefs, l, dld); in ctf_dld_insert()
896 ctf_dld_delete(ctf_file_t *fp, ctf_dldef_t *dld) in ctf_dld_delete() argument
898 ctf_list_delete(&fp->ctf_dldefs, dld); in ctf_dld_delete()
903 fp->ctf_dtstrlen -= len; in ctf_dld_delete()
918 ctf_discard(ctf_file_t *fp) in ctf_discard() argument
922 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_discard()
923 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_discard()
925 if (!(fp->ctf_flags & LCTF_DIRTY)) in ctf_discard()
928 for (dtd = ctf_list_prev(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) { in ctf_discard()
930 if (dtd->dtd_type <= fp->ctf_dtoldid) in ctf_discard()
933 ctf_dtd_delete(fp, dtd); in ctf_discard()
936 fp->ctf_dtnextid = fp->ctf_dtoldid + 1; in ctf_discard()
937 fp->ctf_flags &= ~LCTF_DIRTY; in ctf_discard()
943 ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp) in ctf_add_generic() argument
950 return (ctf_set_errno(fp, EINVAL)); in ctf_add_generic()
952 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_generic()
953 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_generic()
955 if (CTF_INDEX_TO_TYPE(fp->ctf_dtnextid, 1) > CTF_MAX_TYPE) in ctf_add_generic()
956 return (ctf_set_errno(fp, ECTF_FULL)); in ctf_add_generic()
959 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_generic()
963 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_generic()
966 type = fp->ctf_dtnextid++; in ctf_add_generic()
967 type = CTF_INDEX_TO_TYPE(type, (fp->ctf_flags & LCTF_CHILD)); in ctf_add_generic()
974 fp->ctf_dtstrlen += strlen(s) + 1; in ctf_add_generic()
976 ctf_dtd_insert(fp, dtd); in ctf_add_generic()
977 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_generic()
984 ctf_add_encoded(ctf_file_t *fp, uint_t flag, in ctf_add_encoded() argument
991 return (ctf_set_errno(fp, EINVAL)); in ctf_add_encoded()
993 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR) in ctf_add_encoded()
1011 ctf_add_reftype(ctf_file_t *fp, uint_t flag, in ctf_add_reftype() argument
1018 return (ctf_set_errno(fp, EINVAL)); in ctf_add_reftype()
1020 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR) in ctf_add_reftype()
1023 ctf_ref_inc(fp, ref); in ctf_add_reftype()
1032 ctf_add_integer(ctf_file_t *fp, uint_t flag, in ctf_add_integer() argument
1035 return (ctf_add_encoded(fp, flag, name, ep, CTF_K_INTEGER)); in ctf_add_integer()
1039 ctf_add_float(ctf_file_t *fp, uint_t flag, in ctf_add_float() argument
1042 return (ctf_add_encoded(fp, flag, name, ep, CTF_K_FLOAT)); in ctf_add_float()
1046 ctf_add_pointer(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref) in ctf_add_pointer() argument
1048 return (ctf_add_reftype(fp, flag, name, ref, CTF_K_POINTER)); in ctf_add_pointer()
1052 ctf_add_array(ctf_file_t *fp, uint_t flag, const ctf_arinfo_t *arp) in ctf_add_array() argument
1059 return (ctf_set_errno(fp, EINVAL)); in ctf_add_array()
1061 fpd = fp; in ctf_add_array()
1063 ctf_dtd_lookup(fp, arp->ctr_contents) == NULL) { in ctf_add_array()
1066 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_array()
1069 fpd = fp; in ctf_add_array()
1071 ctf_dtd_lookup(fp, arp->ctr_index) == NULL) { in ctf_add_array()
1073 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_array()
1076 if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR) in ctf_add_array()
1082 ctf_ref_inc(fp, arp->ctr_contents); in ctf_add_array()
1083 ctf_ref_inc(fp, arp->ctr_index); in ctf_add_array()
1089 ctf_set_array(ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp) in ctf_set_array() argument
1092 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, type); in ctf_set_array()
1094 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_set_array()
1095 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_set_array()
1098 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_set_array()
1100 fpd = fp; in ctf_set_array()
1102 ctf_dtd_lookup(fp, arp->ctr_contents) == NULL) in ctf_set_array()
1103 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_set_array()
1105 fpd = fp; in ctf_set_array()
1107 ctf_dtd_lookup(fp, arp->ctr_index) == NULL) in ctf_set_array()
1108 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_set_array()
1110 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_contents); in ctf_set_array()
1111 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_index); in ctf_set_array()
1112 fp->ctf_flags |= LCTF_DIRTY; in ctf_set_array()
1114 ctf_ref_inc(fp, arp->ctr_contents); in ctf_set_array()
1115 ctf_ref_inc(fp, arp->ctr_index); in ctf_set_array()
1121 ctf_add_funcptr(ctf_file_t *fp, uint_t flag, in ctf_add_funcptr() argument
1133 return (ctf_set_errno(fp, EINVAL)); in ctf_add_funcptr()
1140 return (ctf_set_errno(fp, EOVERFLOW)); in ctf_add_funcptr()
1142 fpd = fp; in ctf_add_funcptr()
1144 ctf_dtd_lookup(fp, ctc->ctc_return) == NULL) in ctf_add_funcptr()
1145 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_funcptr()
1148 fpd = fp; in ctf_add_funcptr()
1150 ctf_dtd_lookup(fp, argv[i]) == NULL) in ctf_add_funcptr()
1151 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_funcptr()
1155 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_funcptr()
1157 if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR) { in ctf_add_funcptr()
1165 ctf_ref_inc(fp, ctc->ctc_return); in ctf_add_funcptr()
1167 ctf_ref_inc(fp, argv[i]); in ctf_add_funcptr()
1178 ctf_add_struct(ctf_file_t *fp, uint_t flag, const char *name) in ctf_add_struct() argument
1180 ctf_hash_t *hp = &fp->ctf_structs; in ctf_add_struct()
1186 hep = ctf_hash_lookup(hp, fp, name, strlen(name)); in ctf_add_struct()
1188 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD) { in ctf_add_struct()
1190 dtd = ctf_dtd_lookup(fp, type); in ctf_add_struct()
1196 type = ctf_add_generic(fp, flag, name, &dtd); in ctf_add_struct()
1208 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_struct()
1214 ctf_add_union(ctf_file_t *fp, uint_t flag, const char *name) in ctf_add_union() argument
1216 ctf_hash_t *hp = &fp->ctf_unions; in ctf_add_union()
1222 hep = ctf_hash_lookup(hp, fp, name, strlen(name)); in ctf_add_union()
1224 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD) { in ctf_add_union()
1226 dtd = ctf_dtd_lookup(fp, type); in ctf_add_union()
1232 type = ctf_add_generic(fp, flag, name, &dtd); in ctf_add_union()
1244 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_union()
1250 ctf_add_enum(ctf_file_t *fp, uint_t flag, const char *name) in ctf_add_enum() argument
1252 ctf_hash_t *hp = &fp->ctf_enums; in ctf_add_enum()
1258 hep = ctf_hash_lookup(hp, fp, name, strlen(name)); in ctf_add_enum()
1260 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD) { in ctf_add_enum()
1262 dtd = ctf_dtd_lookup(fp, type); in ctf_add_enum()
1268 type = ctf_add_generic(fp, flag, name, &dtd); in ctf_add_enum()
1275 dtd->dtd_data.ctt_size = fp->ctf_dmodel->ctd_int; in ctf_add_enum()
1280 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_enum()
1286 ctf_add_forward(ctf_file_t *fp, uint_t flag, const char *name, uint_t kind) in ctf_add_forward() argument
1295 hp = &fp->ctf_structs; in ctf_add_forward()
1298 hp = &fp->ctf_unions; in ctf_add_forward()
1301 hp = &fp->ctf_enums; in ctf_add_forward()
1304 return (ctf_set_errno(fp, ECTF_NOTSUE)); in ctf_add_forward()
1312 fp, name, strlen(name))) != NULL) in ctf_add_forward()
1315 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR) in ctf_add_forward()
1325 ctf_add_typedef(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref) in ctf_add_typedef() argument
1331 fpd = fp; in ctf_add_typedef()
1333 ctf_dtd_lookup(fp, ref) == NULL)) in ctf_add_typedef()
1334 return (ctf_set_errno(fp, EINVAL)); in ctf_add_typedef()
1336 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR) in ctf_add_typedef()
1341 ctf_ref_inc(fp, ref); in ctf_add_typedef()
1347 ctf_add_volatile(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref) in ctf_add_volatile() argument
1349 return (ctf_add_reftype(fp, flag, name, ref, CTF_K_VOLATILE)); in ctf_add_volatile()
1353 ctf_add_const(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref) in ctf_add_const() argument
1355 return (ctf_add_reftype(fp, flag, name, ref, CTF_K_CONST)); in ctf_add_const()
1359 ctf_add_restrict(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref) in ctf_add_restrict() argument
1361 return (ctf_add_reftype(fp, flag, name, ref, CTF_K_RESTRICT)); in ctf_add_restrict()
1365 ctf_add_enumerator(ctf_file_t *fp, ctf_id_t enid, const char *name, int value) in ctf_add_enumerator() argument
1367 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, enid); in ctf_add_enumerator()
1374 return (ctf_set_errno(fp, EINVAL)); in ctf_add_enumerator()
1376 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_enumerator()
1377 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_enumerator()
1380 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_enumerator()
1387 return (ctf_set_errno(fp, ECTF_NOTENUM)); in ctf_add_enumerator()
1390 return (ctf_set_errno(fp, ECTF_DTFULL)); in ctf_add_enumerator()
1396 return (ctf_set_errno(fp, ECTF_DUPMEMBER)); in ctf_add_enumerator()
1401 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_enumerator()
1405 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_enumerator()
1416 fp->ctf_dtstrlen += strlen(s) + 1; in ctf_add_enumerator()
1417 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_enumerator()
1423 ctf_add_member(ctf_file_t *fp, ctf_id_t souid, const char *name, ctf_id_t type, in ctf_add_member() argument
1426 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, souid); in ctf_add_member()
1435 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_member()
1436 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_member()
1439 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_add_member()
1446 return (ctf_set_errno(fp, ECTF_NOTSOU)); in ctf_add_member()
1449 return (ctf_set_errno(fp, ECTF_DTFULL)); in ctf_add_member()
1461 return (ctf_set_errno(fp, ECTF_DUPMEMBER)); in ctf_add_member()
1466 if ((msize = ctf_type_size(fp, type)) == CTF_ERR || in ctf_add_member()
1467 (malign = ctf_type_align(fp, type)) == CTF_ERR || in ctf_add_member()
1468 (mkind = ctf_type_kind(fp, type)) == CTF_ERR) in ctf_add_member()
1480 if (ctf_type_encoding(fp, type, &e) == CTF_ERR) in ctf_add_member()
1496 return (ctf_set_errno(fp, EINVAL)); in ctf_add_member()
1504 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_member()
1508 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_member()
1517 ctf_id_t ltype = ctf_type_resolve(fp, lmd->dmd_type); in ctf_add_member()
1525 if (ctf_type_encoding(fp, ltype, &linfo) != CTF_ERR) in ctf_add_member()
1527 else if ((lsize = ctf_type_size(fp, ltype)) != CTF_ERR) in ctf_add_member()
1550 ssize = ctf_get_ctt_size(fp, &dtd->dtd_data, NULL, NULL); in ctf_add_member()
1565 fp->ctf_dtstrlen += strlen(s) + 1; in ctf_add_member()
1567 ctf_ref_inc(fp, type); in ctf_add_member()
1568 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_member()
1581 ctf_delete_type(ctf_file_t *fp, ctf_id_t type) in ctf_delete_type() argument
1584 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, type); in ctf_delete_type()
1586 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_delete_type()
1587 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_delete_type()
1594 fpd = fp; in ctf_delete_type()
1596 ctf_dtd_lookup(fp, type) == NULL) in ctf_delete_type()
1600 return (ctf_set_errno(fp, ECTF_NOTDYN)); in ctf_delete_type()
1602 if (dtd->dtd_ref != 0 || fp->ctf_refcnt > 1) in ctf_delete_type()
1603 return (ctf_set_errno(fp, ECTF_REFERENCED)); in ctf_delete_type()
1605 ctf_dtd_delete(fp, dtd); in ctf_delete_type()
1606 fp->ctf_flags |= LCTF_DIRTY; in ctf_delete_type()
1975 ctf_add_function(ctf_file_t *fp, ulong_t idx, const ctf_funcinfo_t *fip, in ctf_add_function() argument
1981 uintptr_t symbase = (uintptr_t)fp->ctf_symtab.cts_data; in ctf_add_function()
1983 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_function()
1984 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_function()
1986 if (ctf_dsd_lookup(fp, idx) != NULL) in ctf_add_function()
1987 return (ctf_set_errno(fp, ECTF_CONFLICT)); in ctf_add_function()
1990 return (ctf_set_errno(fp, ECTF_STRTAB)); in ctf_add_function()
1992 if (idx > fp->ctf_nsyms) in ctf_add_function()
1993 return (ctf_set_errno(fp, ECTF_NOTDATA)); in ctf_add_function()
1995 if (fp->ctf_symtab.cts_entsize == sizeof (Elf32_Sym)) { in ctf_add_function()
1998 return (ctf_set_errno(fp, ECTF_NOTFUNC)); in ctf_add_function()
2002 return (ctf_set_errno(fp, ECTF_NOTFUNC)); in ctf_add_function()
2005 afp = fp; in ctf_add_function()
2010 afp = fp; in ctf_add_function()
2017 return (ctf_set_errno(fp, ENOMEM)); in ctf_add_function()
2025 return (ctf_set_errno(fp, ENOMEM)); in ctf_add_function()
2034 ctf_dsd_insert(fp, dsd); in ctf_add_function()
2035 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_function()
2041 ctf_add_object(ctf_file_t *fp, ulong_t idx, ctf_id_t type) in ctf_add_object() argument
2045 uintptr_t symbase = (uintptr_t)fp->ctf_symtab.cts_data; in ctf_add_object()
2047 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_object()
2048 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_object()
2050 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_object()
2051 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_object()
2053 if (ctf_dsd_lookup(fp, idx) != NULL) in ctf_add_object()
2054 return (ctf_set_errno(fp, ECTF_CONFLICT)); in ctf_add_object()
2057 return (ctf_set_errno(fp, ECTF_STRTAB)); in ctf_add_object()
2059 if (idx > fp->ctf_nsyms) in ctf_add_object()
2060 return (ctf_set_errno(fp, ECTF_NOTDATA)); in ctf_add_object()
2062 if (fp->ctf_symtab.cts_entsize == sizeof (Elf32_Sym)) { in ctf_add_object()
2065 return (ctf_set_errno(fp, ECTF_NOTDATA)); in ctf_add_object()
2069 return (ctf_set_errno(fp, ECTF_NOTDATA)); in ctf_add_object()
2072 afp = fp; in ctf_add_object()
2078 return (ctf_set_errno(fp, ENOMEM)); in ctf_add_object()
2083 ctf_dsd_insert(fp, dsd); in ctf_add_object()
2084 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_object()
2090 ctf_dataptr(ctf_file_t *fp, const void **addrp, size_t *sizep) in ctf_dataptr() argument
2093 *addrp = fp->ctf_base; in ctf_dataptr()
2095 *sizep = fp->ctf_size; in ctf_dataptr()
2099 ctf_add_label(ctf_file_t *fp, const char *name, ctf_id_t type, uint_t position) in ctf_add_label() argument
2105 return (ctf_set_errno(fp, EINVAL)); in ctf_add_label()
2107 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_add_label()
2108 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_add_label()
2110 fpd = fp; in ctf_add_label()
2114 if (type != 0 && (fp->ctf_flags & LCTF_CHILD) && in ctf_add_label()
2116 return (ctf_set_errno(fp, ECTF_NOPARENT)); in ctf_add_label()
2118 if (ctf_dld_lookup(fp, name) != NULL) in ctf_add_label()
2119 return (ctf_set_errno(fp, ECTF_LABELEXISTS)); in ctf_add_label()
2122 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_label()
2126 return (ctf_set_errno(fp, EAGAIN)); in ctf_add_label()
2130 fp->ctf_dtstrlen += strlen(name) + 1; in ctf_add_label()
2131 ctf_dld_insert(fp, dld, position); in ctf_add_label()
2132 fp->ctf_flags |= LCTF_DIRTY; in ctf_add_label()
2144 ctf_set_size(ctf_file_t *fp, ctf_id_t id, const ulong_t newsz) in ctf_set_size() argument
2146 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, id); in ctf_set_size()
2150 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_set_size()
2151 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_set_size()
2154 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_set_size()
2159 return (ctf_set_errno(fp, ECTF_NOTSOU)); in ctf_set_size()
2165 return (ctf_set_errno(fp, EINVAL)); in ctf_set_size()
2175 fp->ctf_flags |= LCTF_DIRTY; in ctf_set_size()
2180 ctf_set_root(ctf_file_t *fp, ctf_id_t id, const boolean_t vis) in ctf_set_root() argument
2182 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, id); in ctf_set_root()
2185 if (!(fp->ctf_flags & LCTF_RDWR)) in ctf_set_root()
2186 return (ctf_set_errno(fp, ECTF_RDONLY)); in ctf_set_root()
2189 return (ctf_set_errno(fp, ECTF_BADID)); in ctf_set_root()