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:
@@ -756,6 +756,39 @@ symerr:
|
||||
|
||||
/* 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user