summaryrefslogtreecommitdiff
path: root/libdw
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2009-04-28 18:39:04 +0200
committerPetr Machata <pmachata@redhat.com>2009-04-28 18:39:04 +0200
commitcb8f67b29a896c2660c10aa1028a9dbb377553e9 (patch)
tree1081f07e8e8c0951eec5707aae612fd763124251 /libdw
parentb130453eb16a8cf042915e312cc5f189b8b92c01 (diff)
downloadelfutils-cb8f67b29a896c2660c10aa1028a9dbb377553e9.tar.gz
Convert several new functions to use read hooks
Diffstat (limited to 'libdw')
-rw-r--r--libdw/dwarf_formblock.c4
-rw-r--r--libdw/dwarf_formstring.c8
-rw-r--r--libdw/dwarf_formudata.c8
-rw-r--r--libdw/dwarf_getaranges.c25
-rw-r--r--libdw/dwarf_getsrclines.c8
-rw-r--r--libdw/dwarf_nextcu.c15
6 files changed, 32 insertions, 36 deletions
diff --git a/libdw/dwarf_formblock.c b/libdw/dwarf_formblock.c
index 51396d47..486dc198 100644
--- a/libdw/dwarf_formblock.c
+++ b/libdw/dwarf_formblock.c
@@ -79,7 +79,9 @@ dwarf_formblock (attr, return_block)
break;
case DW_FORM_block4:
- return_block->length = read_4ubyte_unaligned (attr->cu->dbg, attr->valp);
+ if (__libdw_read_length (attr->cu->dbg, IDX_debug_info, attr->valp,
+ 4, &return_block->length))
+ return -1;
return_block->data = attr->valp + 4;
break;
diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c
index 790831ea..63eca9b1 100644
--- a/libdw/dwarf_formstring.c
+++ b/libdw/dwarf_formstring.c
@@ -80,11 +80,9 @@ dwarf_formstring (attrp)
}
uint64_t off;
- // XXX We need better boundary checks.
- if (attrp->cu->offset_size == 8)
- off = read_8ubyte_unaligned (dbg, attrp->valp);
- else
- off = read_4ubyte_unaligned (dbg, attrp->valp);
+ if (__libdw_read_offset (dbg, IDX_debug_info, attrp->valp,
+ attrp->cu->offset_size, &off))
+ return NULL;
if (off >= dbg->sectiondata[IDX_debug_str]->d_size)
goto invalid_error;
diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c
index b5c40bb5..e2f1d023 100644
--- a/libdw/dwarf_formudata.c
+++ b/libdw/dwarf_formudata.c
@@ -77,11 +77,11 @@ dwarf_formudata (attr, return_uval)
break;
case DW_FORM_data4:
- *return_uval = read_4ubyte_unaligned (attr->cu->dbg, attr->valp);
- break;
-
case DW_FORM_data8:
- *return_uval = read_8ubyte_unaligned (attr->cu->dbg, attr->valp);
+ if (__libdw_read_offset (attr->cu->dbg, IDX_debug_info, attr->valp,
+ attr->form == DW_FORM_data4 ? 4 : 8,
+ return_uval))
+ return -1;
break;
case DW_FORM_sdata:
diff --git a/libdw/dwarf_getaranges.c b/libdw/dwarf_getaranges.c
index 96e99620..78086fb8 100644
--- a/libdw/dwarf_getaranges.c
+++ b/libdw/dwarf_getaranges.c
@@ -149,10 +149,10 @@ dwarf_getaranges (dbg, aranges, naranges)
}
Dwarf_Word offset;
- if (length_bytes == 4)
- offset = read_4ubyte_unaligned_inc (dbg, readp);
- else
- offset = read_8ubyte_unaligned_inc (dbg, readp);
+ if (__libdw_read_offset_inc (dbg,
+ IDX_debug_aranges, (unsigned char **)&readp,
+ length_bytes, &offset))
+ return -1;
/* Sanity-check the offset. */
if (offset + 4 > dbg->sectiondata[IDX_debug_info]->d_size)
@@ -175,16 +175,13 @@ dwarf_getaranges (dbg, aranges, naranges)
Dwarf_Word range_address;
Dwarf_Word range_length;
- if (address_size == 4)
- {
- range_address = read_4ubyte_unaligned_inc (dbg, readp);
- range_length = read_4ubyte_unaligned_inc (dbg, readp);
- }
- else
- {
- range_address = read_8ubyte_unaligned_inc (dbg, readp);
- range_length = read_8ubyte_unaligned_inc (dbg, readp);
- }
+ if (__libdw_read_address_inc (dbg, IDX_debug_aranges,
+ (unsigned char **)&readp,
+ address_size, &range_address)
+ || __libdw_read_length_inc (dbg, IDX_debug_aranges,
+ (unsigned char **)&readp,
+ address_size, &range_length))
+ return -1;
/* Two zero values mark the end. */
if (range_address == 0 && range_length == 0)
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index fe0e67d6..67b62aac 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -429,10 +429,10 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
/* The value is an address. The size is defined as
apporiate for the target machine. We use the
address size field from the CU header. */
- if (cu->address_size == 4)
- address = read_4ubyte_unaligned_inc (dbg, linep);
- else
- address = read_8ubyte_unaligned_inc (dbg, linep);
+ if (__libdw_read_address_inc (dbg, IDX_debug_line,
+ (unsigned char **)&linep,
+ cu->address_size, &address))
+ goto out;
break;
case DW_LNE_define_file:
diff --git a/libdw/dwarf_nextcu.c b/libdw/dwarf_nextcu.c
index 9e5a96bc..abffe7ec 100644
--- a/libdw/dwarf_nextcu.c
+++ b/libdw/dwarf_nextcu.c
@@ -84,7 +84,8 @@ dwarf_nextcu (dwarf, off, next_off, header_sizep, abbrev_offsetp,
/* This points into the .debug_info section to the beginning of the
CU entry. */
- char *bytes = (char *) dwarf->sectiondata[IDX_debug_info]->d_buf + off;
+ unsigned char *data = (unsigned char *) dwarf->sectiondata[IDX_debug_info]->d_buf;
+ unsigned char *bytes = data + off;
/* The format of the CU header is described in dwarf2p1 7.5.1:
@@ -144,10 +145,10 @@ dwarf_nextcu (dwarf, off, next_off, header_sizep, abbrev_offsetp,
/* Get offset in .debug_abbrev. Note that the size of the entry
depends on whether this is a 32-bit or 64-bit DWARF definition. */
uint64_t abbrev_offset;
- if (offset_size == 4)
- abbrev_offset = read_4ubyte_unaligned_inc (dwarf, bytes);
- else
- abbrev_offset = read_8ubyte_unaligned_inc (dwarf, bytes);
+ if (__libdw_read_offset_inc (dwarf, IDX_debug_info, &bytes,
+ offset_size, &abbrev_offset))
+ return -1;
+
if (abbrev_offsetp != NULL)
*abbrev_offsetp = abbrev_offset;
@@ -162,9 +163,7 @@ dwarf_nextcu (dwarf, off, next_off, header_sizep, abbrev_offsetp,
/* Store the header length. */
if (header_sizep != NULL)
- *header_sizep = (bytes
- - ((char *) dwarf->sectiondata[IDX_debug_info]->d_buf
- + off));
+ *header_sizep = bytes - (data + off);
/* See definition of DIE_OFFSET_FROM_CU_OFFSET macro
for an explanation of the trick in this expression. */