* gdb.java/configure.in (AC_INIT): Use jmisc.exp.
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index ebcdcd49d12fe747584ffa3804f8f0c0fd924d64..f1c70fa1ba76b5485a7683082af649494d83c97e 100644 (file)
 
 #if defined(USE_MMALLOC) && defined(HAVE_MMAP)
 
-static int
-open_existing_mapped_file PARAMS ((char *, long, int));
+static int open_existing_mapped_file (char *, long, int);
 
-static int
-open_mapped_file PARAMS ((char *filename, long mtime, int flags));
+static int open_mapped_file (char *filename, long mtime, int flags);
 
-static PTR
-  map_to_file PARAMS ((int));
+static PTR map_to_file (int);
 
 #endif /* defined(USE_MMALLOC) && defined(HAVE_MMAP) */
 
-static void
-add_to_objfile_sections PARAMS ((bfd *, sec_ptr, PTR));
+static void add_to_objfile_sections (bfd *, sec_ptr, PTR);
 
 /* Externally visible variables that are owned by this module.
    See declarations in objfile.h for more info. */
@@ -305,6 +301,14 @@ allocate_objfile (abfd, flags)
        }
     }
 
+  /* Initialize the section indexes for this objfile, so that we can
+     later detect if they are used w/o being properly assigned to. */
+
+    objfile->sect_index_text = -1;
+    objfile->sect_index_data = -1;
+    objfile->sect_index_bss = -1;
+    objfile->sect_index_rodata = -1;
+
   /* Add this file onto the tail of the linked list of other such files. */
 
   objfile->next = NULL;
@@ -370,9 +374,11 @@ unlink_objfile (objfile)
        {
          *objpp = (*objpp)->next;
          objfile->next = NULL;
-         break;
+         return;
        }
     }
+
+  internal_error ("objfiles.c (unlink_objfile): objfile already unlinked");
 }
 
 
@@ -436,17 +442,6 @@ free_objfile (objfile)
      is unknown, but we play it safe for now and keep each action until
      it is shown to be no longer needed. */
 
-#if defined (CLEAR_SOLIB)
-  CLEAR_SOLIB ();
-  /* CLEAR_SOLIB closes the bfd's for any shared libraries.  But
-     the to_sections for a core file might refer to those bfd's.  So
-     detach any core file.  */
-  {
-    struct target_ops *t = find_core_target ();
-    if (t != NULL)
-      (t->to_detach) (NULL, 0);
-  }
-#endif
   /* I *think* all our callers call clear_symtab_users.  If so, no need
      to call this here.  */
   clear_pc_function_cache ();
@@ -495,6 +490,17 @@ free_objfile (objfile)
     }
 }
 
+static void
+do_free_objfile_cleanup (void *obj)
+{
+  free_objfile (obj);
+}
+
+struct cleanup *
+make_cleanup_free_objfile (struct objfile *obj)
+{
+  return make_cleanup (do_free_objfile_cleanup, obj);
+}
 
 /* Free all the object files at once and clean up their users.  */
 
@@ -600,8 +606,8 @@ objfile_relocate (objfile, new_offsets)
 
     ALL_OBJFILE_PSYMTABS (objfile, p)
     {
-      p->textlow += ANOFFSET (delta, SECT_OFF_TEXT);
-      p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT);
+      p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
     }
   }
 
@@ -652,41 +658,41 @@ objfile_relocate (objfile, new_offsets)
 
        if (flags & SEC_CODE)
          {
-           s->addr += ANOFFSET (delta, SECT_OFF_TEXT);
-           s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT);
+           s->addr += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+           s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
          }
        else if (flags & (SEC_DATA | SEC_LOAD))
          {
-           s->addr += ANOFFSET (delta, SECT_OFF_DATA);
-           s->endaddr += ANOFFSET (delta, SECT_OFF_DATA);
+           s->addr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
+           s->endaddr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
          }
        else if (flags & SEC_ALLOC)
          {
-           s->addr += ANOFFSET (delta, SECT_OFF_BSS);
-           s->endaddr += ANOFFSET (delta, SECT_OFF_BSS);
+           s->addr += ANOFFSET (delta, SECT_OFF_BSS (objfile));
+           s->endaddr += ANOFFSET (delta, SECT_OFF_BSS (objfile));
          }
       }
   }
 
   if (objfile->ei.entry_point != ~(CORE_ADDR) 0)
-    objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT);
+    objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
 
   if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC)
     {
-      objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
-      objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+      objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
     }
 
   if (objfile->ei.entry_file_lowpc != INVALID_ENTRY_LOWPC)
     {
-      objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
-      objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+      objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
     }
 
   if (objfile->ei.main_func_lowpc != INVALID_ENTRY_LOWPC)
     {
-      objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
-      objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+      objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
     }
 
   /* Relocate breakpoints as necessary, after things are relocated. */
@@ -865,7 +871,7 @@ open_mapped_file (filename, mtime, flags)
     {
       free (symsfilename);
       symsfilename = concat (filename, ".syms", (char *) NULL);
-      fd = open_existing_mapped_file (symsfilename, mtime, mapped);
+      fd = open_existing_mapped_file (symsfilename, mtime, flags);
     }
 
   /* If we don't have an open file by now, then either the file does not
@@ -877,7 +883,7 @@ open_mapped_file (filename, mtime, flags)
      By default the file is rw for everyone, with the user's umask taking
      care of turning off the permissions the user wants off. */
 
-  if ((fd < 0) && mapped)
+  if ((fd < 0) && (flags & OBJF_MAPPED))
     {
       free (symsfilename);
       symsfilename = concat ("./", basename (filename), ".syms",
This page took 0.025597 seconds and 4 git commands to generate.