diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2020-06-05 18:35:46 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2020-07-22 18:02:19 +0100 |
commit | 0f0c11f7fc9f0ab6bd63fc5f8a4cee7367a81849 (patch) | |
tree | eff35c0824fa60651cd492f8fa63316da9a205da /libctf/ctf-create.c | |
parent | a9b9870206658564272fe17d2079ed9eb6ffb15f (diff) | |
download | binutils-0f0c11f7fc9f0ab6bd63fc5f8a4cee7367a81849.zip binutils-0f0c11f7fc9f0ab6bd63fc5f8a4cee7367a81849.tar.gz binutils-0f0c11f7fc9f0ab6bd63fc5f8a4cee7367a81849.tar.bz2 |
libctf, dedup: add deduplicator
This adds the core deduplicator that the ctf_link machinery calls
(possibly repeatedly) to link the CTF sections: it takes an array
of input ctf_file_t's and another array that indicates which entries in
the input array are parents of which other entries, and returns an array
of outputs. The first output is always the ctf_file_t on which
ctf_link/ctf_dedup/etc was called: the other outputs are child dicts
that have the first output as their parent.
include/
* ctf-api.h (CTF_LINK_SHARE_DUPLICATED): No longer unimplemented.
libctf/
* ctf-impl.h (ctf_type_id_key): New, the key in the
cd_id_to_file_t.
(ctf_dedup): New, core deduplicator state.
(ctf_file_t) <ctf_dedup>: New.
<ctf_dedup_atoms>: New.
<ctf_dedup_atoms_alloc>: New.
(ctf_hash_type_id_key): New prototype.
(ctf_hash_eq_type_id_key): Likewise.
(ctf_dedup_atoms_init): Likewise.
* ctf-hash.c (ctf_hash_eq_type_id_key): New.
(ctf_dedup_atoms_init): Likewise.
* ctf-create.c (ctf_serialize): Adjusted.
(ctf_add_encoded): No longer static.
(ctf_add_reftype): Likewise.
* ctf-open.c (ctf_file_close): Destroy the
ctf_dedup_atoms_alloc.
* ctf-dedup.c: New file.
* ctf-decls.h [!HAVE_DECL_STPCPY]: Add prototype.
* configure.ac: Check for stpcpy.
* Makefile.am: Add it.
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
Diffstat (limited to 'libctf/ctf-create.c')
-rw-r--r-- | libctf/ctf-create.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index 001e625..35c286c 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -546,6 +546,9 @@ ctf_serialize (ctf_file_t *fp) nfp->ctf_link_variable_filter = fp->ctf_link_variable_filter; nfp->ctf_link_variable_filter_arg = fp->ctf_link_variable_filter_arg; nfp->ctf_link_flags = fp->ctf_link_flags; + nfp->ctf_dedup_atoms = fp->ctf_dedup_atoms; + nfp->ctf_dedup_atoms_alloc = fp->ctf_dedup_atoms_alloc; + memcpy (&nfp->ctf_dedup, &fp->ctf_dedup, sizeof (fp->ctf_dedup)); nfp->ctf_snapshot_lu = fp->ctf_snapshots; @@ -571,11 +574,14 @@ ctf_serialize (ctf_file_t *fp) fp->ctf_link_in_cu_mapping = NULL; fp->ctf_link_out_cu_mapping = NULL; fp->ctf_link_type_mapping = NULL; + fp->ctf_dedup_atoms = NULL; + fp->ctf_dedup_atoms_alloc = NULL; fp->ctf_parent_unreffed = 1; fp->ctf_dvhash = NULL; memset (&fp->ctf_dvdefs, 0, sizeof (ctf_list_t)); memset (fp->ctf_lookups, 0, sizeof (fp->ctf_lookups)); + memset (&fp->ctf_dedup, 0, sizeof (fp->ctf_dedup)); fp->ctf_structs.ctn_writable = NULL; fp->ctf_unions.ctn_writable = NULL; fp->ctf_enums.ctn_writable = NULL; @@ -878,7 +884,7 @@ clp2 (size_t x) return (x + 1); } -static ctf_id_t +ctf_id_t ctf_add_encoded (ctf_file_t *fp, uint32_t flag, const char *name, const ctf_encoding_t *ep, uint32_t kind) { @@ -899,7 +905,7 @@ ctf_add_encoded (ctf_file_t *fp, uint32_t flag, return type; } -static ctf_id_t +ctf_id_t ctf_add_reftype (ctf_file_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind) { ctf_dtdef_t *dtd; |