* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index 22c96ed27d78103379fdc5ce2096f2ff90cbe063..caa595c04d1e2026fd8d5585eced6c169b262e43 100644 (file)
@@ -1,5 +1,5 @@
 /* GDB routines for manipulating objfiles.
-   Copyright 1992 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
 This file is part of GDB.
@@ -49,16 +49,13 @@ map_to_address PARAMS ((void));
 
 #endif  /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
 
-/* Message to be printed before the error message, when an error occurs.  */
-
-extern char *error_pre_print;
-
 /* Externally visible variables that are owned by this module.
    See declarations in objfile.h for more info. */
 
 struct objfile *object_files;          /* Linked list of all objfiles */
 struct objfile *current_objfile;       /* For symbol file being read in */
 struct objfile *symfile_objfile;       /* Main symbol table loaded from */
+struct objfile *rt_common_objfile;     /* For runtime common symbols */
 
 int mapped_symbol_files;               /* Try to use mapped symbol files */
 
@@ -273,6 +270,27 @@ allocate_objfile (abfd, mapped)
   return (objfile);
 }
 
+/* Put OBJFILE at the front of the list.  */
+
+void
+objfile_to_front (objfile)
+     struct objfile *objfile;
+{
+  struct objfile **objp;
+  for (objp = &object_files; *objp != NULL; objp = &((*objp)->next))
+    {
+      if (*objp == objfile)
+       {
+         /* Unhook it from where it is.  */
+         *objp = objfile->next;
+         /* Put it in the front.  */
+         objfile->next = object_files;
+         object_files = objfile;
+         break;
+       }
+    }
+}
+
 /* Unlink OBJFILE from the list of known objfiles, if it is found in the
    list.
 
@@ -341,7 +359,9 @@ free_objfile (objfile)
   if (objfile -> obfd != NULL)
     {
       char *name = bfd_get_filename (objfile->obfd);
-      bfd_close (objfile -> obfd);
+      if (!bfd_close (objfile -> obfd))
+       warning ("cannot close \"%s\": %s",
+                name, bfd_errmsg (bfd_get_error ()));
       free (name);
     }
 
@@ -349,6 +369,12 @@ free_objfile (objfile)
 
   unlink_objfile (objfile);
 
+  /* If we are going to free the runtime common objfile, mark it
+     as unallocated.  */
+
+  if (objfile == rt_common_objfile)
+    rt_common_objfile = NULL;
+
   /* Before the symbol table code was redone to make it easier to
      selectively load and remove information particular to a specific
      linkage unit, gdb used to do these things whenever the monolithic
@@ -519,10 +545,6 @@ objfile_relocate (objfile, new_offsets)
 
     ALL_OBJFILE_PSYMTABS (objfile, p)
       {
-       /* FIXME: specific to symbol readers which use gdb-stabs.h.
-          We can only get away with it since objfile_relocate is only
-          used on XCOFF, which lacks psymtabs, and for gdb-stabs.h
-          targets.  */
        p->textlow += ANOFFSET (delta, SECT_OFF_TEXT);
        p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT);
       }
@@ -549,6 +571,9 @@ objfile_relocate (objfile, new_offsets)
       if (SYMBOL_SECTION (msym) >= 0)
        SYMBOL_VALUE_ADDRESS (msym) += ANOFFSET (delta, SYMBOL_SECTION (msym));
   }
+  /* Relocating different sections by different amounts may cause the symbols
+     to be out of order.  */
+  msymbols_sort (objfile);
 
   {
     int i;
@@ -560,10 +585,10 @@ objfile_relocate (objfile, new_offsets)
     struct obj_section *s;
     bfd *abfd;
 
-    abfd = symfile_objfile->obfd;
+    abfd = objfile->obfd;
 
-    for (s = symfile_objfile->sections;
-        s < symfile_objfile->sections_end; ++s)
+    for (s = objfile->sections;
+        s < objfile->sections_end; ++s)
       {
        flagword flags;
 
This page took 0.024272 seconds and 4 git commands to generate.