From 5f54462c6ab4665adec1f3e4591c095d63eae06a Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Fri, 5 Jun 2020 17:36:16 +0100 Subject: 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. : Split into... : ... this... : ... 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. --- include/ChangeLog | 4 ++++ include/ctf-api.h | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ChangeLog b/include/ChangeLog index 6358ec6..60d7b9f 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,5 +1,9 @@ 2020-07-22 Nick Alcock + * ctf-api.h (CTF_LINK_EMPTY_CU_MAPPINGS): New. + +2020-07-22 Nick Alcock + * ctf-api.h (ECTF_NEEDSBFD): New. (ECTF_NERR): Adjust. (ctf_link): Rename share_mode arg to flags. diff --git a/include/ctf-api.h b/include/ctf-api.h index 7d3e1c8..700a2b1 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -78,7 +78,7 @@ typedef struct ctf_link_sym uint32_t st_value; } ctf_link_sym_t; -/* Indication of how to share types when linking. */ +/* Flags applying to this specific link. */ /* Share all types that are not in conflict. The default. */ #define CTF_LINK_SHARE_UNCONFLICTED 0x0 @@ -86,6 +86,10 @@ typedef struct ctf_link_sym /* Share only types that are used by multiple inputs. Not implemented yet. */ #define CTF_LINK_SHARE_DUPLICATED 0x1 +/* Create empty outputs for all registered CU mappings even if no types are + emitted into them. */ +#define CTF_LINK_EMPTY_CU_MAPPINGS 0x4 + /* Symbolic names for CTF sections. */ typedef enum ctf_sect_names -- cgit v1.1