aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-04-25 12:40:38 +0200
committerMark Wielaard <mark@klomp.org>2018-05-06 16:16:10 +0200
commit3cc78df8a2ee5d346298c342c3ffeed2d9c59131 (patch)
tree2f51dde925e7a6f1891593ab81f2c8fc69d15d1c /src
parent5db8103d36333afd087eb0eceaa81b5c7c98eaa3 (diff)
downloadelfutils-3cc78df8a2ee5d346298c342c3ffeed2d9c59131.tar.gz
readelf: Handle .debug_line_str section.
It is just a .debug_str section with another name. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/readelf.c21
2 files changed, 20 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 77644821..4b55bbcd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-24 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_debug_str_section): Take raw section data. Don't
+ use dwarf_getstring, but determine start and end of string from
+ offset and section data directly.
+ (print_debug): Handle ".debug_line_str" like ".debug_str".
+
2018-04-19 Andreas Schwab <schwab@suse.de>
* elflint.c (valid_e_machine): Add EM_RISCV.
diff --git a/src/readelf.c b/src/readelf.c
index 45fc8265..c2fcfff9 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6105,6 +6105,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
case DW_FORM_indirect:
case DW_FORM_strp:
+ case DW_FORM_line_strp:
case DW_FORM_strx:
case DW_FORM_strx1:
case DW_FORM_strx2:
@@ -8125,10 +8126,11 @@ print_debug_pubnames_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
static void
print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
Ebl *ebl, GElf_Ehdr *ehdr,
- Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
+ Elf_Scn *scn, GElf_Shdr *shdr,
+ Dwarf *dbg __attribute__ ((unused)))
{
- const size_t sh_size = (dbg->sectiondata[IDX_debug_str] ?
- dbg->sectiondata[IDX_debug_str]->d_size : 0);
+ Elf_Data *data = elf_rawdata (scn, NULL);
+ const size_t sh_size = data ? data->d_size : 0;
/* Compute floor(log16(shdr->sh_size)). */
GElf_Addr tmp = sh_size;
@@ -8151,16 +8153,16 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
while (offset < sh_size)
{
size_t len;
- const char *str = dwarf_getstring (dbg, offset, &len);
- if (unlikely (str == NULL))
+ const char *str = (const char *) data->d_buf + offset;
+ const char *endp = memchr (str, '\0', sh_size - offset);
+ if (unlikely (endp == NULL))
{
- printf (gettext (" *** error while reading strings: %s\n"),
- dwarf_errmsg (-1));
+ printf (gettext (" *** error, missing string terminator\n"));
break;
}
printf (" [%*" PRIx64 "] \"%s\"\n", digits, (uint64_t) offset, str);
-
+ len = endp - str;
offset += len + 1;
}
}
@@ -8754,6 +8756,9 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
NEW_SECTION (loc),
NEW_SECTION (pubnames),
NEW_SECTION (str),
+ /* A DWARF5 specialised debug string section. */
+ { ".debug_line_str", section_str,
+ print_debug_str_section },
NEW_SECTION (macinfo),
NEW_SECTION (macro),
NEW_SECTION (ranges),