? attr->cu->address_size
: attr->cu->offset_size);
- if (__libdw_read_offset (attr->cu->dbg,
- IDX_debug_info, attr->valp,
- ref_size, &offset, IDX_debug_info))
+ if (__libdw_read_offset (attr->cu->dbg, IDX_debug_info, attr->valp,
+ ref_size, &offset, IDX_debug_info, 0))
return NULL;
}
else
uint64_t off;
if (__libdw_read_offset (dbg, IDX_debug_info, attrp->valp,
- attrp->cu->offset_size, &off, IDX_debug_str))
+ attrp->cu->offset_size, &off, IDX_debug_str, 1))
return NULL;
return (const char *) dbg->sectiondata[IDX_debug_str]->d_buf + off;
case DW_FORM_data8:
if (__libdw_read_offset (attr->cu->dbg, IDX_debug_info, attr->valp,
attr->form == DW_FORM_data4 ? 4 : 8,
- &offset, sec_index))
+ &offset, sec_index, 0))
return NULL;
break;
Dwarf_Word offset;
if (__libdw_read_offset_inc (dbg,
IDX_debug_aranges, (unsigned char **)&readp,
- length_bytes, &offset, IDX_debug_info))
+ length_bytes, &offset, IDX_debug_info, 4))
return -1;
unsigned int address_size = *readp++;
else if (unlikely (len >= DWARF3_LENGTH_MIN_ESCAPE_CODE
&& len <= DWARF3_LENGTH_MAX_ESCAPE_CODE))
{
- invalid_dwarf:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
goto err_return;
}
/* Get the CU offset. */
if (__libdw_read_offset (dbg, IDX_debug_pubnames, readp + 2, len_bytes,
- &mem[cnt].cu_offset, IDX_debug_info))
+ &mem[cnt].cu_offset, IDX_debug_info, 3))
/* Error has been already set in reader. */
goto err_return;
/* Determine the size of the CU header. */
- if (unlikely (dbg->sectiondata[IDX_debug_info] == NULL
- || dbg->sectiondata[IDX_debug_info]->d_buf == NULL))
- goto invalid_dwarf;
-
unsigned char *infop
= ((unsigned char *) dbg->sectiondata[IDX_debug_info]->d_buf
+ mem[cnt].cu_offset);
/* 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 (__libdw_read_offset_inc (dwarf, IDX_debug_info, &bytes,
- offset_size, &abbrev_offset, IDX_debug_abbrev))
+ if (__libdw_read_offset_inc (dwarf, IDX_debug_info, &bytes, offset_size,
+ &abbrev_offset, IDX_debug_abbrev, 0))
return -1;
if (abbrev_offsetp != NULL)
static inline bool
__libdw_in_section (Dwarf *dbg, int sec_index,
- unsigned char *addr, int width)
+ unsigned char *addr, int size)
{
Elf_Data *data = dbg->sectiondata[sec_index];
+ if (data == NULL || data->d_buf == NULL)
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return false;
+ }
if ((void *) addr < data->d_buf
- || (void *) addr + width > data->d_buf + data->d_size)
+ || (void *) addr + size > data->d_buf + data->d_size)
{
__libdw_seterrno (DWARF_E_INVALID_OFFSET);
return false;
static inline bool
__libdw_offset_in_section (Dwarf *dbg, int sec_index,
- Dwarf_Off offset, int width)
+ Dwarf_Off offset, int size)
{
Elf_Data *data = dbg->sectiondata[sec_index];
- return __libdw_in_section (dbg, sec_index, data->d_buf + offset, width);
+ if (data == NULL || data->d_buf == NULL)
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return false;
+ }
+ return __libdw_in_section (dbg, sec_index, data->d_buf + offset, size);
}
#define READ_AND_RELOCATE(RELOC_HOOK, VAL) \
static inline int
__libdw_read_offset_inc (Dwarf *dbg,
int sec_index, unsigned char **addr,
- int width, Dwarf_Off *ret, int sec_ret)
+ int width, Dwarf_Off *ret, int sec_ret,
+ int size)
{
Dwarf_Off val;
READ_AND_RELOCATE (__libdw_relocate_offset, val);
- if (!__libdw_offset_in_section (dbg, sec_ret, val, width))
+ if (!__libdw_offset_in_section (dbg, sec_ret, val, size))
return -1;
*ret = val;
static inline int
__libdw_read_offset (Dwarf *dbg,
int sec_index, const unsigned char *addr,
- int width, Dwarf_Off *ret, int sec_ret)
+ int width, Dwarf_Off *ret, int sec_ret,
+ int size)
{
return __libdw_read_offset_inc (dbg, sec_index, (unsigned char **)&addr,
- width, ret, sec_ret);
+ width, ret, sec_ret, size);
}