]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Handle DW_FORM_line_strp.
authorMark Wielaard <mark@klomp.org>
Wed, 25 Apr 2018 10:31:42 +0000 (12:31 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 6 May 2018 14:13:06 +0000 (16:13 +0200)
DW_FORM_line_strp strings come from a separate .debug_line_str section.
Make error messages more distinct (no .debug_str, no .debug_line_str or
not a string form).

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_begin_elf.c
libdw/dwarf_error.c
libdw/dwarf_formstring.c
libdw/libdwP.h

index 276f3a4e9095040f81c35d480dae225b9b100400..9ec493fb56cdfa94535a6ce523a301c55941f4d6 100644 (file)
@@ -1,3 +1,13 @@
+2018-04-24  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_begin_elf.c (dwarf_scnnames): Add ".debug_line_str".
+       * dwarf_error.c (errmsgs): Add DWARF_E_NO_DEBUG_STR and
+       DWARF_E_NO_DEBUG_LINE_STR.
+       * dwarf_formstring.c (dwarf_formstring): Handle DW_FORM_line_strp.
+       Get data from either .debug_str or .debug_line_str.
+       * libdwP.h: Add IDX_debug_line_str, DWARF_E_NO_DEBUG_STR and
+       DWARF_E_NO_DEBUG_LINE_STR.
+
 2018-04-03  Mark Wielaard  <mark@klomp.org>
 
        * dwarf_formudata.c (__libdw_formptr): Take and return const
index 19a5fbbbb5d32ed55e13ff054640337969476c93..8bdcea2f17a909e303e6f101e0c088fb570a4428 100644 (file)
@@ -55,6 +55,7 @@ static const char dwarf_scnnames[IDX_last][19] =
   [IDX_debug_addr] = ".debug_addr",
   [IDX_debug_aranges] = ".debug_aranges",
   [IDX_debug_line] = ".debug_line",
+  [IDX_debug_line_str] = ".debug_line_str",
   [IDX_debug_frame] = ".debug_frame",
   [IDX_debug_loc] = ".debug_loc",
   [IDX_debug_pubnames] = ".debug_pubnames",
index cbf573fb6c772c929b383625885f46e13a037afc..63c8bbe7e44d52fcd0d3869a13d6de47b18548e5 100644 (file)
@@ -1,7 +1,6 @@
 /* Retrieve ELF descriptor used for DWARF access.
-   Copyright (C) 2002, 2003, 2004, 2005, 2009, 2014, 2015 Red Hat, Inc.
+   Copyright (C) 2002-2005, 2009, 2014, 2015, 2017, 2018 Red Hat, Inc.
    This file is part of elfutils.
-   Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This file is free software; you can redistribute it and/or modify
    it under the terms of either
@@ -73,6 +72,8 @@ static const char *errmsgs[] =
     [DWARF_E_NO_ENTRY] = N_("no entries found"),
     [DWARF_E_INVALID_DWARF] = N_("invalid DWARF"),
     [DWARF_E_NO_STRING] = N_("no string data"),
+    [DWARF_E_NO_DEBUG_STR] = N_(".debug_str section missing"),
+    [DWARF_E_NO_DEBUG_LINE_STR] = N_(".debug_line_str section missing"),
     [DWARF_E_NO_STR_OFFSETS] = N_(".debug_str_offsets section missing"),
     [DWARF_E_NO_ADDR] = N_("no address value"),
     [DWARF_E_NO_CONSTANT] = N_("no constant value"),
index 39766ad5b6c106539df2971ca2bf8eade1cc58e8..e7396a7924397bdb5144b1df58f14bbb19f7c19e 100644 (file)
@@ -57,9 +57,14 @@ dwarf_formstring (Dwarf_Attribute *attrp)
       return NULL;
     }
 
-  if (dbg_ret->sectiondata[IDX_debug_str] == NULL)
+  Elf_Data *data = ((attrp->form == DW_FORM_line_strp)
+                   ? dbg_ret->sectiondata[IDX_debug_line_str]
+                   : dbg_ret->sectiondata[IDX_debug_str]);
+  if (data == NULL)
     {
-      __libdw_seterrno (DWARF_E_NO_STRING);
+      __libdw_seterrno ((attrp->form == DW_FORM_line_strp)
+                       ? DWARF_E_NO_DEBUG_LINE_STR
+                       : DWARF_E_NO_DEBUG_STR);
       return NULL;
     }
 
@@ -72,6 +77,13 @@ dwarf_formstring (Dwarf_Attribute *attrp)
                               IDX_debug_str, 1))
        return NULL;
     }
+  else if (attrp->form == DW_FORM_line_strp)
+    {
+      if (__libdw_read_offset (dbg, dbg_ret, cu_sec_idx (cu),
+                              attrp->valp, cu->offset_size, &off,
+                              IDX_debug_line_str, 1))
+       return NULL;
+    }
   else
     {
       Dwarf_Word idx;
@@ -160,7 +172,7 @@ dwarf_formstring (Dwarf_Attribute *attrp)
        goto invalid_offset;
     }
 
-  return (const char *) dbg_ret->sectiondata[IDX_debug_str]->d_buf + off;
+  return (const char *) data->d_buf + off;
 }
 INTDEF(dwarf_formstring)
 
index 594486f7a6255018d58af79dc938fee74ebf895e..4de0f6c3be669c5674874ebfac97bba9803426fd 100644 (file)
@@ -75,6 +75,7 @@ enum
     IDX_debug_aranges,
     IDX_debug_addr,
     IDX_debug_line,
+    IDX_debug_line_str,
     IDX_debug_frame,
     IDX_debug_loc,
     IDX_debug_pubnames,
@@ -109,6 +110,8 @@ enum
   DWARF_E_NO_ENTRY,
   DWARF_E_INVALID_DWARF,
   DWARF_E_NO_STRING,
+  DWARF_E_NO_DEBUG_STR,
+  DWARF_E_NO_DEBUG_LINE_STR,
   DWARF_E_NO_STR_OFFSETS,
   DWARF_E_NO_ADDR,
   DWARF_E_NO_CONSTANT,