diff options
author | Mark Wielaard <[email protected]> | 2018-04-25 12:31:42 +0200 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2018-05-06 16:13:06 +0200 |
commit | 5db8103d36333afd087eb0eceaa81b5c7c98eaa3 (patch) | |
tree | 5ded2670681d6881840d1d99c22a42540c8c726a /libdw/dwarf_formstring.c | |
parent | 470aba95790b52d70b6bd78b4c4a481ab791a4c9 (diff) |
libdw: Handle DW_FORM_line_strp.
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 <[email protected]>
Diffstat (limited to 'libdw/dwarf_formstring.c')
-rw-r--r-- | libdw/dwarf_formstring.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c index 39766ad5..e7396a79 100644 --- a/libdw/dwarf_formstring.c +++ b/libdw/dwarf_formstring.c @@ -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) |