/* Fetch a value from a debug section that has been indexed by
something in another section (eg DW_FORM_loclistx or DW_FORM_rnglistx).
- Returns 0 if the value could not be found. */
+ Returns -1 if the value could not be found. */
static dwarf_vma
fetch_indexed_value (dwarf_vma idx,
if (section->start == NULL)
{
warn (_("Unable to locate %s section\n"), section->uncompressed_name);
- return 0;
+ return -1;
}
uint32_t pointer_size, bias;
{
warn (_("Offset into section %s too big: 0x%s\n"),
section->name, dwarf_vmatoa ("x", offset));
- return 0;
+ return -1;
}
return byte_get (section->start + offset, pointer_size);
if (dwo)
{
idx = fetch_indexed_value (uvalue, loclists_dwo, 0);
- idx += (offset_size == 8) ? 20 : 12;
+ if (idx != (dwarf_vma) -1)
+ idx += (offset_size == 8) ? 20 : 12;
}
else if (debug_info_p == NULL)
{
idx += debug_info_p->loclists_base;
Fortunately we already have that sum cached in the
loc_offsets array. */
- idx = debug_info_p->loc_offsets [uvalue];
+ if (uvalue < debug_info_p->num_loc_offsets)
+ idx = debug_info_p->loc_offsets [uvalue];
+ else
+ {
+ warn (_("loc_offset %" PRIu64 " too big\n"), uvalue);
+ idx = -1;
+ }
}
}
else if (form == DW_FORM_rnglistx)
if (dwo)
{
idx = fetch_indexed_value (uvalue, rnglists_dwo, 0);
- idx += (offset_size == 8) ? 20 : 12;
+ if (idx != (dwarf_vma) -1)
+ idx += (offset_size == 8) ? 20 : 12;
}
else
{
/* We do not have a cached value this time, so we perform the
computation manually. */
idx = fetch_indexed_value (uvalue, rnglists, base);
- idx += base;
+ if (idx != (dwarf_vma) -1)
+ idx += base;
}
}
else
}
/* We have already displayed the form name. */
- printf (_("%c(index: 0x%s): %s"), delimiter,
- dwarf_vmatoa ("x", uvalue),
- dwarf_vmatoa ("x", idx));
+ if (idx != (dwarf_vma) -1)
+ printf (_("%c(index: 0x%s): %s"), delimiter,
+ dwarf_vmatoa ("x", uvalue),
+ dwarf_vmatoa ("x", idx));
}
break;