From: Nick Alcock Date: Fri, 25 Apr 2025 10:54:28 +0000 (+0100) Subject: libctf: lookup, open: chase header field changes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c5eb5b20adb555e0fd0f42cf8349a70d8fb4fe9;p=thirdparty%2Fbinutils-gdb.git 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. --- diff --git a/include/ctf-api.h b/include/ctf-api.h index 27bd4731524..5883c5321df 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -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). */ diff --git a/libctf/ctf-lookup.c b/libctf/ctf-lookup.c index 64b19e02571..fa3acc25df8 100644 --- a/libctf/ctf-lookup.c +++ b/libctf/ctf-lookup.c @@ -671,7 +671,7 @@ sort_symidx_by_name (const void *one_, const void *two_, void *arg_) static uint32_t * ctf_symidx_sort (ctf_dict_t *fp, uint32_t *idx, size_t *nidx, - size_t len) + size_t len) { uint32_t *sorted; size_t i; @@ -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; diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c index 32f1414d91c..4dfa57807cb 100644 --- a/libctf/ctf-open.c +++ b/libctf/ctf-open.c @@ -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)); }