+static int
+open_symbol_file_object (from_ttyp)
+ int *from_ttyp; /* sneak past catch_errors */
+{
+ CORE_ADDR lm;
+ struct link_map lmcopy;
+ char *filename;
+ int errcode;
+
+ if (symfile_objfile)
+ if (!query ("Attempt to reload symbols from process? "))
+ return 0;
+
+ if ((debug_base = locate_base ()) == 0)
+ return 0; /* failed somehow... */
+
+ /* First link map member should be the executable. */
+ if ((lm = first_link_map_member ()) == 0)
+ return 0; /* failed somehow... */
+
+ /* Read from target memory to GDB. */
+ read_memory (lm, (void *) &lmcopy, sizeof (lmcopy));
+
+ if (lmcopy.l_name == 0)
+ return 0; /* no filename. */
+
+ /* Now fetch the filename from target memory. */
+ target_read_string (SOLIB_EXTRACT_ADDRESS (lmcopy.l_name), &filename,
+ MAX_PATH_SIZE - 1, &errcode);
+ if (errcode)
+ {
+ warning ("failed to read exec filename from attached file: %s",
+ safe_strerror (errcode));
+ return 0;
+ }
+
+ make_cleanup (free, filename);
+ /* Have a pathname: read the symbol file. */
+ symbol_file_command (filename, *from_ttyp);
+
+ return 1;
+}
+#endif /* SVR4_SHARED_LIBS */
+
+
+/* LOCAL FUNCTION
+
+ free_so --- free a `struct so_list' object
+
+ SYNOPSIS
+
+ void free_so (struct so_list *so)
+
+ DESCRIPTION
+
+ Free the storage associated with the `struct so_list' object SO.
+ If we have opened a BFD for SO, close it.
+
+ The caller is responsible for removing SO from whatever list it is
+ a member of. If we have placed SO's sections in some target's
+ section table, the caller is responsible for removing them.
+
+ This function doesn't mess with objfiles at all. If there is an
+ objfile associated with SO that needs to be removed, the caller is
+ responsible for taking care of that. */
+
+static void
+free_so (struct so_list *so)
+{
+ char *bfd_filename = 0;
+
+ if (so->sections)
+ free (so->sections);
+
+ if (so->abfd)
+ {
+ bfd_filename = bfd_get_filename (so->abfd);
+ if (! bfd_close (so->abfd))
+ warning ("cannot close \"%s\": %s",
+ bfd_filename, bfd_errmsg (bfd_get_error ()));
+ }
+
+ if (bfd_filename)
+ free (bfd_filename);
+
+ free (so);
+}
+
+
+/* On some systems, the only way to recognize the link map entry for
+ the main executable file is by looking at its name. Return
+ non-zero iff SONAME matches one of the known main executable names. */
+
+static int
+match_main (soname)
+ char *soname;
+{
+ char **mainp;
+
+ for (mainp = main_name_list; *mainp != NULL; mainp++)
+ {
+ if (strcmp (soname, *mainp) == 0)
+ return (1);
+ }
+
+ return (0);
+}
+
+
+/* LOCAL FUNCTION
+
+ current_sos -- build a list of currently loaded shared objects
+
+ SYNOPSIS
+
+ struct so_list *current_sos ()
+
+ DESCRIPTION
+
+ Build a list of `struct so_list' objects describing the shared
+ objects currently loaded in the inferior. This list does not
+ include an entry for the main executable file.
+
+ Note that we only gather information directly available from the
+ inferior --- we don't examine any of the shared library files
+ themselves. The declaration of `struct so_list' says which fields
+ we provide values for. */
+