+/* Total size required for common symbols in ABFD. */
+
+static void
+calculate_common_size (bfd *abfd)
+{
+ asymbol **syms = NULL;
+ long storage, symcount;
+
+ common_size = 0;
+ if ((bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC | HAS_SYMS)) != HAS_SYMS)
+ return;
+
+ storage = bfd_get_symtab_upper_bound (abfd);
+ if (storage < 0)
+ bfd_fatal (bfd_get_filename (abfd));
+ if (storage)
+ syms = (asymbol **) xmalloc (storage);
+
+ symcount = bfd_canonicalize_symtab (abfd, syms);
+ if (symcount < 0)
+ bfd_fatal (bfd_get_filename (abfd));
+
+ while (--symcount >= 0)
+ {
+ asymbol *sym = syms[symcount];
+
+ if (bfd_is_com_section (sym->section)
+ && (sym->flags & BSF_SECTION_SYM) == 0)
+ common_size += sym->value;
+ }
+ free (syms);
+}
+