(bfd_window *);
 extern bool bfd_get_file_window
   (bfd *, file_ptr, bfd_size_type, bfd_window *, bool);
-\f
-/* Externally visible ELF routines.  */
-
-/* Create a new BFD as if by bfd_openr.  Rather than opening a file,
-   reconstruct an ELF file by reading the segments out of remote
-   memory based on the ELF file header at EHDR_VMA and the ELF program
-   headers it points to.  If non-zero, SIZE is the known extent of the
-   object.  If not null, *LOADBASEP is filled in with the difference
-   between the VMAs from which the segments were read, and the VMAs
-   the file headers (and hence BFD's idea of each section's VMA) put
-   them at.
-
-   The function TARGET_READ_MEMORY is called to copy LEN bytes from
-   the remote memory at target address VMA into the local buffer at
-   MYADDR; it should return zero on success or an `errno' code on
-   failure.  TEMPL must be a BFD for a target with the word size and
-   byte order found in the remote memory.  */
-extern bfd *bfd_elf_bfd_from_remote_memory
-  (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
-                             bfd_size_type len));
-
 /* Forward declarations.  */
 struct ecoff_debug_info;
 struct ecoff_debug_swap;
 
   (bfd_window *);
 extern bool bfd_get_file_window
   (bfd *, file_ptr, bfd_size_type, bfd_window *, bool);
-\f
-/* Externally visible ELF routines.  */
-
-/* Create a new BFD as if by bfd_openr.  Rather than opening a file,
-   reconstruct an ELF file by reading the segments out of remote
-   memory based on the ELF file header at EHDR_VMA and the ELF program
-   headers it points to.  If non-zero, SIZE is the known extent of the
-   object.  If not null, *LOADBASEP is filled in with the difference
-   between the VMAs from which the segments were read, and the VMAs
-   the file headers (and hence BFD's idea of each section's VMA) put
-   them at.
-
-   The function TARGET_READ_MEMORY is called to copy LEN bytes from
-   the remote memory at target address VMA into the local buffer at
-   MYADDR; it should return zero on success or an `errno' code on
-   failure.  TEMPL must be a BFD for a target with the word size and
-   byte order found in the remote memory.  */
-extern bfd *bfd_elf_bfd_from_remote_memory
-  (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
-                             bfd_size_type len));
-
 /* Forward declarations.  */
 struct ecoff_debug_info;
 struct ecoff_debug_swap;
 
 bfd *bfd_openw (const char *filename, const char *target);
 
+bfd *bfd_elf_bfd_from_remote_memory
+   (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
+    int (*target_read_memory)
+       (bfd_vma vma, bfd_byte *myaddr, bfd_size_type len));
+
 bool bfd_close (bfd *abfd);
 
 bool bfd_close_all_done (bfd *);
 
     }
 }
 \f
-/* Create a new BFD as if by bfd_openr.  Rather than opening a file,
-   reconstruct an ELF file by reading the segments out of remote memory
-   based on the ELF file header at EHDR_VMA and the ELF program headers it
-   points to.  If not null, *LOADBASEP is filled in with the difference
-   between the VMAs from which the segments were read, and the VMAs the
-   file headers (and hence BFD's idea of each section's VMA) put them at.
-
-   The function TARGET_READ_MEMORY is called to copy LEN bytes from the
-   remote memory at target address VMA into the local buffer at MYADDR; it
-   should return zero on success or an `errno' code on failure.  TEMPL must
-   be a BFD for an ELF target with the word size and byte order found in
-   the remote memory.  */
-
-bfd *
-bfd_elf_bfd_from_remote_memory
-  (bfd *templ,
-   bfd_vma ehdr_vma,
-   bfd_size_type size,
-   bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type))
-{
-  return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory)
-    (templ, ehdr_vma, size, loadbasep, target_read_memory);
-}
-\f
 long
 _bfd_elf_get_synthetic_symtab (bfd *abfd,
                               long symcount ATTRIBUTE_UNUSED,
 
   return nbfd;
 }
 
+/*
+FUNCTION
+       bfd_elf_bfd_from_remote_memory
+
+SYNOPSIS
+       bfd *bfd_elf_bfd_from_remote_memory
+         (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
+          int (*target_read_memory)
+            (bfd_vma vma, bfd_byte *myaddr, bfd_size_type len));
+
+DESCRIPTION
+       Create a new BFD as if by bfd_openr.  Rather than opening a
+       file, reconstruct an ELF file by reading the segments out of
+       remote memory based on the ELF file header at EHDR_VMA and the
+       ELF program headers it points to.  If non-zero, SIZE is the
+       known extent of the object.  If not null, *LOADBASEP is filled
+       in with the difference between the VMAs from which the
+       segments were read, and the VMAs the file headers (and hence
+       BFD's idea of each section's VMA) put them at.
+
+       The function TARGET_READ_MEMORY is called to copy LEN bytes
+       from the remote memory at target address VMA into the local
+       buffer at MYADDR; it should return zero on success or an
+       errno code on failure.  TEMPL must be a BFD for an ELF
+       target with the word size and byte order found in the remote
+       memory.
+*/
+
+bfd *
+bfd_elf_bfd_from_remote_memory
+  (bfd *templ,
+   bfd_vma ehdr_vma,
+   bfd_size_type size,
+   bfd_vma *loadbasep,
+   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type))
+{
+  if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return NULL;
+    }
+  return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory)
+    (templ, ehdr_vma, size, loadbasep, target_read_memory);
+}
+
 static inline void
 _maybe_make_executable (bfd * abfd)
 {