static struct objfile * get_dynamics_objfile (struct gdbarch *gdbarch) { struct objfile *dynamics_objfile; dynamics_objfile = program_space_data (current_program_space, jv_dynamics_progspace_key); if (dynamics_objfile == NULL) { struct jv_per_objfile_data *data; /* Mark it as shared so that it is cleared when the inferior is re-run. */ dynamics_objfile = allocate_objfile (NULL, NULL, OBJF_SHARED | OBJF_NOT_FILENAME); dynamics_objfile->per_bfd->gdbarch = gdbarch; data = XCNEW (struct jv_per_objfile_data); set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key, data); set_program_space_data (current_program_space, jv_dynamics_progspace_key, dynamics_objfile); } return dynamics_objfile; }
static struct objfile * get_dynamics_objfile (void) { if (dynamics_objfile == NULL) { dynamics_objfile = allocate_objfile (NULL, 0); } return dynamics_objfile; }
static struct vmap * add_vmap (LdInfo *ldi) { bfd *abfd, *last; char *mem, *objname, *filename; struct objfile *obj; struct vmap *vp; int fd; ARCH64_DECL (arch64); /* This ldi structure was allocated using alloca() in xcoff_relocate_symtab(). Now we need to have persistent object and member names, so we should save them. */ filename = LDI_FILENAME (ldi, arch64); mem = filename + strlen (filename) + 1; mem = xstrdup (mem); objname = xstrdup (filename); fd = LDI_FD (ldi, arch64); if (fd < 0) /* Note that this opens it once for every member; a possible enhancement would be to only open it once for every object. */ abfd = bfd_openr (objname, gnutarget); else abfd = bfd_fdopenr (objname, gnutarget, fd); if (!abfd) { warning (_("Could not open `%s' as an executable file: %s"), objname, bfd_errmsg (bfd_get_error ())); return NULL; } /* make sure we have an object file */ if (bfd_check_format (abfd, bfd_object)) vp = map_vmap (abfd, 0); else if (bfd_check_format (abfd, bfd_archive)) { last = 0; /* FIXME??? am I tossing BFDs? bfd? */ while ((last = bfd_openr_next_archived_file (abfd, last))) if (strcmp (mem, last->filename) == 0) break; if (!last) { warning (_("\"%s\": member \"%s\" missing."), objname, mem); bfd_close (abfd); return NULL; } if (!bfd_check_format (last, bfd_object)) { warning (_("\"%s\": member \"%s\" not in executable format: %s."), objname, mem, bfd_errmsg (bfd_get_error ())); bfd_close (last); bfd_close (abfd); return NULL; } vp = map_vmap (last, abfd); } else { warning (_("\"%s\": not in executable format: %s."), objname, bfd_errmsg (bfd_get_error ())); bfd_close (abfd); return NULL; } obj = allocate_objfile (vp->bfd, 0); vp->objfile = obj; /* Always add symbols for the main objfile. */ if (vp == vmap || auto_solib_add) vmap_add_symbols (vp); return vp; }
static struct vmap * add_vmap (LdInfo *ldi) { bfd *abfd, *last; char *mem, *filename; struct objfile *obj; struct vmap *vp; int fd; ARCH64_DECL (arch64); /* This ldi structure was allocated using alloca() in xcoff_relocate_symtab(). Now we need to have persistent object and member names, so we should save them. */ filename = LDI_FILENAME (ldi, arch64); mem = filename + strlen (filename) + 1; mem = xstrdup (mem); fd = LDI_FD (ldi, arch64); abfd = gdb_bfd_open (filename, gnutarget, fd < 0 ? -1 : fd); if (!abfd) { warning (_("Could not open `%s' as an executable file: %s"), filename, bfd_errmsg (bfd_get_error ())); return NULL; } /* Make sure we have an object file. */ if (bfd_check_format (abfd, bfd_object)) vp = map_vmap (abfd, 0); else if (bfd_check_format (abfd, bfd_archive)) { last = gdb_bfd_openr_next_archived_file (abfd, NULL); while (last != NULL) { bfd *next; if (strcmp (mem, last->filename) == 0) break; next = gdb_bfd_openr_next_archived_file (abfd, last); gdb_bfd_unref (last); last = next; } if (!last) { warning (_("\"%s\": member \"%s\" missing."), filename, mem); gdb_bfd_unref (abfd); return NULL; } if (!bfd_check_format (last, bfd_object)) { warning (_("\"%s\": member \"%s\" not in executable format: %s."), filename, mem, bfd_errmsg (bfd_get_error ())); gdb_bfd_unref (last); gdb_bfd_unref (abfd); return NULL; } vp = map_vmap (last, abfd); /* map_vmap acquired a reference to LAST, so we can release ours. */ gdb_bfd_unref (last); } else { warning (_("\"%s\": not in executable format: %s."), filename, bfd_errmsg (bfd_get_error ())); gdb_bfd_unref (abfd); return NULL; } obj = allocate_objfile (vp->bfd, 0); vp->objfile = obj; /* Always add symbols for the main objfile. */ if (vp == vmap || auto_solib_add) vmap_add_symbols (vp); /* Anything needing a reference to ABFD has already acquired it, so release our local reference. */ gdb_bfd_unref (abfd); return vp; }