]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Handle DW_FORM_[ref|strp]_sup[48] as DW_FORM_GNU_[ref|strp]_alt.
authorMark Wielaard <mark@klomp.org>
Tue, 8 May 2018 13:34:03 +0000 (15:34 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 11 May 2018 15:27:00 +0000 (17:27 +0200)
Although we don't yet handle DWARF5 supplemental files, they are like
mostly like GNU alt files.  This way using any of the supplemental files
will at least generate an appropriate error message.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_formref.c
libdw/dwarf_formref_die.c
libdw/dwarf_formstring.c
src/ChangeLog
src/readelf.c

index cc7eae9d46898972770953ffa072dd643209c472..5e2c0d81facd0e4469243dd7999fa8f1f2188233 100644 (file)
@@ -1,3 +1,12 @@
+2018-05-08  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_formref.c (__libdw_formref): Explicitly don't handle
+       DW_FORM_ref_sup4 and DW_FORM_ref_sup8.
+       * dwarf_formref_die.c (dwarf_formref_die): Handle DW_FORM_ref_sup4
+       and DW_FORM_ref_sup8.
+       * dwarf_formstring.c (dwarf_formstring): Handle DW_FORM_strp_sup
+       as DW_FORM_GNU_strp_alt.
+
 2018-05-05  Mark Wielaard  <mark@klomp.org>
 
        * dwarf.h: Add DWARF line content descriptions.
index 2240a258031810ca2024db6673ac9842e327c5a9..2bae2a44ccd5cbd980d58b2a4e500696c1bc2b54 100644 (file)
@@ -86,6 +86,8 @@ __libdw_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
     case DW_FORM_ref_addr:
     case DW_FORM_ref_sig8:
     case DW_FORM_GNU_ref_alt:
+    case DW_FORM_ref_sup4:
+    case DW_FORM_ref_sup8:
       /* These aren't handled by dwarf_formref, only by dwarf_formref_die.  */
       __libdw_seterrno (DWARF_E_INVALID_REFERENCE);
       return -1;
index d47fb2f5f3d4257210079e085b92181fadc04d22..f196331acb69cbbca52ae7a67408f512c3dc3ccc 100644 (file)
@@ -44,13 +44,20 @@ dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *result)
   struct Dwarf_CU *cu = attr->cu;
 
   Dwarf_Off offset;
-  if (attr->form == DW_FORM_ref_addr || attr->form == DW_FORM_GNU_ref_alt)
+  if (attr->form == DW_FORM_ref_addr || attr->form == DW_FORM_GNU_ref_alt
+      || attr->form == DW_FORM_ref_sup4 || attr->form == DW_FORM_ref_sup8)
     {
       /* This has an absolute offset.  */
 
-      uint8_t ref_size = (cu->version == 2 && attr->form == DW_FORM_ref_addr
-                         ? cu->address_size
-                         : cu->offset_size);
+      uint8_t ref_size;
+      if (cu->version == 2 && attr->form == DW_FORM_ref_addr)
+       ref_size = cu->address_size;
+      else if (attr->form == DW_FORM_ref_sup4)
+       ref_size = 4;
+      else if (attr->form == DW_FORM_ref_sup8)
+       ref_size = 8;
+      else
+       ref_size = cu->offset_size;
 
       Dwarf *dbg_ret = (attr->form == DW_FORM_GNU_ref_alt
                        ? INTUSE(dwarf_getalt) (cu->dbg) : cu->dbg);
index e7396a7924397bdb5144b1df58f14bbb19f7c19e..c55c7f04f9b6d0b2f96affce3ee58af59c2f48b3 100644 (file)
@@ -48,7 +48,8 @@ dwarf_formstring (Dwarf_Attribute *attrp)
 
   Dwarf_CU *cu = attrp->cu;
   Dwarf *dbg = cu->dbg;
-  Dwarf *dbg_ret = (attrp->form == DW_FORM_GNU_strp_alt
+  Dwarf *dbg_ret = ((attrp->form == DW_FORM_GNU_strp_alt
+                    || attrp->form == DW_FORM_strp_sup)
                    ? INTUSE(dwarf_getalt) (dbg) : dbg);
 
   if (unlikely (dbg_ret == NULL))
@@ -70,7 +71,8 @@ dwarf_formstring (Dwarf_Attribute *attrp)
 
   uint64_t off;
   if (attrp->form == DW_FORM_strp
-      || attrp->form == DW_FORM_GNU_strp_alt)
+      || attrp->form == DW_FORM_GNU_strp_alt
+      || attrp->form == DW_FORM_strp_sup)
     {
       if (__libdw_read_offset (dbg, dbg_ret, cu_sec_idx (cu),
                               attrp->valp, cu->offset_size, &off,
index 4b55bbcd40a4b90b4e7014b758b444c00164f69c..b1041a83d94c495aa7a4515d83fad879c137bcf4 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-05  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (attr_callback): Handle DW_FORM_ref_sup4 and
+       DW_FORM_ref_sup8 as references.
+
 2018-04-24  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (print_debug_str_section): Take raw section data. Don't
index c2fcfff9f9417815bcd4ff709ef5aad1f926cfe6..c69910abe183af304efeae0da41fb47761807a9a 100644 (file)
@@ -6130,6 +6130,8 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
     case DW_FORM_ref2:
     case DW_FORM_ref1:
     case DW_FORM_GNU_ref_alt:
+    case DW_FORM_ref_sup4:
+    case DW_FORM_ref_sup8:
       if (cbargs->silent)
        break;
       Dwarf_Die ref;