This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/3] sim: msp430: set initial PC to ELF entry if available
- From: Mike Frysinger <vapier at gentoo dot org>
- To: gdb-patches at sourceware dot org
- Cc: nickc at redhat dot com
- Date: Sat, 8 Mar 2014 00:28:12 -0500
- Subject: [PATCH 2/3] sim: msp430: set initial PC to ELF entry if available
- Authentication-results: sourceware.org; auth=none
- References: <1394256493-15084-1-git-send-email-vapier at gentoo dot 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. Else, set new_pc to
the existing reset vector.
---
sim/msp430/msp430-sim.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index c3fa4a9..3017080 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -249,9 +249,18 @@ sim_create_inferior (SIM_DESC sd,
int c;
int new_pc;
- c = sim_core_read_buffer (sd, MSP430_CPU (sd), read_map, resetv, 0xfffe, 2);
+ /* Set the PC. */
+ if (abfd != NULL)
+ {
+ new_pc = bfd_get_start_address (abfd);
+ }
+ else
+ {
+ c = sim_core_read_buffer (sd, MSP430_CPU (sd), read_map, resetv, 0xfffe,
+ 2);
+ new_pc = resetv[0] + 256 * resetv[1];
+ }
- new_pc = resetv[0] + 256 * resetv[1];
sim_pc_set (MSP430_CPU (sd), new_pc);
msp430_pc_store (MSP430_CPU (sd), new_pc);
--
1.9.0