aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2025-04-25 11:40:13 +0100
committerNick Alcock <nick.alcock@oracle.com>2025-04-25 18:07:43 +0100
commitbd0c033b29a36a731e6af431e963a48c278f3bfd (patch)
treeaddda2773750444a700cbcf7c3d92c14a95debb1 /libctf
parent0cd5118024fa7847c6c37327e92df88ffc3b99aa (diff)
downloadbinutils-bd0c033b29a36a731e6af431e963a48c278f3bfd.zip
binutils-bd0c033b29a36a731e6af431e963a48c278f3bfd.tar.gz
binutils-bd0c033b29a36a731e6af431e963a48c278f3bfd.tar.bz2
libctf, create, types: slices
Nothing difficult for this CTF-specific type kind, just the usual adjustment to internal API changes.
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ctf-create.c15
-rw-r--r--libctf/ctf-types.c16
2 files changed, 10 insertions, 21 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index d081090..9d02bee 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -787,9 +787,7 @@ ctf_add_slice (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref,
ctf_dtdef_t *dtd;
ctf_slice_t slice;
ctf_id_t resolved_ref = ref;
- ctf_id_t type;
int kind;
- const ctf_type_t *tp;
ctf_dict_t *tmp = fp;
if (ep == NULL)
@@ -801,7 +799,7 @@ ctf_add_slice (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref,
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
return (ctf_set_typed_errno (fp, EINVAL));
- if (ref != 0 && ((tp = ctf_lookup_by_id (&tmp, ref)) == NULL))
+ if (ref != 0 && (ctf_lookup_by_id (&tmp, ref, NULL) == NULL))
return CTF_ERR; /* errno is set for us. */
/* Make sure we ultimately point to an integral type. We also allow slices to
@@ -817,21 +815,20 @@ ctf_add_slice (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref,
&& (ref != 0))
return (ctf_set_typed_errno (fp, ECTF_NOTINTFP));
- if ((type = ctf_add_generic (fp, flag, NULL, CTF_K_SLICE,
- sizeof (ctf_slice_t), &dtd)) == CTF_ERR)
+ if ((dtd = ctf_add_generic (fp, flag, NULL, CTF_K_SLICE, 0,
+ sizeof (ctf_slice_t), 0, NULL)) == NULL)
return CTF_ERR; /* errno is set for us. */
memset (&slice, 0, sizeof (ctf_slice_t));
- dtd->dtd_data.ctt_info = CTF_TYPE_INFO (CTF_K_SLICE, flag, 0);
- dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, CHAR_BIT)
- / CHAR_BIT);
+ dtd->dtd_data->ctt_info = CTF_TYPE_INFO (CTF_K_SLICE, 0, 0);
+ dtd->dtd_data->ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, CHAR_BIT) / CHAR_BIT);
slice.cts_type = (uint32_t) ref;
slice.cts_bits = ep->cte_bits;
slice.cts_offset = ep->cte_offset;
memcpy (dtd->dtd_vlen, &slice, sizeof (ctf_slice_t));
- return type;
+ return dtd->dtd_type;
}
ctf_id_t
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index 7423d0d..e108eda 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -1449,7 +1449,7 @@ ctf_type_align_natural (ctf_dict_t *fp, ctf_id_t prev_type,
/* Resolve the type down to a base type node, and then return the alignment
needed for the type storage in bytes.
- XXX may need arch-dependent attention. */
+ TODO may need arch-dependent attention. */
ssize_t
ctf_type_align (ctf_dict_t *fp, ctf_id_t type)
@@ -1702,19 +1702,11 @@ ctf_type_reference (ctf_dict_t *fp, ctf_id_t type)
/* Slices store their type in an unusual place. */
case CTF_K_SLICE:
{
- ctf_dtdef_t *dtd;
+ unsigned char *vlen;
const ctf_slice_t *sp;
- if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
- {
- ssize_t increment;
-
- (void) ctf_get_ctt_size (fp, tp, NULL, &increment);
- sp = (const ctf_slice_t *) ((uintptr_t) tp + increment);
- }
- else
- sp = (const ctf_slice_t *) dtd->dtd_vlen;
-
+ vlen = ctf_vlen (fp, type, tp, NULL);
+ sp = (const ctf_slice_t *) vlen;
return sp->cts_type;
}
default: