]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: lookup, open: chase header field changes
authorNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 10:54:28 +0000 (11:54 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 17:07:43 +0000 (18:07 +0100)
Nothing exciting here, just header fields slightly changing name
and a couple of new comments and indentation fixes.

include/ctf-api.h
libctf/ctf-lookup.c
libctf/ctf-open.c

index 27bd4731524d93b78913c8ef286d46db836d8e1d..5883c5321df48ec14182335101e377929838e38e 100644 (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).  */
 
index 64b19e0257185b981e7fc8f5aeccae1060a12b39..fa3acc25df81744c8bc9fdb893a21137fce502fb 100644 (file)
@@ -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;
index 32f1414d91c6a279f86d64f8905bec88a4061aa2..4dfa57807cbf0ba0ce52a869582dc57fbf8bdb5c 100644 (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));
     }