1999-04-16 09:35:26 +08:00
|
|
|
/* Generic load for hardware simulator models.
|
2008-01-02 06:53:26 +08:00
|
|
|
Copyright (C) 1997, 2007, 2008 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
Contributed by Cygnus Support.
|
|
|
|
|
|
|
|
This file is part of GDB, the GNU debugger.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 22:30:15 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2007-08-24 22:30:15 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include "sim-main.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "sim-utils.h"
|
|
|
|
#include "sim-assert.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Generic implementation of sim_load that works with simulators
|
|
|
|
modeling a hardware platform. */
|
|
|
|
|
|
|
|
SIM_RC
|
|
|
|
sim_load (sd, prog_name, prog_bfd, from_tty)
|
|
|
|
SIM_DESC sd;
|
|
|
|
char *prog_name;
|
Index: arm/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* wrapper.c (sim_create_inferior, sim_open): Rename _bfd to bfd.
Index: common/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* sim-utils.h (sim_analyze_program, sim_load_file): Rename _bfd to bfd.
* sim-hload.c (sim_load), sim-base.h (sim_state_base): Ditto.
* nrun.c (main): Ditto.
Index: d10v/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: erc32/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interf.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: h8300/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* compile.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: h8500/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* compile.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: i960/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* sim-if.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: m32r/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* sim-if.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: m68hc11/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_prepare_for_program, sim_open)
(sim_create_inferior): Rename _bfd to bfd.
Index: mcore/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: mips/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open):
(sim_create_inferior):
Index: mn10200/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: mn10300/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open, sim_create_inferior, sim_open)
(sim_create_inferior): Rename _bfd to bfd.
Index: ppc/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* sim_calls.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: sh/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (init_dsp, sim_open, sim_create_inferior): Rename _bfd
to bfd.
Index: v850/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* interp.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
Index: z8k/ChangeLog
2003-02-27 Andrew Cagney <cagney@redhat.com>
* iface.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
2003-02-28 07:26:34 +08:00
|
|
|
struct bfd *prog_bfd;
|
1999-04-16 09:35:26 +08:00
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
bfd *result_bfd;
|
|
|
|
|
|
|
|
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
|
|
|
|
if (sim_analyze_program (sd, prog_name, prog_bfd) != SIM_RC_OK)
|
|
|
|
return SIM_RC_FAIL;
|
|
|
|
SIM_ASSERT (STATE_PROG_BFD (sd) != NULL);
|
|
|
|
|
|
|
|
/* NOTE: For historical reasons, older hardware simulators
|
|
|
|
incorrectly write the program sections at LMA interpreted as a
|
|
|
|
virtual address. This is still accommodated for backward
|
|
|
|
compatibility reasons. */
|
|
|
|
|
|
|
|
result_bfd = sim_load_file (sd, STATE_MY_NAME (sd),
|
|
|
|
STATE_CALLBACK (sd),
|
|
|
|
prog_name,
|
|
|
|
STATE_PROG_BFD (sd),
|
|
|
|
STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG,
|
1999-07-12 19:15:22 +08:00
|
|
|
STATE_LOAD_AT_LMA_P (sd),
|
|
|
|
sim_write);
|
1999-04-16 09:35:26 +08:00
|
|
|
if (result_bfd == NULL)
|
|
|
|
{
|
|
|
|
bfd_close (STATE_PROG_BFD (sd));
|
|
|
|
STATE_PROG_BFD (sd) = NULL;
|
|
|
|
return SIM_RC_FAIL;
|
|
|
|
}
|
|
|
|
return SIM_RC_OK;
|
|
|
|
}
|