forked from Imagelibrary/binutils-gdb
libctf: serialize: kind suppression and prohibition
The CTF serialization machinery decides whether to write out a dict as BTF or CTF (or, in LIBCTF_BTM_BTF mode, whether to write out a dict or fail with ECTF_NOTBTF) in part by looking at the type kinds in the dictionary. It is possible that you'd like to extend this check and ban specific type kinds from the dictionary (possibly even if it's CTF); it's also possible that you'd like to *not* fail even if a CTF-only kind is found, but rather replace it with a still-valid stub (CTF_K_UNKNOWN / BTF_KIND_UNKNOWN) and keep going. (The kernel's btfarchive machinery does this to ensure that the compiler and previous link stages have emitted only valid BTF type kinds.) ctf_write_suppress_kind supports both these use cases: +int ctf_write_suppress_kind (ctf_dict_t *fp, int kind, int prohibited); This commit adds only the core population code: the actual suppression is spread across the serializer and will be added in the next commits.
This commit is contained in:
@@ -264,6 +264,8 @@ typedef struct ctf_snapshot_id
|
||||
_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. */
|
||||
@@ -1106,6 +1108,11 @@ extern int ctf_arc_write (const char *file, ctf_dict_t **ctf_dicts, size_t,
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user