{
register struct vmap *vp, *nxt;
struct objfile *obj;
+ int need_symtab_cleanup = 0;
for (nxt = vmap; vp = nxt; )
{
free_objfile() will do proper cleanup of objfile *and* bfd. */
if (vp->objfile)
- free_objfile (vp->objfile);
+ {
+ free_objfile (vp->objfile);
+ need_symtab_cleanup = 1;
+ }
else
bfd_close(vp->bfd);
exec_ops.to_sections = NULL;
exec_ops.to_sections_end = NULL;
}
+
+ if (need_symtab_cleanup)
+ clear_symtab_users ();
}
/*
if (scratch_chan < 0)
perror_with_name(filename);
- exec_bfd = bfd_fdopenr(scratch_pathname, NULL, scratch_chan);
+ exec_bfd = bfd_fdopenr(scratch_pathname, gnutarget, scratch_chan);
if (!exec_bfd)
error("Could not open `%s' as an executable file: %s"
, scratch_pathname, bfd_errmsg(bfd_error));
struct objfile *obj;
vp = (void*) xmalloc (sizeof (*vp));
- bzero (vp, sizeof (*vp));
+ memset (vp, '\0', sizeof (*vp));
vp->nxt = 0;
vp->bfd = bf;
vp->name = bfd_get_filename(arch ? arch : bf);
asection *textsec;
asection *datasec;
asection *bsssec;
- CORE_ADDR old_text_offset;
+ CORE_ADDR text_delta;
+ CORE_ADDR data_delta;
+ CORE_ADDR bss_delta;
struct section_offsets *new_offsets;
int i;
ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i);
textsec = bfd_get_section_by_name (vp->bfd, ".text");
- old_text_offset = ANOFFSET (objfile->section_offsets, textsec->target_index);
+ text_delta =
+ vp->tstart - ANOFFSET (objfile->section_offsets, textsec->target_index);
ANOFFSET (new_offsets, textsec->target_index) = vp->tstart;
+
datasec = bfd_get_section_by_name (vp->bfd, ".data");
+ data_delta =
+ vp->dstart - ANOFFSET (objfile->section_offsets, datasec->target_index);
ANOFFSET (new_offsets, datasec->target_index) = vp->dstart;
+
bsssec = bfd_get_section_by_name (vp->bfd, ".bss");
+ bss_delta =
+ vp->dstart - ANOFFSET (objfile->section_offsets, bsssec->target_index);
ANOFFSET (new_offsets, bsssec->target_index) = vp->dstart;
objfile_relocate (objfile, new_offsets);
+
+ {
+ struct obj_section *s;
+ for (s = objfile->sections; s < objfile->sections_end; ++s)
+ {
+ if (s->sec_ptr->target_index == textsec->target_index)
+ {
+ s->addr += text_delta;
+ s->endaddr += text_delta;
+ }
+ else if (s->sec_ptr->target_index == datasec->target_index)
+ {
+ s->addr += data_delta;
+ s->endaddr += data_delta;
+ }
+ else if (s->sec_ptr->target_index == bsssec->target_index)
+ {
+ s->addr += bss_delta;
+ s->endaddr += bss_delta;
+ }
+ }
+ }
- if (old_text_offset != ANOFFSET (new_offsets, textsec->target_index))
+ if (text_delta != 0)
/* breakpoints need to be relocated as well. */
- fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_text_offset);
+ fixup_breakpoints (0, TEXT_SEGMENT_BASE, text_delta);
}
/* Add symbols for an objfile. */
if (ldi->ldinfo_fd < 0)
/* Note that this opens it once for every member; a possible
enhancement would be to only open it once for every object. */
- bfd = bfd_openr (objname, NULL);
+ bfd = bfd_openr (objname, gnutarget);
else
- bfd = bfd_fdopenr(objname, NULL, ldi->ldinfo_fd);
+ bfd = bfd_fdopenr(objname, gnutarget, ldi->ldinfo_fd);
if (!bfd)
error("Could not open `%s' as an executable file: %s",
objname, bfd_errmsg(bfd_error));
#ifndef SOLIB_SYMBOLS_MANUAL
if (catch_errors (objfile_symbol_add, (char *)obj,
- "Error while reading shared library symbols:\n"))
+ "Error while reading shared library symbols:\n",
+ RETURN_MASK_ALL))
{
/* Note this is only done if symbol reading was successful. */
vmap_symtab (vp);
printf_filtered ("file type %s.\n", bfd_get_target(abfd));
for (p = t->to_sections; p < t->to_sections_end; p++) {
- printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
- printf_filtered (" - %s", local_hex_string_custom (p->endaddr, "08"));
+ printf_filtered ("\t%s",
+ local_hex_string_custom ((unsigned long) p->addr, "08l"));
+ printf_filtered (" - %s",
+ local_hex_string_custom ((unsigned long) p->endaddr, "08l"));
if (info_verbose)
printf_filtered (" @ %s",
- local_hex_string_custom (p->sec_ptr->filepos, "08"));
+ local_hex_string_custom ((unsigned long) p->sec_ptr->filepos, "08l"));
printf_filtered (" is %s", bfd_section_name (p->bfd, p->sec_ptr));
if (p->bfd != abfd) {
printf_filtered (" in %s", bfd_get_filename (p->bfd));