]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Report error when decl_file or call_file attribute is invalid.
authorMark Wielaard <mark@klomp.org>
Tue, 20 Mar 2018 12:29:25 +0000 (13:29 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 27 Mar 2018 13:40:36 +0000 (15:40 +0200)
Report an error for why the DW_AT_decl_file or DW_AT_call_file cannot
be resolved to a file name. This is likely invalid DWARF, a missing
DW_AT_stmt_list attribute on the CU or a missing .debug_line section.

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

index c879712d5e925418d5be3387b01d2d9e27c2d88e..f2f99ed1a314f7112238c64218bec64898e198e1 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-20  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (attr_callback): Report error when DW_AT_decl_file or
+       DW_AT_call_file cannot be resolved.
+
 2018-03-06  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (print_ops): Handle DW_OP_addrx, DW_OP_constx,
index fcf5e2cd900d99b01f715e33f11b3e07ed7703a5..8a968815b754a22d985bfc11da064a3c09894015 100644 (file)
@@ -6247,11 +6247,25 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
                if (dwarf_getsrcfiles (&cudie, &files, &nfiles) == 0)
                  {
                    valuestr = dwarf_filesrc (files, num, NULL, NULL);
-                   char *filename = strrchr (valuestr, '/');
-                   if (filename != NULL)
-                     valuestr = filename + 1;
+                   if (valuestr != NULL)
+                     {
+                       char *filename = strrchr (valuestr, '/');
+                       if (filename != NULL)
+                         valuestr = filename + 1;
+                     }
+                   else
+                     error (0, 0, gettext ("invalid file (%" PRId64 "): %s"),
+                            num, dwarf_errmsg (-1));
                  }
+               else
+                 error (0, 0, gettext ("no srcfiles for CU [%zx]"),
+                        dwarf_dieoffset (&cudie));
              }
+           else
+            error (0, 0, gettext ("couldn't get DWARF CU: %s"),
+                   dwarf_errmsg (-1));
+           if (valuestr == NULL)
+             valuestr = "???";
          }
          break;
        default: