#include "gdbcmd.h"
#include "gdbcore.h"
#include "symfile.h"
+#include "objfiles.h"
#include "libbfd.h" /* BFD internals (sigh!) FIXME */
+#include "xcoffsolib.h"
/* Prototypes for local functions */
bfd *exec_bfd; /* needed by core.c */
extern char *getenv();
-extern void child_create_inferior (), child_attach ();
extern void add_syms_addr_command ();
extern void symbol_file_command ();
static void exec_files_info();
extern struct objfile *lookup_objfile_bfd ();
+#if 0
/*
* the vmap struct is used to describe the virtual address space of
* the target we are manipulating. The first entry is always the "exec"
};
static struct vmap *vmap; /* current vmap */
+#endif /* 0 */
+
+struct vmap *vmap; /* current vmap */
extern struct target_ops exec_ops;
struct objfile *obj;
vp = (void*) xmalloc (sizeof (*vp));
+ bzero (vp, sizeof (*vp));
vp->nxt = 0;
vp->bfd = bf;
vp->name = bfd_get_filename(arch ? arch : bf);
obj = lookup_objfile_bfd (bf);
if (exec_bfd && !obj) {
obj = allocate_objfile (bf, 0);
+
+#if 0
+ /* This is only needed if we want to load shared libraries no matter what.
+ Since we provide the choice of incremental loading of shared objects
+ now, we do not have to load them as default anymore. */
+
syms_from_objfile (obj, 0, 0, 0);
+ new_symfile_objfile (obj, 0, 0);
+#endif
}
/* find the end of the list, and append. */
}
-#define FASTER_MSYMBOL_RELOCATION 1
-
-#ifdef FASTER_MSYMBOL_RELOCATION
-
-/* Used to relocate an object file's minimal symbols. */
-
-static void
-reloc_objfile_msymbols (objf, addr)
-struct objfile *objf;
-CORE_ADDR addr;
-{
- register struct minimal_symbol *msymbol;
- int ii;
-
- for (msymbol = objf->msymbols, ii=0;
- msymbol && ii < objf->minimal_symbol_count; ++msymbol, ++ii)
-
- if (msymbol->address < TEXT_SEGMENT_BASE)
- msymbol->address += addr;
-}
-
-#else /* !FASTER_MSYMBOL_RELOCATION */
-
-/* Called via iterate_over_msymbols to relocate minimal symbols */
-
-static int
-relocate_minimal_symbol (objfile, msymbol, arg1, arg2, arg3)
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
- PTR arg1;
- PTR arg2;
- PTR arg3;
-{
- if (msymbol->address < TEXT_SEGMENT_BASE)
- msymbol -> address += (int) arg1;
-
- /* return 0, otherwise `iterate_over_msymbols()' will stop at the
- first iteration. */
- return 0;
-}
-#endif /* FASTER_MSYMBOL_RELOCATION */
-
/* true, if symbol table and minimal symbol table are relocated. */
int symtab_relocated = 0;
{
register struct symtab *s;
register struct objfile *objfile;
+ register struct minimal_symbol *msymbol;
/*
* for each symbol table generated from the vp->bfd
*/
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_OBJFILES (objfile)
{
for (s = objfile -> symtabs; s != NULL; s = s -> next) {
if (fstat(fileno(io), &si) < 0)
fatal("cannot fstat BFD for sym");
- if (si.st_dev != vip->st_dev
- || si.st_ino != vip->st_ino)
+ if (vip && (si.st_dev != vip->st_dev
+ || si.st_ino != vip->st_ino))
continue;
}
if (!s->nonreloc || LINETABLE(s))
vmap_symtab_1(s, vp, old_start);
-#ifdef FASTER_MSYMBOL_RELOCATION
- /* we can rely on the fact that at least one symtab in this objfile
- will get relocated. Thus, we can be sure that minimal symbol
- vector is guaranteed for relocation. */
+#if 0
+ Himm.., recently we nullified trampoline entry names in order not
+ to confuse them with real symbols. Appearently this turned into a
+ problem, and msymbol vector did not get relocated properly. If
+ msymbols have to have non-null names, then we should name
+ trampoline entries with empty strings.
- reloc_objfile_msymbols (objfile, vp->tstart - old_start);
+ ALL_MSYMBOLS (objfile, msymbol)
+#else
+ for (msymbol = objfile->msymbols;
+ msymbol->name || msymbol->address; (msymbol)++)
#endif
+ if (msymbol->address < TEXT_SEGMENT_BASE)
+ msymbol -> address += vp->tstart - old_start;
+
break;
}
}
}
if (vp->tstart != old_start) {
-#ifndef FASTER_MSYMBOL_RELOCATION
- (void) iterate_over_msymbols (relocate_minimal_symbol,
- (PTR) (vp->tstart - old_start),
- (PTR) NULL, (PTR) NULL);
-#endif
-
/* breakpoints need to be relocated as well. */
fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_start);
}
register char *mem, *objname;
/* This ldi structure was allocated using alloca() in
- aixcoff_relocate_symtab(). Now we need to have persistent object
+ xcoff_relocate_symtab(). Now we need to have persistent object
and member names, so we should save them. */
mem = ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1;
vmap_exec ()
{
static bfd *execbfd;
+ int i;
+
if (execbfd == exec_bfd)
return;
execbfd = exec_bfd;
- /* First exec section is `.text', second is `.data'. If this is changed,
- then this routine will choke. */
-
- if (!vmap || !exec_ops.to_sections ||
- strcmp (exec_ops.to_sections[0].sec_ptr->name, ".text") ||
- strcmp (exec_ops.to_sections[1].sec_ptr->name, ".data"))
+ if (!vmap || !exec_ops.to_sections)
+ error ("vmap_exec: vmap or exec_ops.to_sections == 0\n");
- fatal ("aix: Improper exec_ops sections.");
-
- exec_ops.to_sections [0].addr += vmap->tstart;
- exec_ops.to_sections [0].endaddr += vmap->tstart;
- exec_ops.to_sections [1].addr += vmap->dstart;
- exec_ops.to_sections [1].endaddr += vmap->dstart;
+ for (i=0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
+ {
+ if (strcmp(".text", exec_ops.to_sections[i].sec_ptr->name) == 0)
+ {
+ exec_ops.to_sections[i].addr += vmap->tstart;
+ exec_ops.to_sections[i].endaddr += vmap->tstart;
+ }
+ else if (strcmp(".data", exec_ops.to_sections[i].sec_ptr->name) == 0)
+ {
+ exec_ops.to_sections[i].addr += vmap->dstart;
+ exec_ops.to_sections[i].endaddr += vmap->dstart;
+ }
+ }
}
, name);
retry:
for (got_one = 0, vp = vmap; vp; vp = vp->nxt) {
- FILE *io;
+ FILE *io;
- /* The filenames are not always sufficient to match on. */
- if ((name[0] == "/"
- && !eq(name, vp->name))
- || (memb[0] && !eq(memb, vp->member)))
- continue;
+ /* First try to find a `vp', which is the same as in ldinfo.
+ If not the same, just continue and grep the next `vp'. If same,
+ relocate its tstart, tend, dstart, dend values. If no such `vp'
+ found, get out of this for loop, add this ldi entry as a new vmap
+ (add_vmap) and come back, fins its `vp' and so on... */
- /* totally opaque! */
- io = bfd_cache_lookup(vp->bfd);
- if (!io)
- fatal("cannot find BFD's iostream for %s"
- , vp->name);
+ /* The filenames are not always sufficient to match on. */
- /* see if we are referring to the same file */
- if (fstat(fileno(io), &vi) < 0)
- fatal("cannot fstat BFD for %s", vp->name);
+ if ((name[0] == "/" && !eq(name, vp->name))
+ || (memb[0] && !eq(memb, vp->member)))
+ continue;
- if (ii.st_dev != vi.st_dev || ii.st_ino != vi.st_ino)
- continue;
+ io = bfd_cache_lookup(vp->bfd); /* totally opaque! */
+ if (!io)
+ fatal("cannot find BFD's iostream for %s", vp->name);
- if (!retried)
- close(ldi->ldinfo_fd);
+ /* see if we are referring to the same file */
- ++got_one;
+ if (fstat(fileno(io), &vi) < 0)
+ fatal("cannot fstat BFD for %s", vp->name);
- /* found a corresponding VMAP. remap! */
- ostart = vp->tstart;
+ if (ii.st_dev != vi.st_dev || ii.st_ino != vi.st_ino)
+ continue;
- vp->tstart = ldi->ldinfo_textorg;
- vp->tend = vp->tstart + ldi->ldinfo_textsize;
- vp->dstart = ldi->ldinfo_dataorg;
- vp->dend = vp->dstart + ldi->ldinfo_datasize;
+ if (!retried)
+ close(ldi->ldinfo_fd);
- if (vp->tadj) {
- vp->tstart += vp->tadj;
- vp->tend += vp->tadj;
- }
+ ++got_one;
- /* relocate symbol table(s). */
- vmap_symtab(vp, ostart, &vi);
+ /* found a corresponding VMAP. remap! */
+ ostart = vp->tstart;
- /* there may be more, so we don't break out of the loop. */
+ vp->tstart = ldi->ldinfo_textorg;
+ vp->tend = vp->tstart + ldi->ldinfo_textsize;
+ vp->dstart = ldi->ldinfo_dataorg;
+ vp->dend = vp->dstart + ldi->ldinfo_datasize;
+
+ if (vp->tadj) {
+ vp->tstart += vp->tadj;
+ vp->tend += vp->tadj;
+ }
+
+ /* relocate symbol table(s). */
+ vmap_symtab(vp, ostart, &vi);
+
+ /* there may be more, so we don't break out of the loop. */
}
- /*
- * if there was no matching *vp, we must perforce create
- * the sucker(s)
- */
- if (!got_one && !retried) {
- add_vmap(ldi);
- ++retried;
- goto retry;
+ /* if there was no matching *vp, we must perforce create the sucker(s) */
+ if (!got_one && !retried) {
+ add_vmap(ldi);
+ ++retried;
+ goto retry;
}
} while (ldi->ldinfo_next
&& (ldi = (void *) (ldi->ldinfo_next + (char *) ldi)));
if (!vp)
return;
- printf("\n\tMapping info for file `%s'.\n", vp->name);
- printf("\t %8.8s %8.8s %8.8s %s\n",
- "start", "end", "section", "file(member)");
+ printf("\tMapping info for file `%s'.\n", vp->name);
+
+ printf("\t %8.8s %8.8s %8.8s %8.8s %8.8s %s\n",
+ "tstart", "tend", "dstart", "dend", "section", "file(member)");
for (; vp; vp = vp->nxt)
- printf("\t0x%8.8x 0x%8.8x %s%s%s%s\n",
- vp->tstart,
- vp->tend,
- vp->name,
- vp->member ? "(" : "",
- vp->member,
- vp->member ? ")" : "");
+ printf("\t0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x %s%s%s%s\n",
+ vp->tstart,
+ vp->tend,
+ vp->dstart,
+ vp->dend,
+ vp->name,
+ *vp->member ? "(" : "",
+ vp->member,
+ *vp->member ? ")" : "");
}
#ifdef DAMON
"Use an executable file as a target.\n\
Specify the filename of the executable file.",
exec_file_command, exec_close, /* open, close */
- child_attach, 0, 0, 0, /* attach, detach, resume, wait, */
+ find_default_attach, 0, 0, 0, /* attach, detach, resume, wait, */
0, 0, /* fetch_registers, store_registers, */
- 0, 0, 0, /* prepare_to_store, conv_to, conv_from, */
+ 0, /* prepare_to_store */
xfer_memory, exec_files_info,
0, 0, /* insert_breakpoint, remove_breakpoint, */
0, 0, 0, 0, 0, /* terminal stuff */
0, 0, /* kill, load */
0, /* lookup sym */
- child_create_inferior,
+ find_default_create_inferior,
0, /* mourn_inferior */
+ 0, /* can_run */
file_stratum, 0, /* next */
0, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */
0, 0, /* section pointers */