1 /* run front end support for SH
2 Copyright (C) 1987, 1992 Free Software Foundation, Inc.
4 This file is part of SH SIM
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 #include "remote-sim.h"
34 int target_byte_order;
42 bfd_vma start_address;
49 while ((i = getopt (ac, av, "m:p:s:tv")) != EOF)
53 sim_size (atoi (optarg));
56 sim_set_profile (atoi (optarg));
59 sim_set_profile_size (atoi (optarg));
80 printf ("run %s\n", name);
82 abfd = bfd_openr (name, 0);
85 if (bfd_check_format (abfd, bfd_object))
88 for (s = abfd->sections; s; s = s->next)
90 unsigned char *buffer = malloc (bfd_section_size (abfd, s));
91 bfd_get_section_contents (abfd,
95 bfd_section_size (abfd, s));
96 sim_write (s->vma, buffer, bfd_section_size (abfd, s));
99 start_address = bfd_get_start_address (abfd);
100 sim_create_inferior (start_address, NULL, NULL);
102 target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234;
119 /* Assume we left through the exit system call,
120 in which case r5 has the exit code */
123 sim_fetch_register (5, b);
136 fprintf (stderr, "usage: run [-tv] program\n");
141 /* Callbacks used by the simulator proper. */
144 printf_filtered (va_alist)
151 format = va_arg (args, char *);
153 vfprintf (stdout, format, args);