+ /* gdb_bfd_fopen does not support "target:" filenames. */
+ if (write_files)
+ warning (_("writing into executable files is "
+ "not supported for %s sysroots"),
+ TARGET_SYSROOT_PREFIX);
+
+ scratch_pathname = filename;
+ scratch_chan = -1;
+ canonical_pathname = scratch_pathname;
+ }
+ else
+ {
+ char *temp_pathname;
+
+ scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
+ filename, write_files ?
+ O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
+ &temp_pathname);
+#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
+ if (scratch_chan < 0)
+ {
+ char *exename = (char *) alloca (strlen (filename) + 5);
+
+ strcat (strcpy (exename, filename), ".exe");
+ scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
+ exename, write_files ?
+ O_RDWR | O_BINARY
+ : O_RDONLY | O_BINARY,
+ &temp_pathname);
+ }
+#endif
+ if (scratch_chan < 0)
+ perror_with_name (filename);
+
+ scratch_storage.reset (temp_pathname);
+ scratch_pathname = temp_pathname;
+
+ /* gdb_bfd_open (and its variants) prefers canonicalized
+ pathname for better BFD caching. */
+ canonical_storage = gdb_realpath (scratch_pathname);
+ canonical_pathname = canonical_storage.get ();