+/* Factored out from ecoff_link_check_archive_element. */
+
+static bfd_boolean
+read_ext_syms_and_strs (HDRR **symhdr, bfd_size_type *external_ext_size,
+ bfd_size_type *esize, void **external_ext, char **ssext, bfd *abfd,
+ const struct ecoff_backend_data * const backend)
+{
+ if (! ecoff_slurp_symbolic_header (abfd))
+ return FALSE;
+
+ /* If there are no symbols, we don't want it. */
+ if (bfd_get_symcount (abfd) == 0)
+ return TRUE;
+
+ *symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
+
+ *external_ext_size = backend->debug_swap.external_ext_size;
+ *esize = (*symhdr)->iextMax * *external_ext_size;
+ *external_ext = bfd_malloc (*esize);
+ if (*external_ext == NULL && *esize != 0)
+ return FALSE;
+
+ if (bfd_seek (abfd, (file_ptr) (*symhdr)->cbExtOffset, SEEK_SET) != 0
+ || bfd_bread (*external_ext, *esize, abfd) != *esize)
+ return FALSE;
+
+ *ssext = (char *) bfd_malloc ((bfd_size_type) (*symhdr)->issExtMax);
+ if (*ssext == NULL && (*symhdr)->issExtMax != 0)
+ return FALSE;
+
+ if (bfd_seek (abfd, (file_ptr) (*symhdr)->cbSsExtOffset, SEEK_SET) != 0
+ || (bfd_bread (*ssext, (bfd_size_type) (*symhdr)->issExtMax, abfd)
+ != (bfd_size_type) (*symhdr)->issExtMax))
+ return FALSE;
+ return TRUE;
+}
+
+static bfd_boolean
+reread_ext_syms_and_strs (HDRR **symhdr, bfd_size_type *external_ext_size,
+ bfd_size_type *esize, void **external_ext, char **ssext, bfd *abfd,
+ const struct ecoff_backend_data * const backend)
+{
+ if (*external_ext != NULL)
+ free (*external_ext);
+ *external_ext = NULL;
+ if (*ssext != NULL)
+ free (*ssext);
+ *ssext = NULL;
+ return read_ext_syms_and_strs (symhdr, external_ext_size, esize,
+ external_ext, ssext, abfd, backend);
+}
+