count = bfd_count_sections (some_bfd);
if (count == 0)
- abort(); /* return 1? */
+ fatal ("aborting"); /* return 1? */
if (*start)
free (*start);
*start = (struct section_table *) xmalloc (count * sizeof (**start));
*end = *start;
bfd_map_over_sections (some_bfd, add_to_section_table, (char *)end);
if (*end > *start + count)
- abort();
+ fatal ("aborting");
/* We could realloc the table, but it probably loses for most files. */
return 0;
}
\f
void
-sex_to_vmap(bfd *bf, sec_ptr sex, struct vmap_and_bfd *vmap_bfd)
+sex_to_vmap(bfd *bf, sec_ptr sex, PTR arg3)
{
+ struct vmap_and_bfd *vmap_bfd = (struct vmap_and_bfd *)arg3;
register struct vmap *vp, **vpp;
register struct symtab *syms;
bfd *arch = vmap_bfd->pbfd;
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. */
/* found a corresponding VMAP. remap! */
ostart = vp->tstart;
- vp->tstart = ldi->ldinfo_textorg;
+ /* We can assume pointer == CORE_ADDR, this code is native only. */
+ vp->tstart = (CORE_ADDR) ldi->ldinfo_textorg;
vp->tend = vp->tstart + ldi->ldinfo_textsize;
- vp->dstart = ldi->ldinfo_dataorg;
+ vp->dstart = (CORE_ADDR) ldi->ldinfo_dataorg;
vp->dend = vp->dstart + ldi->ldinfo_datasize;
if (vp->tadj) {
boolean (*xfer_fn) PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
if (len <= 0)
- abort();
+ fatal ("aborting");
memend = memaddr + len;
xfer_fn = write? bfd_set_section_contents: bfd_get_section_contents;
int offset = 0;
struct ld_info *ldip;
struct vmap *vp;
-
+
/* Allocated size of buffer. */
int buffer_size = LDINFO_SIZE;
char *buffer = xmalloc (buffer_size);
struct cleanup *old = make_cleanup (free_current_contents, &buffer);
+ /* FIXME, this restriction should not exist. For now, though I'll
+ avoid coredumps with error() pending a real fix. */
+ if (vmap == NULL)
+ error
+ ("Can't debug a core file without an executable file (on the RS/6000)");
+
ldinfo_sec = bfd_get_section_by_name (core_bfd, ".ldinfo");
if (ldinfo_sec == NULL)
{
offset += ldip->ldinfo_next;
- vp->tstart = ldip->ldinfo_textorg;
+ /* We can assume pointer == CORE_ADDR, this code is native only. */
+ vp->tstart = (CORE_ADDR) ldip->ldinfo_textorg;
vp->tend = vp->tstart + ldip->ldinfo_textsize;
- vp->dstart = ldip->ldinfo_dataorg;
+ vp->dstart = (CORE_ADDR) ldip->ldinfo_dataorg;
vp->dend = vp->dstart + ldip->ldinfo_datasize;
if (vp->tadj != 0) {
vmap_symtab (vp);
- add_text_to_loadinfo (ldip->ldinfo_textorg, ldip->ldinfo_dataorg);
+ add_text_to_loadinfo ((CORE_ADDR)ldip->ldinfo_textorg,
+ (CORE_ADDR)ldip->ldinfo_dataorg);
} while (ldip->ldinfo_next != 0);
vmap_exec ();
do_cleanups (old);