This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 4/9] [libbacktrace] Handle DW_FORM_GNU_strp_alt
- From: Tom de Vries <tdevries at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Ian Lance Taylor <ian at airs dot com>
- Date: Tue, 11 Dec 2018 11:14:06 +0100
- Subject: [PATCH 4/9] [libbacktrace] Handle DW_FORM_GNU_strp_alt
- References: <20181211101411.7067-1-tdevries@suse.de>
Handle DW_FORM_GNU_strp_alt which references the .debug_str section in the
.gnu_debugaltlink file.
2018-11-11 Tom de Vries <tdevries@suse.de>
* dwarf.c (read_attribute): Handle DW_FORM_GNU_strp_alt
using altlink.
---
libbacktrace/dwarf.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c
index 8b802a085ca..341b84605c0 100644
--- a/libbacktrace/dwarf.c
+++ b/libbacktrace/dwarf.c
@@ -843,14 +843,23 @@ read_attribute (enum dwarf_form form, struct dwarf_buf *buf,
val->encoding = ATTR_VAL_REF_SECTION;
return 1;
case DW_FORM_GNU_strp_alt:
- val->u.uint = read_offset (buf, is_dwarf64);
- if (altlink == NULL)
- {
- val->encoding = ATTR_VAL_NONE;
- return 1;
- }
- val->encoding = ATTR_VAL_REF_SECTION;
- return 1;
+ {
+ uint64_t offset;
+ offset = read_offset (buf, is_dwarf64);
+ if (altlink == NULL)
+ {
+ val->encoding = ATTR_VAL_NONE;
+ return 1;
+ }
+ if (offset >= altlink->dwarf_str_size)
+ {
+ dwarf_buf_error (buf, "DW_FORM_GNU_strp_alt out of range");
+ return 0;
+ }
+ val->encoding = ATTR_VAL_STRING;
+ val->u.string = (const char *) altlink->dwarf_str + offset;
+ return 1;
+ }
default:
dwarf_buf_error (buf, "unrecognized DWARF form");
return 0;
--
2.16.4