}
static Dwarf_Off
-next_listptr_offset (struct listptr_table *table, size_t idx)
+next_listptr_offset (struct listptr_table *table, size_t *idxp, Dwarf_Off off)
{
/* Note that multiple attributes could in theory point to the same loclist
offset, so make sure we pick one that is bigger than the current one.
The table is sorted on offset. */
- Dwarf_Off offset = table->table[idx].offset;
- while (++idx < table->n)
+ if (*idxp < table->n)
{
- Dwarf_Off next = table->table[idx].offset;
- if (next > offset)
- return next;
+ while (++*idxp < table->n)
+ {
+ Dwarf_Off next = table->table[*idxp].offset;
+ if (next > off)
+ return next;
+ }
}
return 0;
}
struct listptr *p = &table->table[*idxp];
*base = listptr_base (p);
*cu = p->cu;
- ++*idxp;
return true;
}
return false;
}
+/* Returns the next index with the current CU for the given attribute.
+ If there is none false is returned, otherwise true. Assumes the
+ table has been sorted. */
+static bool
+listptr_attr (struct listptr_table *table, size_t idxp,
+ Dwarf_Off offset, unsigned int attr)
+{
+ struct listptr *listptr;
+ do
+ {
+ listptr = get_listptr (table, idxp);
+ if (listptr == NULL)
+ return false;
+
+ if (listptr->offset == offset && listptr->attr == attr)
+ return true;
+
+ idxp++;
+ }
+ while (listptr->offset <= offset);
+
+ return false;
+}
+
static void
print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
Ebl *ebl, GElf_Ehdr *ehdr __attribute__ ((unused)),
bool start_of_list = true;
while (readp < nexthdr)
{
+ Dwarf_Off off = (Dwarf_Off) (readp - (unsigned char *) data->d_buf);
+ if (listptr_attr (&known_loclistsptr, listptr_idx, off,
+ DW_AT_GNU_locviews))
+ {
+ Dwarf_Off next_off = next_listptr_offset (&known_loclistsptr,
+ &listptr_idx, off);
+ const unsigned char *locp = readp;
+ const unsigned char *locendp;
+ if (next_off == 0
+ || next_off > (size_t) (nexthdr - ((const unsigned char *)
+ data->d_buf)))
+ locendp = nexthdr;
+ else
+ locendp = (const unsigned char *) data->d_buf + next_off;
+
+ printf (" Offset: %" PRIx64 ", Index: %" PRIx64 "\n",
+ (uint64_t) (readp - (unsigned char *) data->d_buf),
+ (uint64_t) (readp - offset_array_start));
+
+ while (locp < locendp)
+ {
+ uint64_t v1, v2;
+ get_uleb128 (v1, locp, locendp);
+ if (locp >= locendp)
+ {
+ printf (gettext (" <INVALID DATA>\n"));
+ break;
+ }
+ get_uleb128 (v2, locp, locendp);
+ printf (" view pair %" PRId64 ", %" PRId64 "\n", v1, v2);
+ }
+
+ printf ("\n");
+ readp = (unsigned char *) locendp;
+ continue;
+ }
+
uint8_t kind = *readp++;
uint64_t op1, op2, len;
if (attr == DW_AT_GNU_locviews)
{
Dwarf_Off next_off = next_listptr_offset (&known_locsptr,
- listptr_idx);
+ &listptr_idx, offset);
const unsigned char *locp = readp;
const unsigned char *locendp;
if (next_off == 0