]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Document and handle DW_FORM_indirect in __libdw_form_val_compute_len
authorMark Wielaard <mark@klomp.org>
Sat, 1 May 2021 16:00:49 +0000 (18:00 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 6 May 2021 21:16:10 +0000 (23:16 +0200)
Update the documentation in __libdw_form_val_compute_len for handling
DW_FORM_indirect and make sure the indirect form isn't DW_FORM_indirect
itself or DW_FORM_implicit_const.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/libdw_form.c

index e3e467eec7e7ab2bccc4438c34a5a33aa311ecae..aa3e5ee29dca6bf2318275bc846e3dd4b90925b0 100644 (file)
@@ -1,3 +1,8 @@
+2021-05-01  Mark Wielaard  <mark@klomp.org>
+
+       * libdw_form.c (__libdw_form_val_compute_len): Check indirect
+       form is not DW_FORM_indirect or DW_FORM_implicit_const.
+
 2021-04-23  Omar Sandoval  <osandov@fb.com>
 
        * dwarf_child.c (__libdw_find_attr): Handle DW_FORM_indirect.
index 584c8467129d098b199c7c5a04ba74c494742a9e..c83dfb397f5c3780041ac4ff68cd6d660b1a3fdf 100644 (file)
@@ -116,8 +116,12 @@ __libdw_form_val_compute_len (struct Dwarf_CU *cu, unsigned int form,
       break;
 
     case DW_FORM_indirect:
+      /* The amount of data to skip in the DIE is the size of the actual
+        FORM data (which is __libdw_form_val_len) plus the size of the
+        uleb128 encoding that FORM (which is valp - startp).  */
       get_uleb128 (u128, valp, endp);
-      // XXX Is this really correct?
+      if (*valp == DW_FORM_indirect || *valp == DW_FORM_implicit_const)
+       return (size_t) -1;
       result = __libdw_form_val_len (cu, u128, valp);
       if (result != (size_t) -1)
        result += valp - startp;