diff options
author | David Edelsohn <dje.gcc@gmail.com> | 1997-04-17 10:23:48 +0000 |
---|---|---|
committer | David Edelsohn <dje.gcc@gmail.com> | 1997-04-17 10:23:48 +0000 |
commit | 9d52bcb7f0d1533fffd0c950438386e840dcaf01 (patch) | |
tree | c8067f2d8a1e1a49c7485b24ba2175dd1f35514e /sim/mips | |
parent | 463372706f4bf9fe4693d455217496a1f1b8aeb6 (diff) | |
download | gdb-9d52bcb7f0d1533fffd0c950438386e840dcaf01.zip gdb-9d52bcb7f0d1533fffd0c950438386e840dcaf01.tar.gz gdb-9d52bcb7f0d1533fffd0c950438386e840dcaf01.tar.bz2 |
* Makefile.in (SIM_OBJS): Add sim-load.o.
* interp.c: #include bfd.h.
(target_byte_order): Delete.
(sim_kind, myname, big_endian_p): New static locals.
(sim_open): Set sim_kind, myname. Move call to set_endianness to
after argument parsing. Recognize -E arg, set endianness accordingly.
(sim_load): Return SIM_RC. New arg abfd. Call sim_load_file to
load file into simulator. Set PC from bfd.
(sim_create_inferior): Return SIM_RC. Delete arg start_address.
(set_endianness): Use big_endian_p instead of target_byte_order.
Diffstat (limited to 'sim/mips')
-rw-r--r-- | sim/mips/ChangeLog | 13 | ||||
-rw-r--r-- | sim/mips/interp.c | 65 |
2 files changed, 52 insertions, 26 deletions
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog index de7075e..f54c1c5 100644 --- a/sim/mips/ChangeLog +++ b/sim/mips/ChangeLog @@ -1,3 +1,16 @@ +Thu Apr 17 03:18:14 1997 Doug Evans <dje@canuck.cygnus.com> + + * Makefile.in (SIM_OBJS): Add sim-load.o. + * interp.c: #include bfd.h. + (target_byte_order): Delete. + (sim_kind, myname, big_endian_p): New static locals. + (sim_open): Set sim_kind, myname. Move call to set_endianness to + after argument parsing. Recognize -E arg, set endianness accordingly. + (sim_load): Return SIM_RC. New arg abfd. Call sim_load_file to + load file into simulator. Set PC from bfd. + (sim_create_inferior): Return SIM_RC. Delete arg start_address. + (set_endianness): Use big_endian_p instead of target_byte_order. + Wed Apr 16 17:55:37 1997 Andrew Cagney <cagney@b1.cygnus.com> * interp.c (sim_size): Delete prototype - conflicts with diff --git a/sim/mips/interp.c b/sim/mips/interp.c index f4b42a9..6ec5cbd 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -62,7 +62,7 @@ code on the hardware. #include "getopt.h" #include "libiberty.h" - +#include "bfd.h" #include "callback.h" /* GDB simulator callback interface */ #include "remote-sim.h" /* GDB simulator interface */ @@ -86,8 +86,9 @@ char* pr_uword64 PARAMS ((uword64 addr)); #include "engine.c" #undef SIM_MANIFESTS -/* This variable holds the GDB view of the target endianness: */ -extern int target_byte_order; +static SIM_OPEN_KIND sim_kind; +static char *myname; +static int big_endian_p; /* The following reserved instruction value is used when a simulator trap is required. NOTE: Care must be taken, since this value may be @@ -666,6 +667,9 @@ sim_open (kind,argv) stdout and stderr are initialised: */ callback->init(callback); + sim_kind = kind; + myname = argv[0]; + state = 0; CHECKSIM(); if (state & simEXCEPTION) { @@ -679,8 +683,6 @@ sim_open (kind,argv) state |= simHOSTBE; /* big-endian host */ } - set_endianness (); - #if defined(HASFPU) /* Check that the host FPU conforms to IEEE 754-1985 for the SINGLE and DOUBLE binary formats. This is a bit nasty, requiring that we @@ -752,11 +754,15 @@ sim_open (kind,argv) while (1) { int option_index = 0; - c = getopt_long(argc,argv,"hn:s:tp",cmdline,&option_index); + c = getopt_long(argc,argv,"E:hn:s:tp",cmdline,&option_index); if (c == -1) break; switch (c) { + case 'E' : + big_endian_p = strcmp (optarg, "big") == 0; + break; + case 'h': callback->printf_filtered(callback,"Usage:\n\t\ target sim [-h] [--log=<file>] [--name=<model>] [--size=<amount>]"); @@ -871,6 +877,8 @@ Re-compile simulator with \"-DPROFILE\" to enable this option.\n"); } } + set_endianness (); + /* If the host has "mmap" available we could use it to provide a very large virtual address space for the simulator, since memory would only be allocated within the "mmap" space as it is @@ -1449,40 +1457,45 @@ sim_info (sd,verbose) return; } -int -sim_load (sd,prog,from_tty) +SIM_RC +sim_load (sd,prog,abfd,from_tty) SIM_DESC sd; char *prog; + bfd *abfd; int from_tty; { - /* Return non-zero if the caller should handle the load. Zero if - we have loaded the image. */ - return(-1); + extern bfd *sim_load_file (); /* ??? Don't know where this should live. */ + bfd *prog_bfd; + + prog_bfd = sim_load_file (sd, myname, callback, prog, abfd, + sim_kind == SIM_OPEN_DEBUG); + if (prog_bfd == NULL) + return SIM_RC_FAIL; +#if 1 + PC = (uword64) bfd_get_start_address (prog_bfd); +#else + /* TODO: Sort this properly. SIM_ADDR may already be a 64bit value: */ + PC = SIGNEXTEND(bfd_get_start_address(prog_bfd),32); +#endif + if (abfd == NULL) + bfd_close (prog_bfd); + return SIM_RC_OK; } -void -sim_create_inferior (sd, start_address,argv,env) +SIM_RC +sim_create_inferior (sd, argv,env) SIM_DESC sd; - SIM_ADDR start_address; char **argv; char **env; { #ifdef DEBUG - printf("DBG: sim_create_inferior entered: start_address = 0x%s\n",pr_addr(start_address)); + printf("DBG: sim_create_inferior entered: start_address = 0x%s\n", + pr_addr(PC)); #endif /* DEBUG */ /* Prepare to execute the program to be simulated */ /* argv and env are NULL terminated lists of pointers */ -#if 1 - PC = (uword64)start_address; -#else - /* TODO: Sort this properly. SIM_ADDR may already be a 64bit value: */ - PC = SIGNEXTEND(start_address,32); -#endif - /* NOTE: GDB normally sets the PC explicitly. However, this call is - used by other clients of the simulator. */ - if (argv || env) { #if 0 /* def DEBUG */ callback->printf_filtered(callback,"sim_create_inferior() : passed arguments ignored\n"); @@ -1498,7 +1511,7 @@ sim_create_inferior (sd, start_address,argv,env) true at the moment. */ } - return; + return SIM_RC_OK; } void @@ -2350,7 +2363,7 @@ set_endianness () within the simulation, since it is possible to change the endianness of user programs. However, we perform the check here to ensure that the start-of-day values agree. */ - if (target_byte_order == 4321) + if (big_endian_p) state |= simBE; /* ??? This is a lot more code than is necessary to solve the problem. |