Store bfd pointer in a global variable

This commit is contained in:
Michael Meissner 1996-09-12 15:28:40 +00:00
parent cacfb845c8
commit 9b280a864b
2 changed files with 29 additions and 6 deletions

View File

@ -1,3 +1,21 @@
Thu Sep 12 11:27:21 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* 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 <ian@cygnus.com>
* run.c (main): Use new bfd_big_endian macro.
Wed Nov 8 15:49:49 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
* 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 <wilson@chestnut.cygnus.com>
* run.c (main): Always return sigrc at end.

View File

@ -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