/* 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.
#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 */
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.
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);
}
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
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);
}
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;
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;