Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v2] sim: msp430: set initial PC to ELF entry if available
Date: Tue, 11 Mar 2014 03:38:00 -0000	[thread overview]
Message-ID: <1394509106-27143-1-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1394256493-15084-2-git-send-email-vapier@gentoo.org>

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


  parent reply	other threads:[~2014-03-11  3:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-08  5:28 [PATCH 1/3] sim: msp430: fix build time warnings Mike Frysinger
2014-03-08  5:28 ` [PATCH 2/3] sim: msp430: set initial PC to ELF entry if available Mike Frysinger
2014-03-10 13:19   ` Nicholas Clifton
2014-03-10 21:09   ` DJ Delorie
2014-03-10 22:28     ` Mike Frysinger
2014-03-11  3:38   ` Mike Frysinger [this message]
2014-03-11  3:44     ` [PATCH v2] " DJ Delorie
2014-03-11  3:57       ` Mike Frysinger
2014-03-11  4:12         ` DJ Delorie
2014-03-08  5:28 ` [PATCH 3/3] sim: msp430: start a test framework Mike Frysinger
2014-03-10 13:56   ` Nicholas Clifton
2014-03-10 13:18 ` [PATCH 1/3] sim: msp430: fix build time warnings Nicholas Clifton
2014-03-10 19:30   ` Mike Frysinger
2014-03-11 16:08     ` Nicholas Clifton
2014-03-11 19:01       ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394509106-27143-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox