This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2] sim: msp430: set initial PC to ELF entry if available


If we want to run a simple ELF, it makes more sense to start at the
ELF's entry point instead of requiring the magic reset vector always
be set up.  This matches better what other sims do.

2014-03-08  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.
---
v2
	- use the ELF entry only when the reset vector is not set up.

 sim/msp430/msp430-sim.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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);
 
-- 
1.9.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]