[libbacktrace] Handle DW_FORM_GNU_ref_alt
authorTom de Vries <tdevries@suse.de>
Thu, 17 Jan 2019 13:42:20 +0000 (13:42 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 17 Jan 2019 13:42:20 +0000 (13:42 +0000)
Handle DW_FORM_GNU_ref_alt which references the .debug_info section in the
.gnu_debugaltlink file.

2019-01-17  Tom de Vries  <tdevries@suse.de>

PR libbacktrace/82857
* dwarf.c (enum attr_val_encoding): Add ATTR_VAL_REF_ALT_INFO.
(read_attribute): Handle DW_FORM_GNU_ref_alt using
ATTR_VAL_REF_ALT_INFO.
(read_referenced_name_from_attr): Handle DW_FORM_GNU_ref_alt.

From-SVN: r268031

libbacktrace/ChangeLog
libbacktrace/dwarf.c

index 1fd307bf5128100e655dbfa155113483d8e7cfc5..191bfa3cac36ea83adbd84314798fd97774f98b7 100644 (file)
@@ -1,3 +1,11 @@
+2019-01-17  Tom de Vries  <tdevries@suse.de>
+
+       PR libbacktrace/82857
+       * dwarf.c (enum attr_val_encoding): Add ATTR_VAL_REF_ALT_INFO.
+       (read_attribute): Handle DW_FORM_GNU_ref_alt using
+       ATTR_VAL_REF_ALT_INFO.
+       (read_referenced_name_from_attr): Handle DW_FORM_GNU_ref_alt.
+
 2019-01-17  Tom de Vries  <tdevries@suse.de>
 
        * dwarf.c (struct unit): Add low_offset and high_offset fields.
index 6f56c46774b7ef3920eec89258cfbf4fe4bc56be..aacbd3a453d50518512423e19e43a63ec8c97556 100644 (file)
@@ -143,6 +143,8 @@ enum attr_val_encoding
   ATTR_VAL_REF_UNIT,
   /* An offset to other data within the .dwarf_info section.  */
   ATTR_VAL_REF_INFO,
+  /* An offset to other data within the alt .dwarf_info section.  */
+  ATTR_VAL_REF_ALT_INFO,
   /* An offset to data in some other section.  */
   ATTR_VAL_REF_SECTION,
   /* A type signature.  */
@@ -858,7 +860,7 @@ read_attribute (enum dwarf_form form, struct dwarf_buf *buf,
          val->encoding = ATTR_VAL_NONE;
          return 1;
        }
-      val->encoding = ATTR_VAL_REF_SECTION;
+      val->encoding = ATTR_VAL_REF_ALT_INFO;
       return 1;
     case DW_FORM_GNU_strp_alt:
       {
@@ -2200,6 +2202,19 @@ read_referenced_name_from_attr (struct dwarf_data *ddata, struct unit *u,
       || val->encoding == ATTR_VAL_REF_UNIT)
     return read_referenced_name (ddata, u, val->u.uint, error_callback, data);
 
+  if (val->encoding == ATTR_VAL_REF_ALT_INFO)
+    {
+      struct unit *alt_unit
+       = find_unit (ddata->altlink->units, ddata->altlink->units_count,
+                    val->u.uint);
+      if (alt_unit == NULL)
+       return NULL;
+
+      uint64_t offset = val->u.uint - alt_unit->low_offset;
+      return read_referenced_name (ddata->altlink, alt_unit, offset,
+                                  error_callback, data);
+    }
+
   return NULL;
 }