libctf: link: BTF support

This is in two parts, one new API function and one change.

New API:
+int ctf_link_output_is_btf (ctf_dict_t *);

Changed API:
unsigned char *ctf_link_write (ctf_dict_t *, size_t *size,
-			      size_t threshold);
+			      size_t threshold, int *is_btf);

The idea here is that callers can call ctf_link_output_is_btf on a
ctf_link()ed (deduplicated) dict to tell whether a link will yield
BTF-compatible output before actually generating that output, so
they can e.g. decide whether to avoid trying to compress the dict
if they know it would be BTF otherwise (since compressing a dict
renders it non-BTF-compatible).

ctf_link_write() gains an optional is_btf output parameter that
reports whether the dict that was finally generated is actually BTF
after all, perhaps because the caller didn't call
ctf_link_output_is_btf or wants to be robust against possible future
changes that may add other reasons why a written-out dict can't be BTF
at the last minute.

These are simple wrappers around already-existing machinery earlier in
this series.
This commit is contained in:
Nick Alcock
2025-04-25 18:22:07 +01:00
parent 343de78445
commit 9ea8bea7f0
4 changed files with 67 additions and 11 deletions

View File

@@ -201,6 +201,7 @@ LIBCTF_2.0 {
ctf_link;
ctf_link_add_strtab;
ctf_link_shuffle_syms;
ctf_link_output_is_btf;
ctf_link_write;
ctf_link_add_linker_symbol;