[libbacktrace] Handle DW_FORM_GNU_strp_alt
authorTom de Vries <tdevries@suse.de>
Thu, 17 Jan 2019 00:08:05 +0000 (00:08 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 17 Jan 2019 00:08:05 +0000 (00:08 +0000)
Handle DW_FORM_GNU_strp_alt which references the .debug_str section in the
.gnu_debugaltlink file.

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

PR libbacktrace/82857
* dwarf.c (read_attribute): Handle DW_FORM_GNU_strp_alt
using altlink.

From-SVN: r267996

libbacktrace/ChangeLog
libbacktrace/dwarf.c

index fb8aebe95c1ae08d579a4476717a0ac62b04b826..458f16c98704a6d6ec8746e474dd5c4b7ee74751 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-17  Tom de Vries  <tdevries@suse.de>
+
+       PR libbacktrace/82857
+       * dwarf.c (read_attribute): Handle DW_FORM_GNU_strp_alt
+       using altlink.
+
 2019-01-17  Tom de Vries  <tdevries@suse.de>
 
        * dwarf.c (enum attr_val_encoding): Add ATTR_VAL_NONE.
index 4cae5b4f4a3e166e0bbb0a641fb47ed6d1156f0d..45691b4ba6987eddd597c94bb25070f7e561c0ef 100644 (file)
@@ -843,14 +843,23 @@ read_attribute (enum dwarf_form form, struct dwarf_buf *buf,
       val->encoding = ATTR_VAL_REF_SECTION;
       return 1;
     case DW_FORM_GNU_strp_alt:
-      val->u.uint = read_offset (buf, is_dwarf64);
-      if (altlink == NULL)
-       {
-         val->encoding = ATTR_VAL_NONE;
-         return 1;
-       }
-      val->encoding = ATTR_VAL_REF_SECTION;
-      return 1;
+      {
+       uint64_t offset;
+       offset = read_offset (buf, is_dwarf64);
+       if (altlink == NULL)
+         {
+           val->encoding = ATTR_VAL_NONE;
+           return 1;
+         }
+       if (offset >= altlink->dwarf_str_size)
+         {
+           dwarf_buf_error (buf, "DW_FORM_GNU_strp_alt out of range");
+           return 0;
+         }
+       val->encoding = ATTR_VAL_STRING;
+       val->u.string = (const char *) altlink->dwarf_str + offset;
+       return 1;
+      }
     default:
       dwarf_buf_error (buf, "unrecognized DWARF form");
       return 0;