internal_function unsigned char *
__libdw_formptr (Dwarf_Attribute *attr, int sec_index,
- int err_nodata, unsigned char **endpp)
+ int err_nodata, unsigned char **endpp,
+ Dwarf_Off *offsetp)
{
if (attr == NULL)
return NULL;
return NULL;
}
- *endpp = endp;
+ if (endpp != NULL)
+ *endpp = endp;
+ if (offsetp != NULL)
+ *offsetp = offset;
return readp;
}
}
unsigned char *endp, *readp
- = __libdw_formptr (attr, IDX_debug_loc,
- DWARF_E_NO_LOCLIST, &endp);
+ = __libdw_formptr (attr, IDX_debug_loc, DWARF_E_NO_LOCLIST, &endp, NULL);
if (readp == NULL)
return -1;
/* Get the offset into the .debug_line section. NB: this call
also checks whether the previous dwarf_attr call failed. */
const unsigned char *lineendp, *linep
- = __libdw_formptr (stmt_list, IDX_debug_line,
- DWARF_E_NO_DEBUG_LINE,
- (unsigned char **) &lineendp);
+ = __libdw_formptr (stmt_list, IDX_debug_line, DWARF_E_NO_DEBUG_LINE,
+ (unsigned char **) &lineendp, NULL);
if (linep == NULL)
goto out;
/* No PC attributes in this DIE at all, so an empty range list. */
return 0;
+ Dwarf_Word start_offset;
if ((readp = __libdw_formptr (attr, IDX_debug_ranges,
DWARF_E_NO_DEBUG_RANGES,
- &readendp)) == NULL)
+ &readendp, &start_offset)) == NULL)
return -1;
- Dwarf_Word start_offset = (void *) readp - d->d_buf;
-
offset = start_offset;
assert ((Dwarf_Word) offset == start_offset);
}
else
{
- if (offset < 0 || (size_t) offset >= d->d_size)
- {
- __libdw_seterrno (DWARF_E_INVALID_OFFSET);
- return -1l;
- }
+ if (!__libdw_offset_in_section (die->cu->dbg,
+ IDX_debug_ranges, offset, 1))
+ return -1l;
readp = d->d_buf + offset;
readendp = d->d_buf + d->d_size;
return true;
}
+static inline bool
+__libdw_offset_in_section (Dwarf *dbg, int sec_index,
+ Dwarf_Off offset, int width)
+{
+ Elf_Data *data = dbg->sectiondata[sec_index];
+ return __libdw_in_section (dbg, sec_index, data->d_buf + offset, width);
+}
+
/* Relocation hooks return -1 on error, 0 if there is no relocation
and 1 if a relocation was present.*/
int __libdw_relocate_address (Dwarf *dbg,
Dwarf_Off val;
READ_AND_RELOCATE (__libdw_relocate_offset, val);
- Elf_Data *data = dbg->sectiondata[sec_ret];
- if (!__libdw_in_section (dbg, sec_ret, data->d_buf + val, width))
+ if (!__libdw_offset_in_section (dbg, sec_ret, val, width))
return -1;
*ret = val;
unsigned char *
__libdw_formptr (Dwarf_Attribute *attr, int sec_index,
- int err_nodata, unsigned char **endpp)
+ int err_nodata, unsigned char **endpp, Dwarf_Off *offsetp)
internal_function;
static inline int