sim: msp430: set initial PC to ELF entry if available
authorMike Frysinger <vapier@gentoo.org>
Sat, 8 Mar 2014 05:20:11 +0000 (00:20 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 11 Mar 2014 03:57:57 +0000 (23:57 -0400)
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.

sim/msp430/ChangeLog
sim/msp430/msp430-sim.c

index 0a3da7d..484a5d2 100644 (file)
@@ -1,5 +1,10 @@
 2014-03-10  Mike Frysinger  <vapier@gentoo.org>
 
+       * msp430-sim.c (sim_create_inferior): Set new_pc to the result of
+       bfd_get_start_address when abfd is not NULL and new_pc is zero.
+
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
        * msp430-sim (maybe_perform_syscall): Change %d to %ld.
        (msp430_step_once): Cast fprintf to fprintf_ftype.
 
index c3fa4a9..2a648f5 100644 (file)
@@ -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);