+/* Parse the next DWARF2 compilation unit at FILE->INFO_PTR. */
+
+static struct comp_unit *
+stash_comp_unit (struct dwarf2_debug *stash, struct dwarf2_debug_file *file)
+{
+ bfd_size_type length;
+ unsigned int offset_size;
+ bfd_byte *info_ptr_unit = file->info_ptr;
+ bfd_byte *info_ptr_end = file->dwarf_info_buffer + file->dwarf_info_size;
+
+ if (file->info_ptr >= info_ptr_end)
+ return NULL;
+
+ length = read_4_bytes (file->bfd_ptr, file->info_ptr, 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 (file->bfd_ptr, file->info_ptr + 4,
+ info_ptr_end);
+ file->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 (file->bfd_ptr, file->info_ptr + 4,
+ info_ptr_end);
+ file->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;
+ file->info_ptr += 4;
+ }
+
+ if (length != 0
+ && file->info_ptr + length <= info_ptr_end
+ && file->info_ptr + length > file->info_ptr)
+ {
+ struct comp_unit *each = parse_comp_unit (stash, file,
+ file->info_ptr, length,
+ info_ptr_unit, offset_size);
+ if (each)
+ {
+ if (file->all_comp_units)
+ file->all_comp_units->prev_unit = each;
+ else
+ file->last_comp_unit = each;
+
+ each->next_unit = file->all_comp_units;
+ file->all_comp_units = each;
+
+ file->info_ptr += length;
+ return each;
+ }
+ }
+
+ /* Don't trust any of the DWARF info after a corrupted length or
+ parse error. */
+ file->info_ptr = 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;
+}
+