aboutsummaryrefslogtreecommitdiff
path: root/sim/msp430/msp430-sim.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-03-08 00:20:11 -0500
committerMike Frysinger <vapier@gentoo.org>2014-03-10 23:57:57 -0400
commit7b0278dcad72af1db86e6ecf91751dbc45e3b071 (patch)
treea31efb2671e2bf5088c311de89047000b6629bb7 /sim/msp430/msp430-sim.c
parenta3271a3e6c841729a9ece40af973e275ea2de875 (diff)
downloadgdb-7b0278dcad72af1db86e6ecf91751dbc45e3b071.zip
gdb-7b0278dcad72af1db86e6ecf91751dbc45e3b071.tar.gz
gdb-7b0278dcad72af1db86e6ecf91751dbc45e3b071.tar.bz2
sim: msp430: set initial PC to ELF entry if available
If we want to run a simple ELF, the reset vector isn't set up, so starting at address 0 doesn't make sense. Use the ELF's entry point instead.
Diffstat (limited to 'sim/msp430/msp430-sim.c')
-rw-r--r--sim/msp430/msp430-sim.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index c3fa4a9..2a648f5 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -249,9 +249,14 @@ sim_create_inferior (SIM_DESC sd,
int c;
int new_pc;
+ /* Set the PC to the default reset vector if available. */
c = sim_core_read_buffer (sd, MSP430_CPU (sd), read_map, resetv, 0xfffe, 2);
-
new_pc = resetv[0] + 256 * resetv[1];
+
+ /* If the reset vector isn't initialized, then use the ELF entry. */
+ if (abfd != NULL && !new_pc)
+ new_pc = bfd_get_start_address (abfd);
+
sim_pc_set (MSP430_CPU (sd), new_pc);
msp430_pc_store (MSP430_CPU (sd), new_pc);