mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
libctf: map from old to corresponding newly-added types in ctf_add_type
This lets you call ctf_type_mapping (dest_fp, src_fp, src_type_id)
and get told what type ID the corresponding type has in the target
ctf_file_t. This works even if it was added by a recursive call, and
because it is stored in the target ctf_file_t it works even if we
had to add one type to multiple ctf_file_t's as part of conflicting
type handling.
We empty out this mapping after every archive is linked: because it maps
input to output fps, and we only visit each input fp once, its contents
are rendered entirely useless every time the source fp changes.
v3: add several missing mapping additions. Add ctf_dynhash_empty, and
empty after every input archive.
v5: fix tabdamage.
libctf/
* ctf-impl.h (ctf_file_t): New field ctf_link_type_mapping.
(struct ctf_link_type_mapping_key): New.
(ctf_hash_type_mapping_key): Likewise.
(ctf_hash_eq_type_mapping_key): Likewise.
(ctf_add_type_mapping): Likewise.
(ctf_type_mapping): Likewise.
(ctf_dynhash_empty): Likewise.
* ctf-open.c (ctf_file_close): Update accordingly.
* ctf-create.c (ctf_update): Likewise.
(ctf_add_type): Populate the mapping.
* ctf-hash.c (ctf_hash_type_mapping_key): Hash a type mapping key.
(ctf_hash_eq_type_mapping_key): Check the key for equality.
(ctf_dynhash_insert): Fix comment typo.
(ctf_dynhash_empty): New.
* ctf-link.c (ctf_add_type_mapping): New.
(ctf_type_mapping): Likewise.
(empty_link_type_mapping): New.
(ctf_link_one_input_archive): Call it.
This commit is contained in:
@@ -473,6 +473,7 @@ ctf_update (ctf_file_t *fp)
|
||||
nfp->ctf_link_inputs = fp->ctf_link_inputs;
|
||||
nfp->ctf_link_outputs = fp->ctf_link_outputs;
|
||||
nfp->ctf_syn_ext_strtab = fp->ctf_syn_ext_strtab;
|
||||
nfp->ctf_link_type_mapping = fp->ctf_link_type_mapping;
|
||||
|
||||
nfp->ctf_snapshot_lu = fp->ctf_snapshots;
|
||||
|
||||
@@ -485,6 +486,7 @@ ctf_update (ctf_file_t *fp)
|
||||
fp->ctf_link_inputs = NULL;
|
||||
fp->ctf_link_outputs = NULL;
|
||||
fp->ctf_syn_ext_strtab = NULL;
|
||||
fp->ctf_link_type_mapping = NULL;
|
||||
|
||||
fp->ctf_dvhash = NULL;
|
||||
memset (&fp->ctf_dvdefs, 0, sizeof (ctf_list_t));
|
||||
@@ -1557,6 +1559,7 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
ctf_funcinfo_t ctc;
|
||||
|
||||
ctf_hash_t *hp;
|
||||
ctf_id_t orig_src_type = src_type;
|
||||
|
||||
if (!(dst_fp->ctf_flags & LCTF_RDWR))
|
||||
return (ctf_set_errno (dst_fp, ECTF_RDONLY));
|
||||
@@ -1640,7 +1643,10 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
if (memcmp (&src_en, &dst_en, sizeof (ctf_encoding_t)) == 0)
|
||||
{
|
||||
if (kind != CTF_K_SLICE)
|
||||
return dst_type;
|
||||
{
|
||||
ctf_add_type_mapping (src_fp, src_type, dst_fp, dst_type);
|
||||
return dst_type;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1679,7 +1685,10 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
int match; /* Do the encodings match? */
|
||||
|
||||
if (kind != CTF_K_INTEGER && kind != CTF_K_FLOAT && kind != CTF_K_SLICE)
|
||||
return dtd->dtd_type;
|
||||
{
|
||||
ctf_add_type_mapping (src_fp, src_type, dst_fp, dtd->dtd_type);
|
||||
return dtd->dtd_type;
|
||||
}
|
||||
|
||||
sroot = (flag & CTF_ADD_ROOT);
|
||||
droot = (LCTF_INFO_ISROOT (dst_fp,
|
||||
@@ -1698,7 +1707,10 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
if (match && sroot == droot)
|
||||
{
|
||||
if (kind != CTF_K_SLICE)
|
||||
return dtd->dtd_type;
|
||||
{
|
||||
ctf_add_type_mapping (src_fp, src_type, dst_fp, dtd->dtd_type);
|
||||
return dtd->dtd_type;
|
||||
}
|
||||
}
|
||||
else if (!match && sroot && droot)
|
||||
{
|
||||
@@ -1939,6 +1951,8 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
return (ctf_set_errno (dst_fp, ECTF_CORRUPT));
|
||||
}
|
||||
|
||||
if (dst_type != CTF_ERR)
|
||||
ctf_add_type_mapping (src_fp, orig_src_type, dst_fp, dst_type);
|
||||
return dst_type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user