From: Michael Meissner Date: Thu, 12 Sep 1996 15:28:40 +0000 (+0000) Subject: Store bfd pointer in a global variable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b280a864b4861885f1b239188b8680d26c83f17;p=binutils-gdb.git Store bfd pointer in a global variable --- diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 7d92a22f54e..8d825a7bb29 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,21 @@ +Thu Sep 12 11:27:21 1996 Michael Meissner + + * run.c (sim_bfd): New global to hold the bfd pointer for the + executable. + (main): Initialize sim_bfd. + +Fri Dec 15 16:27:49 1995 Ian Lance Taylor + + * run.c (main): Use new bfd_big_endian macro. + +Wed Nov 8 15:49:49 1995 James G. Smith + + * run.c (main): Removed SH specific comments, so source is + generic. Also updated to only load relevant sections. Moved + sim_open() to after callback attach (to match GDB). + + * run.1: Removed SH specific comments. + Sat Oct 21 12:31:01 1995 Jim Wilson * run.c (main): Always return sigrc at end. diff --git a/sim/common/run.c b/sim/common/run.c index 15bd0298ce7..982d99c7ad8 100644 --- a/sim/common/run.c +++ b/sim/common/run.c @@ -1,8 +1,6 @@ /* run front end support for all the simulators. Copyright (C) 1992, 1993 1994, 1995 Free Software Foundation, Inc. -This file is part of SH SIM - GNU CC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) @@ -35,6 +33,8 @@ void usage(); extern int optind; extern char *optarg; +bfd *sim_bfd; + int target_byte_order; extern host_callback default_callback; @@ -87,7 +87,7 @@ main (ac, av) printf ("run %s\n", name); } - abfd = bfd_openr (name, 0); + sim_bfd = abfd = bfd_openr (name, 0); if (!abfd) { fprintf (stderr, "run: can't open %s: %s\n", @@ -102,12 +102,15 @@ main (ac, av) exit (1); } - sim_set_callbacks (&default_callback); default_callback.init (&default_callback); + /* Ensure that any run-time initialisation that needs to be + performed by the simulator can occur. */ + sim_open(NULL); + for (s = abfd->sections; s; s = s->next) - if (abfd) + if (abfd && (s->flags & SEC_LOAD)) { unsigned char *buffer = (unsigned char *)malloc (bfd_section_size (abfd, s)); bfd_get_section_contents (abfd, @@ -121,7 +124,7 @@ main (ac, av) start_address = bfd_get_start_address (abfd); sim_create_inferior (start_address, NULL, NULL); - target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234; + target_byte_order = bfd_big_endian (abfd) ? 4321 : 1234; if (trace) { @@ -140,6 +143,8 @@ main (ac, av) sim_stop_reason (&reason, &sigrc); + sim_close(0); + /* If reason is sim_exited, then sigrc holds the exit code which we want to return. If reason is sim_stopped or sim_signalled, then sigrc holds the signal that the simulator received; we want to return that to