aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-impl.h
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-05 17:36:16 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 18:02:18 +0100
commit5f54462c6ab4665adec1f3e4591c095d63eae06a (patch)
tree7b65fc8d4f34b3b13fe5657085abd7b6f0fbdd1c /libctf/ctf-impl.h
parente3f17159e26fc9b10625725e4d544693741cddb8 (diff)
downloadbinutils-5f54462c6ab4665adec1f3e4591c095d63eae06a.zip
binutils-5f54462c6ab4665adec1f3e4591c095d63eae06a.tar.gz
binutils-5f54462c6ab4665adec1f3e4591c095d63eae06a.tar.bz2
libctf, link: redo cu-mapping handling
Now a bunch of stuff that doesn't apply to ld or any normal use of libctf, piled into one commit so that it's easier to ignore. The cu-mapping machinery associates incoming compilation unit names with outgoing names of CTF dictionaries that should correspond to them, for non-gdb CTF consumers that would like to group multiple TUs into a single child dict if conflicting types are found in it (the existing use case is one kernel module, one child CTF dict, even if the kernel module is composed of multiple CUs). The upcoming deduplicator needs to track not only the mapping from incoming CU name to outgoing dict name, but the inverse mapping from outgoing dict name to incoming CU name, so it can work over every CTF dict we might see in the output and link into it. So rejig the ctf-link machinery to do that. Simultaneously (because they are closely associated and were written at the same time), we add a new CTF_LINK_EMPTY_CU_MAPPINGS flag to ctf_link, which tells the ctf_link machinery to create empty child dicts for each outgoing CU mapping even if no CUs that correspond to it exist in the link. This is a bit (OK, quite a lot) of a waste of space, but some existing consumers require it. (Nobody else should use it.) Its value is not consecutive with existing CTF_LINK flag values because we're about to add more flags that are conceptually closer to the existing ones than this one is. include/ * ctf-api.h (CTF_LINK_EMPTY_CU_MAPPINGS): New. libctf/ * ctf-impl.h (ctf_file_t): Improve comments. <ctf_link_cu_mapping>: Split into... <ctf_link_in_cu_mapping>: ... this... <ctf_link_out_cu_mapping>: ... and this. * ctf-create.c (ctf_serialize): Adjust. * ctf-open.c (ctf_file_close): Likewise. * ctf-link.c (ctf_create_per_cu): Look things up in the in_cu_mapping instead of the cu_mapping. (ctf_link_add_cu_mapping): The deduplicating link will define what happens if many FROMs share a TO. (ctf_link_add_cu_mapping): Create in_cu_mapping and out_cu_mapping. Do not create ctf_link_outputs here any more, or create per-CU dicts here: they are already created when needed. (ctf_link_one_variable): Log a debug message if we skip a variable due to its type being concealed in a CU-mapped link. (This is probably too common a case to make into a warning.) (ctf_link): Create empty per-CU dicts if requested.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r--libctf/ctf-impl.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index cb7de23..46bceb4 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -311,12 +311,27 @@ struct ctf_file
ctf_list_t ctf_errs_warnings; /* CTF errors and warnings. */
ctf_dynhash_t *ctf_link_inputs; /* Inputs to this link. */
ctf_dynhash_t *ctf_link_outputs; /* Additional outputs from this link. */
- ctf_dynhash_t *ctf_link_type_mapping; /* Map input types to output types. */
- ctf_dynhash_t *ctf_link_cu_mapping; /* Map CU names to CTF dict names. */
- /* Allow the caller to Change the name of link archive members. */
+
+ /* Map input types to output types: populated in each output dict.
+ Key is a ctf_link_type_key_t: value is a type ID. Used by
+ nondeduplicating links and ad-hoc ctf_add_type calls only. */
+ ctf_dynhash_t *ctf_link_type_mapping;
+
+ /* Map input CU names to output CTF dict names: populated in the top-level
+ output dict.
+
+ Key and value are dynamically-allocated strings. */
+ ctf_dynhash_t *ctf_link_in_cu_mapping;
+
+ /* Map output CTF dict names to input CU names: populated in the top-level
+ output dict. A hash of string to hash (set) of strings. Key and
+ individual value members are shared with ctf_link_in_cu_mapping. */
+ ctf_dynhash_t *ctf_link_out_cu_mapping;
+
/* CTF linker flags. */
int ctf_link_flags;
+ /* Allow the caller to change the name of link archive members. */
ctf_link_memb_name_changer_f *ctf_link_memb_name_changer;
void *ctf_link_memb_name_changer_arg; /* Argument for it. */
ctf_dynhash_t *ctf_add_processing; /* Types ctf_add_type is working on now. */