Remove '.Sanitize' from explicit list of Things-to-lose. It is now implicitly
[binutils-gdb.git] / sim / sh / run.c
1 /* run front end support for H8/500
2 Copyright (C) 1987, 1992 Free Software Foundation, Inc.
3
4 This file is part of H8300 SIM
5
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)
9 any later version.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 /* Steve Chamberlain
22 sac@cygnus.com */
23
24 #include "bfd.h"
25 #include "sysdep.h"
26
27 int
28 main (ac, av)
29 int ac;
30 char **av;
31 {
32 bfd *abfd;
33 bfd_vma start_address;
34 asection *s;
35 int i;
36 int verbose = 0;
37 int trace = 0;
38 char *name = "";
39
40 for (i = 1; i < ac; i++)
41 {
42 if (strcmp (av[i], "-v") == 0)
43 {
44 verbose = 1;
45 }
46 else if (strcmp (av[i], "-t") == 0)
47 {
48 trace = 1;
49 }
50 else if (strcmp (av[i], "-p") == 0)
51 {
52 sim_set_profile(atoi(av[i+1]));
53 i++;
54 }
55 else if (strcmp (av[i], "-s") == 0)
56 {
57 sim_set_profile_size(atoi(av[i+1]));
58 i++;
59 }
60 else if (strcmp (av[i], "-m") == 0)
61 {
62 sim_size(atoi(av[i+1]));
63 i++;
64 }
65 else
66 {
67 name = av[i];
68 }
69 }
70 if (verbose)
71 {
72 printf ("run %s\n", name);
73 }
74 abfd = bfd_openr (name, "coff-sh");
75 if (abfd)
76 {
77
78 if (bfd_check_format (abfd, bfd_object))
79 {
80
81 for (s = abfd->sections; s; s = s->next)
82 {
83 unsigned char *buffer = malloc (bfd_section_size (abfd, s));
84 bfd_get_section_contents (abfd,
85 s,
86 buffer,
87 0,
88 bfd_section_size (abfd, s));
89 sim_write (s->vma, buffer, bfd_section_size (abfd, s));
90 }
91
92 start_address = bfd_get_start_address (abfd);
93 sim_set_pc (start_address);
94 if (trace)
95 {
96 int done = 0;
97 while (!done)
98 {
99 done = sim_trace ();
100 }
101 }
102 else
103 {
104 sim_resume (0, 0);
105 }
106 if (verbose)
107 sim_info ();
108
109 /* Find out what was in r0 and return that */
110 {
111 unsigned char b[4];
112 sim_fetch_register(0, b);
113 return b[3];
114 }
115
116 }
117 }
118
119 return 1;
120 }