_CTF_ITEM (ECTF_NODATASEC, "Variable not found in datasec.") \
_CTF_ITEM (ECTF_NOTDECLTAG, "This function requires a decl tag.") \
_CTF_ITEM (ECTF_NOTTAG, "This function requires a type or decl tag.") \
+ _CTF_ITEM (ECTF_KIND_PROHIBITED, "Writeout of suppressed kind attempted.") \
+ _CTF_ITEM (ECTF_NOTBTF, "Cannot write out this dict as BTF.") \
_CTF_ITEM (ECTF_TOOLARGE, "Prefix required for correct representation.")
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
extern int ctf_arc_write_fd (int, ctf_dict_t **, size_t, const char **,
size_t);
+/* Prohibit writeout of this type kind: attempts to write it out cause
+ an ECTF_KIND_PROHIBITED error. */
+
+extern int ctf_write_suppress_kind (ctf_dict_t *fp, int kind, int prohibited);
+
/* Linking. These functions are used by ld to link .ctf sections in input
object files into a single .ctf section which is an archive possibly
containing members containing types whose names collide across multiple
const ctf_dictops_t *ctf_dictops; /* Version-specific dict operations. */
ctf_header_t *ctf_header; /* The header from this CTF dict. */
ctf_header_v3_t *ctf_v3_header; /* The header from an upgraded CTF dict. */
+ ctf_dynset_t *ctf_write_prohibitions; /* Kinds writeout causes error for. */
+ ctf_dynset_t *ctf_write_suppressions; /* Kinds that are skipped on write. */
unsigned char ctf_openflags; /* Flags the dict had when opened. */
int ctf_opened_btf; /* Whether this dict was pure BTF when
opened. */
/* Type section. */
+/* Kind suppression. */
+
+int
+ctf_write_suppress_kind (ctf_dict_t *fp, int kind, int prohibited)
+{
+ ctf_dynset_t *set;
+
+ if (kind < CTF_K_UNKNOWN || kind > CTF_K_MAX)
+ return (ctf_set_errno (fp, EINVAL));
+
+ if (prohibited)
+ set = fp->ctf_write_prohibitions;
+ else
+ set = fp->ctf_write_suppressions;
+
+ if (!set)
+ {
+ set = ctf_dynset_create (htab_hash_pointer, htab_eq_pointer, NULL);
+ if (!set)
+ return (ctf_set_errno (fp, errno));
+
+ if (prohibited)
+ fp->ctf_write_prohibitions = set;
+ else
+ fp->ctf_write_suppressions = set;
+ }
+
+ if ((ctf_dynset_cinsert (set, (const void *) (uintptr_t) kind)) < 0)
+ return (ctf_set_errno (fp, errno));
+
+ return 0;
+}
+
/* Iterate through the static types and the dynamic type definition list and
compute the size of the CTF type section.
ctf_write_mem;
ctf_gzwrite;
ctf_compress_write;
+ ctf_write_suppress_kind;
ctf_sect_size;
ctf_getdatasect;
ctf_getsymsect;