aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-09-26 23:20:06 +0930
committerAlan Modra <amodra@gmail.com>2017-09-26 23:23:44 +0930
commit33e0a9a056bd23e923b929a4f2ab049ade0b1c32 (patch)
tree2deb090c0367890c4b799c0e1a7ab086b312eb86 /bfd/dwarf2.c
parent30d0157a2ad64e64e5ff9fcc0dbe78a3e682f573 (diff)
downloadfsf-binutils-gdb-33e0a9a056bd23e923b929a4f2ab049ade0b1c32.zip
fsf-binutils-gdb-33e0a9a056bd23e923b929a4f2ab049ade0b1c32.tar.gz
fsf-binutils-gdb-33e0a9a056bd23e923b929a4f2ab049ade0b1c32.tar.bz2
Tidy reading data in read_formatted_entries
Using read_attribute_value accomplishes two things: It checks for unexpected formats, and ensures the buffer pointer always increments. PR 22210 * dwarf2.c (read_formatted_entries): Use read_attribute_value to read data.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r--bfd/dwarf2.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index dd5ac8f..be415e3 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1960,6 +1960,7 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp,
char *string_trash;
char **stringp = &string_trash;
unsigned int uint_trash, *uintp = &uint_trash;
+ struct attribute attr;
content_type = _bfd_safe_read_leb128 (abfd, format, &bytes_read,
FALSE, buf_end);
@@ -1991,47 +1992,23 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp,
form = _bfd_safe_read_leb128 (abfd, format, &bytes_read, FALSE,
buf_end);
format += bytes_read;
+
+ buf = read_attribute_value (&attr, form, 0, unit, buf, buf_end);
+ if (buf == NULL)
+ return FALSE;
switch (form)
{
case DW_FORM_string:
- *stringp = read_string (abfd, buf, buf_end, &bytes_read);
- buf += bytes_read;
- break;
-
case DW_FORM_line_strp:
- *stringp = read_indirect_line_string (unit, buf, buf_end, &bytes_read);
- buf += bytes_read;
+ *stringp = attr.u.str;
break;
case DW_FORM_data1:
- *uintp = read_1_byte (abfd, buf, buf_end);
- buf += 1;
- break;
-
case DW_FORM_data2:
- *uintp = read_2_bytes (abfd, buf, buf_end);
- buf += 2;
- break;
-
case DW_FORM_data4:
- *uintp = read_4_bytes (abfd, buf, buf_end);
- buf += 4;
- break;
-
case DW_FORM_data8:
- *uintp = read_8_bytes (abfd, buf, buf_end);
- buf += 8;
- break;
-
case DW_FORM_udata:
- *uintp = _bfd_safe_read_leb128 (abfd, buf, &bytes_read, FALSE,
- buf_end);
- buf += bytes_read;
- break;
-
- case DW_FORM_block:
- /* It is valid only for DW_LNCT_timestamp which is ignored by
- current GDB. */
+ *uintp = attr.u.val;
break;
}
}