bfd_cache_close_all ();
exec_file_attach (char *filename, int from_tty){  /* Remove any previous exec file.  */  unpush_target (&exec_ops);  /* Now open and digest the file the user requested, if any.  */  if (!filename)    {      if (from_tty)        printf_unfiltered ("No executable file now.\n");    }  else    {      char *scratch_pathname;      int scratch_chan;      scratch_chan = openp (getenv ("PATH"), 1, filename,		   write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0,			    &scratch_pathname);#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)      if (scratch_chan < 0)	{	  char *exename = alloca (strlen (filename) + 5);	  strcat (strcpy (exename, filename), ".exe");	  scratch_chan = openp (getenv ("PATH"), 1, exename, write_files ?	     O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0, &scratch_pathname);	}#endif      if (scratch_chan < 0)	perror_with_name (filename);      exec_bfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);      if (!exec_bfd)	error ("\"%s\": could not open as an executable file: %s",	       scratch_pathname, bfd_errmsg (bfd_get_error ()));      /* At this point, scratch_pathname and exec_bfd->name both point to the         same malloc'd string.  However exec_close() will attempt to free it         via the exec_bfd->name pointer, so we need to make another copy and         leave exec_bfd as the new owner of the original copy. */      scratch_pathname = xstrdup (scratch_pathname);      make_cleanup (xfree, scratch_pathname);      if (!bfd_check_format (exec_bfd, bfd_object))	{	  /* Make sure to close exec_bfd, or else "run" might try to use	     it.  */	  exec_close (0);	  error ("\"%s\": not in executable format: %s",		 scratch_pathname, bfd_errmsg (bfd_get_error ()));	}      /* FIXME - This should only be run for RS6000, but the ifdef is a poor         way to accomplish.  */#ifdef DEPRECATED_IBM6000_TARGET      /* Setup initial vmap. */      map_vmap (exec_bfd, 0);      if (vmap == NULL)	{	  /* Make sure to close exec_bfd, or else "run" might try to use	     it.  */	  exec_close (0);	  error ("\"%s\": can't find the file sections: %s",		 scratch_pathname, bfd_errmsg (bfd_get_error ()));	}#endif /* DEPRECATED_IBM6000_TARGET */      if (build_section_table (exec_bfd, &exec_ops.to_sections,			       &exec_ops.to_sections_end))	{	  /* Make sure to close exec_bfd, or else "run" might try to use	     it.  */	  exec_close (0);	  error ("\"%s\": can't find the file sections: %s",		 scratch_pathname, bfd_errmsg (bfd_get_error ()));	}#ifdef DEPRECATED_HPUX_TEXT_END      DEPRECATED_HPUX_TEXT_END (&exec_ops);#endif      validate_files ();      set_gdbarch_from_file (exec_bfd);      push_target (&exec_ops);      /* Tell display code (if any) about the changed file name.  */      if (exec_file_display_hook)	(*exec_file_display_hook) (filename);    }}