+/* Parse the next DWARF2 compilation unit at STASH->INFO_PTR. */
+
+static struct comp_unit *
+stash_comp_unit (struct dwarf2_debug *stash)
+{
+ bfd_size_type length;
+ unsigned int offset_size;
+ bfd_byte *info_ptr_unit = stash->info_ptr;
+
+ if (stash->info_ptr >= stash->info_ptr_end)
+ return NULL;
+
+ length = read_4_bytes (stash->bfd_ptr, stash->info_ptr,
+ stash->info_ptr_end);
+ /* A 0xffffff length is the DWARF3 way of indicating
+ we use 64-bit offsets, instead of 32-bit offsets. */
+ if (length == 0xffffffff)
+ {
+ offset_size = 8;
+ length = read_8_bytes (stash->bfd_ptr, stash->info_ptr + 4,
+ stash->info_ptr_end);
+ stash->info_ptr += 12;
+ }
+ /* A zero length is the IRIX way of indicating 64-bit offsets,
+ mostly because the 64-bit length will generally fit in 32
+ bits, and the endianness helps. */
+ else if (length == 0)
+ {
+ offset_size = 8;
+ length = read_4_bytes (stash->bfd_ptr, stash->info_ptr + 4,
+ stash->info_ptr_end);
+ stash->info_ptr += 8;
+ }
+ /* In the absence of the hints above, we assume 32-bit DWARF2
+ offsets even for targets with 64-bit addresses, because:
+ a) most of the time these targets will not have generated
+ more than 2Gb of debug info and so will not need 64-bit
+ offsets,
+ and
+ b) if they do use 64-bit offsets but they are not using
+ the size hints that are tested for above then they are
+ not conforming to the DWARF3 standard anyway. */
+ else
+ {
+ offset_size = 4;
+ stash->info_ptr += 4;
+ }
+
+ if (length != 0
+ && stash->info_ptr + length <= stash->info_ptr_end
+ && stash->info_ptr + length > stash->info_ptr)
+ {
+ struct comp_unit *each = parse_comp_unit (stash, length, info_ptr_unit,
+ offset_size);
+ if (each)
+ {
+ if (stash->all_comp_units)
+ stash->all_comp_units->prev_unit = each;
+ else
+ stash->last_comp_unit = each;
+
+ each->next_unit = stash->all_comp_units;
+ stash->all_comp_units = each;
+
+ stash->info_ptr += length;
+ return each;
+ }
+ }
+
+ /* Don't trust any of the DWARF info after a corrupted length or
+ parse error. */
+ stash->info_ptr = stash->info_ptr_end;
+ return NULL;
+}
+
+/* Hash function for an asymbol. */
+
+static hashval_t
+hash_asymbol (const void *sym)
+{
+ const asymbol *asym = sym;
+ return htab_hash_string (asym->name);
+}
+
+/* Equality function for asymbols. */
+
+static int
+eq_asymbol (const void *a, const void *b)
+{
+ const asymbol *sa = a;
+ const asymbol *sb = b;
+ return strcmp (sa->name, sb->name) == 0;
+}
+