libctf: lookup, open: chase header field changes

Nothing exciting here, just header fields slightly changing name
and a couple of new comments and indentation fixes.
This commit is contained in:
Nick Alcock
2025-04-25 11:54:28 +01:00
parent f7f72bcca6
commit 3c5eb5b20a
3 changed files with 21 additions and 20 deletions

View File

@@ -620,6 +620,9 @@ extern ctf_id_t ctf_lookup_by_kind (ctf_dict_t *, int kind, const char *);
typedef of a type with a *different width* (because this slice has not been
applied to it).
May error with ECTF_NONREPRESENTABLE if type 0 is seen (rare, but can happen:
not only types GCC cannot encode, but also e.g. const void variables).
Most of the time you don't need to call this: the type-querying functions
will do it for you (as noted below). */

View File

@@ -1013,7 +1013,7 @@ ctf_symbol_next_static (ctf_dict_t *fp, ctf_next_t **it, const char **name,
if (fp != i->cu.ctn_fp)
return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFP));
/* TODO-v4: Indexed after non-indexed portions? */
/* TODO: Indexed after non-indexed portions? */
if ((!functions && fp->ctf_objtidx_names) ||
(functions && fp->ctf_funcidx_names))
@@ -1025,13 +1025,13 @@ ctf_symbol_next_static (ctf_dict_t *fp, ctf_next_t **it, const char **name,
if (functions)
{
len = (hp->cth_varoff - hp->cth_funcidxoff) / sizeof (uint32_t);
tab = (uint32_t *) (fp->ctf_buf + hp->cth_funcoff);
len = hp->cth_funcidx_len / sizeof (uint32_t);
tab = (uint32_t *) (fp->ctf_buf + hp->cth_func_off);
}
else
{
len = (hp->cth_funcidxoff - hp->cth_objtidxoff) / sizeof (uint32_t);
tab = (uint32_t *) (fp->ctf_buf + hp->cth_objtoff);
len = hp->cth_objtidx_len / sizeof (uint32_t);
tab = (uint32_t *) (fp->ctf_buf + hp->cth_objt_off);
}
do
@@ -1064,14 +1064,14 @@ ctf_symbol_next_static (ctf_dict_t *fp, ctf_next_t **it, const char **name,
if (functions)
{
if (fp->ctf_sxlate[n] >= hp->cth_funcoff
&& fp->ctf_sxlate[n] < hp->cth_objtidxoff)
if (fp->ctf_sxlate[n] >= hp->cth_func_off
&& fp->ctf_sxlate[n] < hp->cth_func_off + hp->cth_func_len)
break;
}
else
{
if (fp->ctf_sxlate[n] >= hp->cth_objtoff
&& fp->ctf_sxlate[n] < hp->cth_funcoff)
if (fp->ctf_sxlate[n] >= hp->cth_objt_off
&& fp->ctf_sxlate[n] < hp->cth_objt_off + hp->cth_objt_len)
break;
}
}
@@ -1138,16 +1138,15 @@ ctf_try_lookup_indexed (ctf_dict_t *fp, unsigned long symidx,
{
if ((fp->ctf_funcidx_sxlate
= ctf_symidx_sort (fp, (uint32_t *)
(fp->ctf_buf + hp->cth_funcidxoff),
&fp->ctf_nfuncidx,
hp->cth_varoff - hp->cth_funcidxoff))
(fp->ctf_buf + hp->cth_funcidx_off),
&fp->ctf_nfuncidx, hp->cth_funcidx_len))
== NULL)
{
ctf_err_warn (fp, 0, 0, _("cannot sort function symidx"));
return CTF_ERR; /* errno is set for us. */
}
}
symtypetab = (uint32_t *) (fp->ctf_buf + hp->cth_funcoff);
symtypetab = (uint32_t *) (fp->ctf_buf + hp->cth_func_off);
sxlate = fp->ctf_funcidx_sxlate;
names = fp->ctf_funcidx_names;
nidx = fp->ctf_nfuncidx;
@@ -1158,9 +1157,8 @@ ctf_try_lookup_indexed (ctf_dict_t *fp, unsigned long symidx,
{
if ((fp->ctf_objtidx_sxlate
= ctf_symidx_sort (fp, (uint32_t *)
(fp->ctf_buf + hp->cth_objtidxoff),
&fp->ctf_nobjtidx,
hp->cth_funcidxoff - hp->cth_objtidxoff))
(fp->ctf_buf + hp->cth_objtidx_off),
&fp->ctf_nobjtidx, hp->cth_objtidx_len))
== NULL)
{
ctf_err_warn (fp, 0, 0, _("cannot sort object symidx"));
@@ -1168,7 +1166,7 @@ ctf_try_lookup_indexed (ctf_dict_t *fp, unsigned long symidx,
}
}
symtypetab = (uint32_t *) (fp->ctf_buf + hp->cth_objtoff);
symtypetab = (uint32_t *) (fp->ctf_buf + hp->cth_objt_off);
sxlate = fp->ctf_objtidx_sxlate;
names = fp->ctf_objtidx_names;
nidx = fp->ctf_nobjtidx;

View File

@@ -2629,11 +2629,11 @@ ctf_import_internal (ctf_dict_t *fp, ctf_dict_t *pfp, int unreffed)
return (ctf_set_errno (fp, ECTF_HASPARENT));
if (fp->ctf_header->cth_parent_strlen != 0 &&
pfp->ctf_header->cth_strlen != fp->ctf_header->cth_parent_strlen)
pfp->ctf_header->btf.bth_str_len != fp->ctf_header->cth_parent_strlen)
{
ctf_err_warn (fp, 0, ECTF_WRONGPARENT,
_("ctf_import: incorrect parent dict: %u bytes of strings expected, %u found"),
fp->ctf_header->cth_parent_strlen, pfp->ctf_header->cth_strlen);
fp->ctf_header->cth_parent_strlen, pfp->ctf_header->btf.bth_str_len);
return (ctf_set_errno (fp, ECTF_WRONGPARENT));
}